mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
* gctcli: modifyorder stubs * gctcli: add ModifyOrderRequest and ModifyOrderResponse in rpc.proto * gctcli: regenerate rpc.pb.go after the addition of ModifyOrder structs * gctrpc: add ModifyOrder() and regenerate dependent files * gctcli: modifyorder command now uses newly generated ModifyOrder() RPC * exchanges/order/orders.go: use time.Time.Equal() instead of == * gctrpc: update ModifyOrderRequest and ModifyResponse and regenerate gRPC * gctcli/commands: rework modifyorder * engine: implement RPCServer.ModifyOrder * engine: commit an initial version OrderManager.Modify(), still does not update state of managed orders * engine: OrderManager.Modify now updates the inner state of managed orders, but introduces race conditions, needs fixes * engine/order_manager.go: comply with golangci-lint * gctcli: fix getOrderCommand.ArgsUsage * gctcli: fix getModifyOrderCommand args and ArgsUsage * engine: OrderManager.Modify() now correctly updates price of modified order * engine: RPCServer.ModifyOrder now uses checkParams() as advised * exchanges: (1) IBotExchange.ModifyOrder now returns a Modify struct, (2) all exchanges are updated to comply with that change * exchanges/order: Detail.UpdateOrderFromModify also updates the ID * engine/order_manager: add store.modifyExisting() and use it in OrderManager.Modify to update (on success) the state of the modified order * exchanges: Bitfinex.ModifyOrder() now returns the ID in case of an error * engine: OrdetManager.Modify() now emits an order event * exchanges/bithumb: proper order.payment_currency key * engine/order_manager: populate more Modify fields as they are needed by (some) exchanges, add comments * engine: test OrderManager.Modify() * engine: test store.modifyExisting() * engine: write a docstring for store.modifyExisting * engine: OrderManager.Modify() now also sets Modify.Price and Modify.Amount in case of zero values * engine: TestOrderManager_Modify() now verify the effects of price and/or amount set to 0 * engine: OrderManger.Modify() now uses the commsManager to let observers know of errors * engine: TestOrderManager_Modify() uses t.Fatal() * engine: TestOrderManager_Modify() and TestStore_modifyOrder() supply t.Error() with proper messages * exchanges/order_manager_test: fix a golangci-lint complaint * engine/order_manager: fix an error comparison bug and simplify * gctcli/commands: check if either price or amount is set, otherwise we would waste an API call
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) (order.Modify, 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
|
|
}
|