Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyDefaults(cfg *ExchangeConfig)
- type Account
- type AccountId
- type AccountType
- type AccountTypeConfig
- type Address
- type Amount
- func (amount Amount) Decimal() decimal.Decimal
- func (amount Amount) Div(x Amount) Amount
- func (b Amount) IsZero() bool
- func (b Amount) MarshalJSON() ([]byte, error)
- func (b Amount) MarshalYAML() (interface{}, error)
- func (amount Amount) String() string
- func (amount Amount) ToBlockchain(decimals int32) Balance
- func (b *Amount) UnmarshalJSON(p []byte) error
- func (b *Amount) UnmarshalYAML(node *yaml.Node) error
- type Asset
- type Balance
- func (amount *Balance) Abs() Balance
- func (amount *Balance) Add(x *Balance) Balance
- func (amount Balance) Bytes() []byte
- func (amount *Balance) Cmp(other *Balance) int
- func (amount *Balance) Div(x *Balance) Balance
- func (amount Balance) Int() *big.Int
- func (amount *Balance) IsZero() bool
- func (b Balance) MarshalJSON() ([]byte, error)
- func (amount *Balance) Mul(x *Balance) Balance
- func (amount Balance) Sign() int
- func (amount Balance) String() string
- func (amount *Balance) Sub(x *Balance) Balance
- func (amount *Balance) ToHuman(decimals int32) Amount
- func (amount Balance) Uint64() uint64
- func (b *Balance) UnmarshalJSON(p []byte) error
- func (amount Balance) UnmaskFloat64() float64
- type Config
- type ContractAddress
- type ExchangeClientConfig
- type ExchangeConfig
- func (cfg *ExchangeConfig) AsAccount() *Account
- func (cfg *ExchangeConfig) FirstAccountType() (accountCfg *AccountTypeConfig, ok bool)
- func (cfg *ExchangeConfig) ResolveAccountType(typeOrAlias string) (accountCfg *AccountTypeConfig, ok bool, message string)
- func (cfg *ExchangeConfig) ResolveSubAccount(idOrAlias string) (accountCfg *SubAccount, ok bool)
- type ExchangeId
- type MultiSecret
- type NetworkId
- type StringOrInt
- type SubAccount
- type SubAccountHeader
- type SymbolId
Constants ¶
const ENV_OFFCHAIN_CONFIG = "OFFCHAIN_CONFIG"
const FLOAT_PRECISION = 6
Variables ¶
var ValidExchangeIds = []ExchangeId{Okx, Binance, BinanceUS, Bybit, Backpack}
Functions ¶
func ApplyDefaults ¶
func ApplyDefaults(cfg *ExchangeConfig)
Types ¶
type Account ¶
type Account struct {
Id AccountId
Alias string
SubAccount bool
MultiSecret
}
func (*Account) LoadSecrets ¶
type AccountType ¶
type AccountType string
type AccountTypeConfig ¶
type AccountTypeConfig struct {
// The ID for the account type used by the exchange (e.g. "SPOT" or "ISOLATED_MARGIN" on binance).
Type AccountType `yaml:"type" json:"type"`
// Human readable description of the account type.
Description string `yaml:"description,omitempty" json:"description,omitempty"`
// Any aliases for the account type
Aliases []string `yaml:"aliases,omitempty" json:"aliases,omitempty"`
}
type Amount ¶
Amount is a decimal amount as a human expects it for readability.
func NewAmountFromString ¶
NewAmountFromString creates a new AmountHumanReadable from a string
func NewAmountHumanReadableFromFloat ¶
NewAmountHumanReadableFromFloat creates a new AmountHumanReadable from a float
func (Amount) MarshalJSON ¶
func (Amount) MarshalYAML ¶
func (Amount) ToBlockchain ¶
func (*Amount) UnmarshalJSON ¶
type Asset ¶
type Asset struct {
SymbolId SymbolId `json:"symbol_id"`
NetworkId NetworkId `json:"network_id"`
ContractAddress ContractAddress `json:"contract_address"`
}
type Balance ¶
Balance is a big integer amount as blockchain expects it for tx.
func MultiplyByFloat ¶
func NewAmountBlockchainFromInt64 ¶
NewAmountBlockchainFromUint64 creates a new AmountBlockchain from a uint64
func NewAmountBlockchainFromStr ¶
NewAmountBlockchainFromStr creates a new AmountBlockchain from a string
func NewAmountBlockchainFromUint64 ¶
NewAmountBlockchainFromUint64 creates a new AmountBlockchain from a uint64
func NewAmountBlockchainToMaskFloat64 ¶
NewAmountBlockchainToMaskFloat64 creates a new AmountBlockchain as a float64 times 10^FLOAT_PRECISION
func (Balance) MarshalJSON ¶
func (*Balance) UnmarshalJSON ¶
func (Balance) UnmaskFloat64 ¶
UnmaskFloat64 converts an AmountBlockchain into float64 given the number of decimals
type Config ¶
type Config struct {
Exchanges map[ExchangeId]*ExchangeConfig `yaml:"exchanges"`
}
func LoadUnvalidatedConfig ¶
func (*Config) GetExchange ¶
func (c *Config) GetExchange(id ExchangeId) (*ExchangeConfig, bool)
type ContractAddress ¶
type ContractAddress string
type ExchangeClientConfig ¶
type ExchangeClientConfig struct {
ApiUrl string `yaml:"api_url"`
// The account types supported by the exchange.
AccountTypes []*AccountTypeConfig `yaml:"account_types"`
NoAccountTypes *bool `yaml:"no_account_types,omitempty"`
}
func GetDefaultConfig ¶
func GetDefaultConfig(exchangeId ExchangeId) (ExchangeClientConfig, bool)
type ExchangeConfig ¶
type ExchangeConfig struct {
ExchangeId ExchangeId `yaml:"exchange"`
ExchangeClientConfig `yaml:",inline"`
// ApiKeyRef secret.Secret `yaml:"api_key"`
// SecretKeyRef secret.Secret `yaml:"secret_key"`
// PassphraseRef secret.Secret `yaml:"passphrase"`
MultiSecret `yaml:",inline"`
// Id of the main account, if required by the exchange.
Id AccountId `yaml:"id"`
// Subaccounts are isolated accounts on an exchange. They have their own API keys and are
// typically used for trading.
SubAccounts []*SubAccount `yaml:"subaccounts"`
}
Main configuration for an exchange
func (*ExchangeConfig) AsAccount ¶
func (cfg *ExchangeConfig) AsAccount() *Account
func (*ExchangeConfig) FirstAccountType ¶
func (cfg *ExchangeConfig) FirstAccountType() (accountCfg *AccountTypeConfig, ok bool)
func (*ExchangeConfig) ResolveAccountType ¶
func (cfg *ExchangeConfig) ResolveAccountType(typeOrAlias string) (accountCfg *AccountTypeConfig, ok bool, message string)
func (*ExchangeConfig) ResolveSubAccount ¶
func (cfg *ExchangeConfig) ResolveSubAccount(idOrAlias string) (accountCfg *SubAccount, ok bool)
type ExchangeId ¶
type ExchangeId string
var ( Okx ExchangeId = "okx" Binance ExchangeId = "binance" BinanceUS ExchangeId = "binanceus" Bybit ExchangeId = "bybit" Backpack ExchangeId = "backpack" )
type MultiSecret ¶
type MultiSecret struct {
ApiKeyRef secret.Secret `yaml:"api_key"`
SecretKeyRef secret.Secret `yaml:"secret_key"`
PassphraseRef secret.Secret `yaml:"passphrase"`
// Loads all api_key, secret_key, passphrase if this is set.
// The format must either be:
// - separated by newlines in order of (<api_key>, <secret_key>, [passphrase])
// - or a JSON object with the keys "api_key", "secret_key", and optionally "passphrase"
SecretsRef secret.Secret `yaml:"secrets"`
}
func (*MultiSecret) LoadSecrets ¶
func (c *MultiSecret) LoadSecrets() error
type StringOrInt ¶
type StringOrInt string
func (StringOrInt) AsInt ¶
func (s StringOrInt) AsInt() (uint64, bool)
func (StringOrInt) AsString ¶
func (s StringOrInt) AsString() string
type SubAccount ¶
type SubAccount struct {
SubAccountHeader `yaml:",inline"`
MultiSecret `yaml:",inline"`
}
A subaccount is an isolated account on an exchange. It's just like a main account, but typically you cannot withdraw funds from it directly. Instead, funds must be transferred to the main account first. Subaccounts have their own independent API keys.
func (*SubAccount) AsAccount ¶
func (cfg *SubAccount) AsAccount() *Account
type SubAccountHeader ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
oc
command
|
|
|
exchanges
|
|
|
pkg
|
|
|
secret/examples/secret
command
|
|
|
client/api
Package api provides primitives to interact with the openapi HTTP API.
|
Package api provides primitives to interact with the openapi HTTP API. |
