mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-14 07:26:47 +00:00
* orderbook: export orderbook nodes for external strategy inspection * orderbook: Add in methods for locking and unlocking multiple books at the same time e.g. book1.LockWith(book2); defer book1.UnlockWith(book2) * include waiting functionality for depth change alert * backtester: add word. * log: include logger changes to impl with downstream integration * engine: reduce params for loading exchange * assort: rm verbose in tests, change wording in ob, expose sync.waitgroup for ext. sync options * ticker: reduce map look ups and contention when using RW mutex when there are over 80% writes adds find last function to get the latest rate * engine/syncmanager: add in waitgroup for step over for external package calls * cleaup * engine: linter fix * currency/fx: include all references to fiat currencies to default * orderbook: Add in fields to Unsafe type for strategies to detect potential out of sync book operations * syncmanager: changed config variable to display correct time * ordermanager: Add time when none provided * currency/manager: update getasset param to get enabled assets for minor optimizations * ftx: use get all wallet balances for a better accounts breakdown * orderbook: unlock in reverse order * bithumb: fixes bug on market buy and sell orders * bithumb: fix bug for nonce is also time window sensitive * bithumb: get orders add required parameter * bithumb: Add asset type to account struct * currency: improve log output when checking currency and it fails * bithumb: Add error return on incomplete pair * ticker:unexport all service related methods * ticker/currency: fixes * orderbook: fix comment * engine: revert variable name in LoadExchange method * sync_manager: fix panic when enabling disabling manager * engine: fix naming convention of exported function and comments * engine: update comment * orderbook: fix comment for unsafe type
95 lines
4.6 KiB
Go
95 lines
4.6 KiB
Go
package exchange
|
|
|
|
import (
|
|
"sync"
|
|
"time"
|
|
|
|
"github.com/thrasher-corp/gocryptotrader/config"
|
|
"github.com/thrasher-corp/gocryptotrader/currency"
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/account"
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/kline"
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/orderbook"
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/stream"
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/trade"
|
|
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
|
)
|
|
|
|
// IBotExchange enforces standard functions for all exchanges supported in
|
|
// GoCryptoTrader
|
|
type IBotExchange interface {
|
|
Setup(exch *config.ExchangeConfig) error
|
|
Start(wg *sync.WaitGroup)
|
|
SetDefaults()
|
|
GetName() string
|
|
IsEnabled() bool
|
|
SetEnabled(bool)
|
|
ValidateCredentials(a asset.Item) 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, error)
|
|
GetAvailablePairs(a asset.Item) (currency.Pairs, error)
|
|
FetchAccountInfo(a asset.Item) (account.Holdings, error)
|
|
UpdateAccountInfo(a asset.Item) (account.Holdings, error)
|
|
GetAuthenticatedAPISupport(endpoint uint8) bool
|
|
SetPairs(pairs currency.Pairs, a asset.Item, enabled bool) error
|
|
GetAssetTypes(enabled bool) asset.Items
|
|
GetRecentTrades(p currency.Pair, a asset.Item) ([]trade.Data, error)
|
|
GetHistoricTrades(p currency.Pair, a asset.Item, startTime, endTime time.Time) ([]trade.Data, 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(o *order.Cancel) error
|
|
CancelBatchOrders(o []order.Cancel) (order.CancelBatchResponse, error)
|
|
CancelAllOrders(orders *order.Cancel) (order.CancelAllResponse, error)
|
|
GetOrderInfo(orderID string, pair currency.Pair, assetType asset.Item) (order.Detail, error)
|
|
GetDepositAddress(cryptocurrency currency.Code, accountID string) (string, error)
|
|
GetOrderHistory(getOrdersRequest *order.GetOrdersRequest) ([]order.Detail, error)
|
|
GetWithdrawalsHistory(code currency.Code) ([]WithdrawalHistory, 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
|
|
SupportsREST() bool
|
|
GetSubscriptions() ([]stream.ChannelSubscription, error)
|
|
GetDefaultConfig() (*config.ExchangeConfig, error)
|
|
GetBase() *Base
|
|
SupportsAsset(assetType asset.Item) bool
|
|
GetHistoricCandles(p currency.Pair, a asset.Item, timeStart, timeEnd time.Time, interval kline.Interval) (kline.Item, error)
|
|
GetHistoricCandlesExtended(p currency.Pair, a asset.Item, timeStart, timeEnd time.Time, interval kline.Interval) (kline.Item, error)
|
|
DisableRateLimiter() error
|
|
EnableRateLimiter() error
|
|
// Websocket specific wrapper functionality
|
|
// GetWebsocket returns a pointer to the websocket
|
|
GetWebsocket() (*stream.Websocket, error)
|
|
IsWebsocketEnabled() bool
|
|
SupportsWebsocket() bool
|
|
SubscribeToWebsocketChannels(channels []stream.ChannelSubscription) error
|
|
UnsubscribeToWebsocketChannels(channels []stream.ChannelSubscription) error
|
|
IsAssetWebsocketSupported(aType asset.Item) bool
|
|
// FlushWebsocketChannels checks and flushes subscriptions if there is a
|
|
// pair,asset, url/proxy or subscription change
|
|
FlushWebsocketChannels() error
|
|
AuthenticateWebsocket() error
|
|
// Exchange order related execution limits
|
|
GetOrderExecutionLimits(a asset.Item, cp currency.Pair) (*order.Limits, error)
|
|
CheckOrderExecutionLimits(a asset.Item, cp currency.Pair, price, amount float64, orderType order.Type) error
|
|
UpdateOrderExecutionLimits(a asset.Item) error
|
|
}
|