Documentation ¶
Index ¶
- Constants
- Variables
- func IsSupported(exchangeName string) bool
- type API
- type Base
- func (e *Base) AllowAuthenticatedRequest() bool
- func (e *Base) CheckTransientError(err error) error
- func (e *Base) DisableRateLimiter() error
- func (e *Base) EnableRateLimiter() error
- func (e *Base) FormatExchangeCurrencies(pairs []currency.Pair, assetType asset.Item) (string, error)
- func (e *Base) FormatExchangeCurrency(p currency.Pair, assetType asset.Item) currency.Pair
- func (e *Base) FormatWithdrawPermissions() string
- func (e *Base) GetAPIURL() string
- func (e *Base) GetAPIURLDefault() string
- func (e *Base) GetAPIURLSecondaryDefault() string
- func (e *Base) GetAssetTypes() asset.Items
- func (e *Base) GetAuthenticatedAPISupport(endpoint uint8) bool
- func (e *Base) GetAvailablePairs(assetType asset.Item) currency.Pairs
- func (e *Base) GetBase() *Base
- func (e *Base) GetClientBankAccounts(exchangeName, withdrawalCurrency string) (*banking.Account, error)
- func (e *Base) GetEnabledFeatures() FeaturesEnabled
- func (e *Base) GetEnabledPairs(assetType asset.Item) currency.Pairs
- func (e *Base) GetExchangeBankAccounts(id, depositCurrency string) (*banking.Account, error)
- func (e *Base) GetHTTPClient() *http.Client
- func (e *Base) GetHTTPClientUserAgent() string
- func (e *Base) GetLastPairsUpdateTime() int64
- func (e *Base) GetName() string
- func (e *Base) GetPairAssetType(c currency.Pair) (asset.Item, error)
- func (e *Base) GetPairFormat(assetType asset.Item, requestFormat bool) currency.PairFormat
- func (e *Base) GetRequestFormattedPairAndAssetType(p string) (currency.Pair, asset.Item, error)
- func (e *Base) GetSecondaryAPIURL() string
- func (e *Base) GetSupportedFeatures() FeaturesSupported
- func (e *Base) GetWithdrawPermissions() uint32
- func (e *Base) IsEnabled() bool
- func (e *Base) IsWebsocketEnabled() bool
- func (e *Base) PrintEnabledPairs()
- func (e *Base) SetAPICredentialDefaults()
- func (e *Base) SetAPIKeys(apiKey, apiSecret, clientID string)
- func (e *Base) SetAPIURL() error
- func (e *Base) SetAssetTypes()
- func (e *Base) SetClientProxyAddress(addr string) error
- func (e *Base) SetConfigPairs()
- func (e *Base) SetCurrencyPairFormat()
- func (e *Base) SetEnabled(enabled bool)
- func (e *Base) SetFeatureDefaults()
- func (e *Base) SetHTTPClient(h *http.Client)
- func (e *Base) SetHTTPClientTimeout(t time.Duration)
- func (e *Base) SetHTTPClientUserAgent(ua string)
- func (e *Base) SetPairs(pairs currency.Pairs, assetType asset.Item, enabled bool) error
- func (e *Base) SetupDefaults(exch *config.ExchangeConfig) error
- func (e *Base) SupportsAsset(a asset.Item) bool
- func (e *Base) SupportsAutoPairUpdates() bool
- func (e *Base) SupportsPair(p currency.Pair, enabledPairs bool, assetType asset.Item) bool
- func (e *Base) SupportsREST() bool
- func (e *Base) SupportsRESTTickerBatchUpdates() bool
- func (e *Base) SupportsWebsocket() bool
- func (e *Base) SupportsWithdrawPermissions(permissions uint32) bool
- func (e *Base) UpdatePairs(exchangeProducts currency.Pairs, assetType asset.Item, enabled, force bool) error
- func (e *Base) ValidateAPICredentials() bool
- type Features
- type FeaturesEnabled
- type FeaturesSupported
- type FeeBuilder
- type FeeType
- type FundHistory
- type IBotExchange
- type InternationalBankTransactionType
- type TradeHistory
Constants ¶
const ( // WarningAuthenticatedRequestWithoutCredentialsSet error message for authenticated request without credentials set WarningAuthenticatedRequestWithoutCredentialsSet = "exchange %s authenticated HTTP request called but not supported due to unset/default API keys" // DefaultHTTPTimeout is the default HTTP/HTTPS Timeout for exchange requests DefaultHTTPTimeout = time.Second * 15 // DefaultWebsocketResponseCheckTimeout is the default delay in checking for an expected websocket response DefaultWebsocketResponseCheckTimeout = time.Millisecond * 50 // DefaultWebsocketResponseMaxLimit is the default max wait for an expected websocket response before a timeout DefaultWebsocketResponseMaxLimit = time.Second * 7 // DefaultWebsocketOrderbookBufferLimit is the maximum number of orderbook updates that get stored before being applied DefaultWebsocketOrderbookBufferLimit = 5 )
const ( RestAuthentication uint8 = 0 WebsocketAuthentication uint8 = 1 // Repeated exchange strings // FeeType custom type for calculating fees based on method WireTransfer InternationalBankTransactionType = iota PerfectMoney Neteller AdvCash Payeer Skrill Simplex SEPA Swift RapidTransfer MisterTangoSEPA Qiwi VisaMastercard WebMoney Capitalist WesternUnion MoneyGram Contact // Const declarations for fee types BankFee FeeType = iota InternationalBankDepositFee InternationalBankWithdrawalFee CryptocurrencyTradeFee CyptocurrencyDepositFee CryptocurrencyWithdrawalFee OfflineTradeFee // Definitions for each type of withdrawal method for a given exchange NoAPIWithdrawalMethods uint32 = 0 NoAPIWithdrawalMethodsText string = "NONE, WEBSITE ONLY" AutoWithdrawCrypto uint32 = (1 << 0) AutoWithdrawCryptoWithAPIPermission uint32 = (1 << 1) AutoWithdrawCryptoWithSetup uint32 = (1 << 2) AutoWithdrawCryptoText string = "AUTO WITHDRAW CRYPTO" AutoWithdrawCryptoWithAPIPermissionText string = "AUTO WITHDRAW CRYPTO WITH API PERMISSION" AutoWithdrawCryptoWithSetupText string = "AUTO WITHDRAW CRYPTO WITH SETUP" WithdrawCryptoWith2FA uint32 = (1 << 3) WithdrawCryptoWithSMS uint32 = (1 << 4) WithdrawCryptoWithEmail uint32 = (1 << 5) WithdrawCryptoWithWebsiteApproval uint32 = (1 << 6) WithdrawCryptoWithAPIPermission uint32 = (1 << 7) WithdrawCryptoWith2FAText string = "WITHDRAW CRYPTO WITH 2FA" WithdrawCryptoWithSMSText string = "WITHDRAW CRYPTO WITH SMS" WithdrawCryptoWithEmailText string = "WITHDRAW CRYPTO WITH EMAIL" WithdrawCryptoWithWebsiteApprovalText string = "WITHDRAW CRYPTO WITH WEBSITE APPROVAL" WithdrawCryptoWithAPIPermissionText string = "WITHDRAW CRYPTO WITH API PERMISSION" AutoWithdrawFiat uint32 = (1 << 8) AutoWithdrawFiatWithAPIPermission uint32 = (1 << 9) AutoWithdrawFiatWithSetup uint32 = (1 << 10) AutoWithdrawFiatText string = "AUTO WITHDRAW FIAT" AutoWithdrawFiatWithAPIPermissionText string = "AUTO WITHDRAW FIAT WITH API PERMISSION" AutoWithdrawFiatWithSetupText string = "AUTO WITHDRAW FIAT WITH SETUP" WithdrawFiatWith2FA uint32 = (1 << 11) WithdrawFiatWithSMS uint32 = (1 << 12) WithdrawFiatWithEmail uint32 = (1 << 13) WithdrawFiatWithWebsiteApproval uint32 = (1 << 14) WithdrawFiatWithAPIPermission uint32 = (1 << 15) WithdrawFiatWith2FAText string = "WITHDRAW FIAT WITH 2FA" WithdrawFiatWithSMSText string = "WITHDRAW FIAT WITH SMS" WithdrawFiatWithEmailText string = "WITHDRAW FIAT WITH EMAIL" WithdrawFiatWithWebsiteApprovalText string = "WITHDRAW FIAT WITH WEBSITE APPROVAL" WithdrawFiatWithAPIPermissionText string = "WITHDRAW FIAT WITH API PERMISSION" WithdrawCryptoViaWebsiteOnly uint32 = (1 << 16) WithdrawFiatViaWebsiteOnly uint32 = (1 << 17) WithdrawCryptoViaWebsiteOnlyText string = "WITHDRAW CRYPTO VIA WEBSITE ONLY" WithdrawFiatViaWebsiteOnlyText string = "WITHDRAW FIAT VIA WEBSITE ONLY" NoFiatWithdrawals uint32 = (1 << 18) NoFiatWithdrawalsText string = "NO FIAT WITHDRAWAL" UnknownWithdrawalTypeText string = "UNKNOWN" )
Endpoint authentication types
Variables ¶
var Exchanges = []string{
"binance",
"bitfinex",
"bitflyer",
"bithumb",
"bitmex",
"bitstamp",
"bittrex",
"btc markets",
"btse",
"coinbasepro",
"coinbene",
"coinut",
"exmo",
"gateio",
"gemini",
"hitbtc",
"huobi",
"itbit",
"kraken",
"lakebtc",
"lbank",
"localbitcoins",
"okcoin international",
"okex",
"poloniex",
"yobit",
"zb",
}
Exchanges stores a list of supported exchanges
Functions ¶
func IsSupported ¶
IsSupported returns whether or not a specific exchange is supported
Types ¶
type API ¶
type API struct { AuthenticatedSupport bool AuthenticatedWebsocketSupport bool PEMKeySupport bool Endpoints struct { URL string URLDefault string URLSecondary string URLSecondaryDefault string WebsocketURL string } Credentials struct { Key string Secret string ClientID string PEMKey string } CredentialsValidator struct { // For Huobi (optional) RequiresPEM bool RequiresKey bool RequiresSecret bool RequiresClientID bool RequiresBase64DecodeSecret bool } }
API stores the exchange API settings
type Base ¶
type Base struct { Name string Enabled bool Verbose bool LoadedByConfig bool SkipAuthCheck bool API API BaseCurrencies currency.Currencies CurrencyPairs currency.PairsManager Features Features HTTPTimeout time.Duration HTTPUserAgent string HTTPRecording bool HTTPDebugging bool WebsocketResponseCheckTimeout time.Duration WebsocketResponseMaxLimit time.Duration WebsocketOrderbookBufferLimit int64 Websocket *wshandler.Websocket *request.Requester Config *config.ExchangeConfig }
Base stores the individual exchange information
func (*Base) AllowAuthenticatedRequest ¶
AllowAuthenticatedRequest checks to see if the required fields have been set before sending an authenticated API request
func (*Base) CheckTransientError ¶
CheckTransientError catches transient errors and returns nil if found, used for validation of API credentials
func (*Base) DisableRateLimiter ¶
DisableRateLimiter disables the rate limiting system for the exchange
func (*Base) EnableRateLimiter ¶
EnableRateLimiter enables the rate limiting system for the exchange
func (*Base) FormatExchangeCurrencies ¶
func (e *Base) FormatExchangeCurrencies(pairs []currency.Pair, assetType asset.Item) (string, error)
FormatExchangeCurrencies returns a string containing the exchanges formatted currency pairs
func (*Base) FormatExchangeCurrency ¶
FormatExchangeCurrency is a method that formats and returns a currency pair based on the user currency display preferences
func (*Base) FormatWithdrawPermissions ¶
FormatWithdrawPermissions will return each of the exchange's compatible withdrawal methods in readable form
func (*Base) GetAPIURLDefault ¶
GetAPIURLDefault returns exchange default URL
func (*Base) GetAPIURLSecondaryDefault ¶
GetAPIURLSecondaryDefault returns exchange default secondary URL
func (*Base) GetAssetTypes ¶
GetAssetTypes returns the available asset types for an individual exchange
func (*Base) GetAuthenticatedAPISupport ¶
GetAuthenticatedAPISupport returns whether the exchange supports authenticated API requests
func (*Base) GetAvailablePairs ¶
GetAvailablePairs is a method that returns the available currency pairs of the exchange by asset type
func (*Base) GetClientBankAccounts ¶
func (e *Base) GetClientBankAccounts(exchangeName, withdrawalCurrency string) (*banking.Account, error)
GetClientBankAccounts returns banking details associated with a client for withdrawal purposes
func (*Base) GetEnabledFeatures ¶
func (e *Base) GetEnabledFeatures() FeaturesEnabled
GetEnabledFeatures returns the exchanges enabled features
func (*Base) GetEnabledPairs ¶
GetEnabledPairs is a method that returns the enabled currency pairs of the exchange by asset type
func (*Base) GetExchangeBankAccounts ¶
GetExchangeBankAccounts returns banking details associated with an exchange for funding purposes
func (*Base) GetHTTPClient ¶
GetHTTPClient gets the exchanges HTTP client
func (*Base) GetHTTPClientUserAgent ¶
GetHTTPClientUserAgent gets the exchanges HTTP user agent
func (*Base) GetLastPairsUpdateTime ¶
GetLastPairsUpdateTime returns the unix timestamp of when the exchanges currency pairs were last updated
func (*Base) GetPairAssetType ¶
GetPairAssetType returns the associated asset type for the currency pair
func (*Base) GetPairFormat ¶
GetPairFormat returns the pair format based on the exchange and asset type
func (*Base) GetRequestFormattedPairAndAssetType ¶
GetRequestFormattedPairAndAssetType is a method that returns the enabled currency pair of along with its asset type. Only use when there is no chance of the same name crossing over
func (*Base) GetSecondaryAPIURL ¶
GetSecondaryAPIURL returns the set Secondary API URL
func (*Base) GetSupportedFeatures ¶
func (e *Base) GetSupportedFeatures() FeaturesSupported
GetSupportedFeatures returns the exchanges supported features
func (*Base) GetWithdrawPermissions ¶
GetWithdrawPermissions passes through the exchange's withdraw permissions
func (*Base) IsWebsocketEnabled ¶
IsWebsocketEnabled returns whether or not the exchange has its websocket client enabled
func (*Base) PrintEnabledPairs ¶
func (e *Base) PrintEnabledPairs()
PrintEnabledPairs prints the exchanges enabled asset pairs
func (*Base) SetAPICredentialDefaults ¶
func (e *Base) SetAPICredentialDefaults()
SetAPICredentialDefaults sets the API Credential validator defaults
func (*Base) SetAPIKeys ¶
SetAPIKeys is a method that sets the current API keys for the exchange
func (*Base) SetAssetTypes ¶
func (e *Base) SetAssetTypes()
SetAssetTypes checks the exchange asset types (whether it supports SPOT, Binary or Futures) and sets it to a default setting if it doesn't exist
func (*Base) SetClientProxyAddress ¶
SetClientProxyAddress sets a proxy address for REST and websocket requests
func (*Base) SetConfigPairs ¶
func (e *Base) SetConfigPairs()
SetConfigPairs sets the exchanges currency pairs to the pairs set in the config
func (*Base) SetCurrencyPairFormat ¶
func (e *Base) SetCurrencyPairFormat()
SetCurrencyPairFormat checks the exchange request and config currency pair formats and syncs it with the exchanges SetDefault settings
func (*Base) SetEnabled ¶
SetEnabled is a method that sets if the exchange is enabled
func (*Base) SetFeatureDefaults ¶
func (e *Base) SetFeatureDefaults()
SetFeatureDefaults sets the exchanges default feature support set
func (*Base) SetHTTPClient ¶
SetHTTPClient sets exchanges HTTP client
func (*Base) SetHTTPClientTimeout ¶
SetHTTPClientTimeout sets the timeout value for the exchanges HTTP Client
func (*Base) SetHTTPClientUserAgent ¶
SetHTTPClientUserAgent sets the exchanges HTTP user agent
func (*Base) SetPairs ¶
SetPairs sets the exchange currency pairs for either enabledPairs or availablePairs
func (*Base) SetupDefaults ¶
func (e *Base) SetupDefaults(exch *config.ExchangeConfig) error
SetupDefaults sets the exchange settings based on the supplied config
func (*Base) SupportsAsset ¶
SupportsAsset whether or not the supplied asset is supported by the exchange
func (*Base) SupportsAutoPairUpdates ¶
SupportsAutoPairUpdates returns whether or not the exchange supports auto currency pair updating
func (*Base) SupportsPair ¶
SupportsPair returns true or not whether a currency pair exists in the exchange available currencies or not
func (*Base) SupportsREST ¶
SupportsREST returns whether or not the exchange supports REST
func (*Base) SupportsRESTTickerBatchUpdates ¶
SupportsRESTTickerBatchUpdates returns whether or not the exhange supports REST batch ticker fetching
func (*Base) SupportsWebsocket ¶
SupportsWebsocket returns whether or not the exchange supports websocket
func (*Base) SupportsWithdrawPermissions ¶
SupportsWithdrawPermissions compares the supplied permissions with the exchange's to verify they're supported
func (*Base) UpdatePairs ¶
func (e *Base) UpdatePairs(exchangeProducts currency.Pairs, assetType asset.Item, enabled, force bool) error
UpdatePairs updates the exchange currency pairs for either enabledPairs or availablePairs
func (*Base) ValidateAPICredentials ¶
ValidateAPICredentials validates the exchanges API credentials
type Features ¶
type Features struct { Supports FeaturesSupported Enabled FeaturesEnabled }
Features stores the supported and enabled features for the exchange
type FeaturesEnabled ¶
type FeaturesEnabled struct {
AutoPairUpdates bool
}
FeaturesEnabled stores the exchange enabled features
type FeaturesSupported ¶
type FeaturesSupported struct { REST bool RESTCapabilities protocol.Features Websocket bool WebsocketCapabilities protocol.Features WithdrawPermissions uint32 }
FeaturesSupported stores the exchanges supported features
type FeeBuilder ¶
type FeeBuilder struct { FeeType FeeType // Used for calculating crypto trading fees, deposits & withdrawals Pair currency.Pair IsMaker bool // Fiat currency used for bank deposits & withdrawals FiatCurrency currency.Code BankTransactionType InternationalBankTransactionType // Used to multiply for fee calculations PurchasePrice float64 Amount float64 }
FeeBuilder is the type which holds all parameters required to calculate a fee for an exchange
type FeeType ¶
type FeeType uint8
FeeType is the type for holding a custom fee type (International withdrawal fee)
type FundHistory ¶
type FundHistory struct { ExchangeName string Status string TransferID string Description string Timestamp time.Time Currency string Amount float64 Fee float64 TransferType string CryptoToAddress string CryptoFromAddress string CryptoTxID string BankTo string BankFrom string }
FundHistory holds exchange funding history data
type IBotExchange ¶
type IBotExchange interface { Setup(exch *config.ExchangeConfig) error Start(wg *sync.WaitGroup) SetDefaults() GetName() string IsEnabled() bool SetEnabled(bool) ValidateCredentials() error FetchTicker(p currency.Pair, a asset.Item) (*ticker.Price, error) UpdateTicker(p currency.Pair, a asset.Item) (*ticker.Price, error) FetchOrderbook(p currency.Pair, a asset.Item) (*orderbook.Base, error) UpdateOrderbook(p currency.Pair, a asset.Item) (*orderbook.Base, error) FetchTradablePairs(a asset.Item) ([]string, error) UpdateTradablePairs(forceUpdate bool) error GetEnabledPairs(a asset.Item) currency.Pairs GetAvailablePairs(a asset.Item) currency.Pairs FetchAccountInfo() (account.Holdings, error) UpdateAccountInfo() (account.Holdings, error) GetAuthenticatedAPISupport(endpoint uint8) bool SetPairs(pairs currency.Pairs, a asset.Item, enabled bool) error GetAssetTypes() asset.Items GetExchangeHistory(p currency.Pair, a asset.Item) ([]TradeHistory, error) SupportsAutoPairUpdates() bool SupportsRESTTickerBatchUpdates() bool GetFeeByType(f *FeeBuilder) (float64, error) GetLastPairsUpdateTime() int64 GetWithdrawPermissions() uint32 FormatWithdrawPermissions() string SupportsWithdrawPermissions(permissions uint32) bool GetFundingHistory() ([]FundHistory, error) SubmitOrder(s *order.Submit) (order.SubmitResponse, error) ModifyOrder(action *order.Modify) (string, error) CancelOrder(order *order.Cancel) error CancelAllOrders(orders *order.Cancel) (order.CancelAllResponse, error) GetOrderInfo(orderID string) (order.Detail, error) GetDepositAddress(cryptocurrency currency.Code, accountID string) (string, error) GetOrderHistory(getOrdersRequest *order.GetOrdersRequest) ([]order.Detail, error) GetActiveOrders(getOrdersRequest *order.GetOrdersRequest) ([]order.Detail, error) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) SetHTTPClientUserAgent(ua string) GetHTTPClientUserAgent() string SetClientProxyAddress(addr string) error SupportsWebsocket() bool SupportsREST() bool IsWebsocketEnabled() bool GetWebsocket() (*wshandler.Websocket, error) SubscribeToWebsocketChannels(channels []wshandler.WebsocketChannelSubscription) error UnsubscribeToWebsocketChannels(channels []wshandler.WebsocketChannelSubscription) error AuthenticateWebsocket() error GetSubscriptions() ([]wshandler.WebsocketChannelSubscription, error) GetDefaultConfig() (*config.ExchangeConfig, error) GetBase() *Base SupportsAsset(assetType asset.Item) bool GetHistoricCandles(p currency.Pair, a asset.Item, timeStart, timeEnd time.Time, interval time.Duration) (kline.Item, error) DisableRateLimiter() error EnableRateLimiter() error }
IBotExchange enforces standard functions for all exchanges supported in GoCryptoTrader
type InternationalBankTransactionType ¶
type InternationalBankTransactionType uint8
InternationalBankTransactionType custom type for calculating fees based on fiat transaction types
Directories ¶
Path | Synopsis |
---|---|
Package gemini exchange documentation can be found at https://docs.sandbox.gemini.com
|
Package gemini exchange documentation can be found at https://docs.sandbox.gemini.com |
websocket
|
|