catalog

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKey

type APIKey struct {
	ID         int             `json:"id"`
	UserID     int             `json:"user_id"`
	ExchID     common.Exchange `json:"-"`
	UID        int             `json:"uid"`
	Name       string          `json:"name"`
	APIType    APIType         `json:"api_type"`
	Key        string          `json:"api_key"`
	Secret     string          `json:"api_secret"`
	Passphrase string          `json:"passphrase"`
	ParentUID  int             `json:"parent_uid"`
	CreatedAt  string          `json:"created_at"`
}

APIKey represents API credentials

type APIKeyConfig

type APIKeyConfig struct {
	Name       string `yaml:"name"`
	Type       string `yaml:"type"` // HMAC | RSA | ED25519
	Key        string `yaml:"key"`
	Secret     string `yaml:"secret"`
	Passphrase string `yaml:"passphrase"`
}

APIKeyConfig defines API credentials in the YAML config. Key, Secret and Passphrase support ${ENV_VAR} expansion.

type APIType

type APIType string

APIType represents the type of API authentication

const (
	APITypeHMAC    APIType = "HMAC"
	APITypeRSA     APIType = "RSA"
	APITypeED25519 APIType = "ED25519"
)

type Account

type Account struct {
	ID        int             `json:"id"`
	UID       int             `json:"uid"`
	ExchID    common.Exchange `json:"exch_id"`
	Exchange  string          `json:"exchange"`
	Name      string          `json:"name"`
	ParentUID int             `json:"parent_uid"`
	// contains filtered or unexported fields
}

Account represents an exchange account

func (*Account) GetAPI

func (a *Account) GetAPI(name string) (*APIKey, error)

GetAPI returns the API key with the given name, or an error if not found

func (*Account) GetWallet

func (a *Account) GetWallet(name string) (*Wallet, error)

GetWallet returns the wallet with the given name, or an error if not found

func (*Account) SetAPIKeys

func (a *Account) SetAPIKeys(keys []APIKey)

SetAPIKeys sets the API keys for this account (used by catalog)

func (*Account) SetWallets

func (a *Account) SetWallets(wallets []Wallet)

SetWallets sets the wallets for this account (used by catalog)

type AccountConfig

type AccountConfig struct {
	Name     string         `yaml:"name"`
	Exchange string         `yaml:"exchange"` // Binance | Bybit
	APIKeys  []APIKeyConfig `yaml:"api_keys"`
	Wallets  []WalletConfig `yaml:"wallets"`
}

AccountConfig defines an exchange account in the YAML config.

type Catalog

type Catalog struct {
	// contains filtered or unexported fields
}

func NewCatalog

func NewCatalog(cfg Config) (*Catalog, error)

NewCatalog builds a catalog from a local instruments JSON file and the accounts defined in the configuration.

func (*Catalog) GetAccount

func (c *Catalog) GetAccount(accountID int) (*Account, error)

func (*Catalog) GetAccountByName

func (c *Catalog) GetAccountByName(name string) *Account

GetAccountByName returns the account with the given name, or nil if not found.

func (*Catalog) GetSymbol

func (c *Catalog) GetSymbol(symbolID int) (*Symbol, error)

func (*Catalog) GetSymbolByExchangeAndName

func (c *Catalog) GetSymbolByExchangeAndName(exchangeName, symbolName string) (*Symbol, error)

GetSymbolByExchangeAndName returns the symbol for the given exchange name and symbol name (e.g. "Binance", "BTCUSDT"). Exchange name comparison is case-insensitive. Uses exchangeID -> symbolName -> symbol index for O(1) lookup.

func (*Catalog) GetSymbolByUniversalTicker

func (c *Catalog) GetSymbolByUniversalTicker(universalTicker string) (*Symbol, error)

func (*Catalog) GetToken

func (c *Catalog) GetToken(tokenID int) (*Token, error)

func (*Catalog) GetTokenIDByName

func (c *Catalog) GetTokenIDByName(name string) (int, error)

func (*Catalog) GetWalletByName

func (c *Catalog) GetWalletByName(name string) (*Wallet, error)

GetWalletByName searches all accounts and returns the wallet with the given name.

type Config

type Config struct {
	// Instruments is the path to a JSON file containing the full list of
	// tradable symbols (see Symbol for the expected shape).
	Instruments string `yaml:"instruments"`
	// Accounts defines exchange accounts, their API credentials and wallets.
	Accounts []AccountConfig `yaml:"accounts"`
}

Config contains catalog service configuration.

type Exchange

type Exchange struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
	Slug string `json:"slug"`
}

Exchange represents exchange information

type Product

type Product struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
	Slug string `json:"slug"`
}

Product represents product type information (e.g., SPOT)

type Symbol

type Symbol struct {
	ID              int      `json:"id"`
	Name            string   `json:"name"`
	Exchange        Exchange `json:"exchange"`
	Product         Product  `json:"product"`
	BaseToken       Token    `json:"base_token"`
	QuoteToken      Token    `json:"quote_token"`
	PricePrecision  int      `json:"price_precision"`
	SizePrecision   int      `json:"size_precision"`
	UniversalTicker string   `json:"universal_ticker"`
}

Symbol represents a trading symbol (instrument)

type Token

type Token struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
	Slug string `json:"slug"`
}

Token represents token/asset information

type Wallet

type Wallet struct {
	ID         int               `json:"id"`
	Name       string            `json:"name"`
	WalletType common.WalletType `json:"category_id"`
	AcctID     int               `json:"acct_id"`
	UserID     int               `json:"user_id"`
	IsActive   bool              `json:"is_active"`
}

Wallet represents a wallet belonging to an account

type WalletConfig

type WalletConfig struct {
	Name string `yaml:"name"`
	Type string `yaml:"type"` // spot | umargin | cmargin | leverage | unified
}

WalletConfig defines a wallet in the YAML config.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL