mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-14 07:26:47 +00:00
exchanges: Initial context propagation (#744)
* gct: phase one context awareness pass * exchanges: context propagation pass * common/requester: force context requirement * gctcli/exchanges: linter fix * rpcserver: fix test using dummy rpc server * backtester: fix comments * grpc: add correct cancel and timeout for commands * rpcserver_test: add comment on dummy server * common: deprecated SendHTTPGetRequest * linter: fix * linter: turn on no context check * apichecker: fix context linter issue * binance: use param context * common: remove checks as this gets executed before main * common: change mutex to RW as clients can be used by multiple go routines. * common: remove init and JIT default client. Unexport global variables and add protection. * common: Add comments * bithumb: after dinner mints fix
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package gct
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
@@ -63,7 +64,8 @@ func ExchangeOrderbook(args ...objects.Object) (objects.Object, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ob, err := wrappers.GetWrapper().Orderbook(exchangeName, pair, assetType)
|
||||
ob, err := wrappers.GetWrapper().
|
||||
Orderbook(context.TODO(), exchangeName, pair, assetType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -129,7 +131,8 @@ func ExchangeTicker(args ...objects.Object) (objects.Object, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tx, err := wrappers.GetWrapper().Ticker(exchangeName, pair, assetType)
|
||||
tx, err := wrappers.GetWrapper().
|
||||
Ticker(context.TODO(), exchangeName, pair, assetType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -229,7 +232,8 @@ func ExchangeAccountInfo(args ...objects.Object) (objects.Object, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rtnValue, err := wrappers.GetWrapper().AccountInformation(exchangeName, assetType)
|
||||
rtnValue, err := wrappers.GetWrapper().
|
||||
AccountInformation(context.TODO(), exchangeName, assetType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -297,7 +301,8 @@ func ExchangeOrderQuery(args ...objects.Object) (objects.Object, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
orderDetails, err := wrappers.GetWrapper().QueryOrder(exchangeName, orderID, pair, assetType)
|
||||
orderDetails, err := wrappers.GetWrapper().
|
||||
QueryOrder(context.TODO(), exchangeName, orderID, pair, assetType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -384,7 +389,8 @@ func ExchangeOrderCancel(args ...objects.Object) (objects.Object, error) {
|
||||
}
|
||||
|
||||
var isCancelled bool
|
||||
isCancelled, err = wrappers.GetWrapper().CancelOrder(exchangeName, orderID, cp, a)
|
||||
isCancelled, err = wrappers.GetWrapper().
|
||||
CancelOrder(context.TODO(), exchangeName, orderID, cp, a)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -457,7 +463,7 @@ func ExchangeOrderSubmit(args ...objects.Object) (objects.Object, error) {
|
||||
Exchange: exchangeName,
|
||||
}
|
||||
|
||||
rtn, err := wrappers.GetWrapper().SubmitOrder(tempSubmit)
|
||||
rtn, err := wrappers.GetWrapper().SubmitOrder(context.TODO(), tempSubmit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -547,7 +553,8 @@ func ExchangeWithdrawCrypto(args ...objects.Object) (objects.Object, error) {
|
||||
Amount: amount,
|
||||
}
|
||||
|
||||
rtn, err := wrappers.GetWrapper().WithdrawalCryptoFunds(withdrawRequest)
|
||||
rtn, err := wrappers.GetWrapper().
|
||||
WithdrawalCryptoFunds(context.TODO(), withdrawRequest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -589,7 +596,8 @@ func ExchangeWithdrawFiat(args ...objects.Object) (objects.Object, error) {
|
||||
Amount: amount,
|
||||
}
|
||||
|
||||
rtn, err := wrappers.GetWrapper().WithdrawalFiatFunds(bankAccountID, withdrawRequest)
|
||||
rtn, err := wrappers.GetWrapper().
|
||||
WithdrawalFiatFunds(context.TODO(), bankAccountID, withdrawRequest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -656,7 +664,14 @@ func exchangeOHLCV(args ...objects.Object) (objects.Object, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ret, err := wrappers.GetWrapper().OHLCV(exchangeName, pair, assetType, startTime, endTime, kline.Interval(interval))
|
||||
ret, err := wrappers.GetWrapper().
|
||||
OHLCV(context.TODO(),
|
||||
exchangeName,
|
||||
pair,
|
||||
assetType,
|
||||
startTime,
|
||||
endTime,
|
||||
kline.Interval(interval))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package modules
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/thrasher-corp/gocryptotrader/currency"
|
||||
@@ -32,17 +33,17 @@ type GCT interface {
|
||||
type Exchange interface {
|
||||
Exchanges(enabledOnly bool) []string
|
||||
IsEnabled(exch string) bool
|
||||
Orderbook(exch string, pair currency.Pair, item asset.Item) (*orderbook.Base, error)
|
||||
Ticker(exch string, pair currency.Pair, item asset.Item) (*ticker.Price, error)
|
||||
Orderbook(ctx context.Context, exch string, pair currency.Pair, item asset.Item) (*orderbook.Base, error)
|
||||
Ticker(ctx context.Context, exch string, pair currency.Pair, item asset.Item) (*ticker.Price, error)
|
||||
Pairs(exch string, enabledOnly bool, item asset.Item) (*currency.Pairs, error)
|
||||
QueryOrder(exch, orderid string, pair currency.Pair, assetType asset.Item) (*order.Detail, error)
|
||||
SubmitOrder(submit *order.Submit) (*order.SubmitResponse, error)
|
||||
CancelOrder(exch, orderid string, pair currency.Pair, item asset.Item) (bool, error)
|
||||
AccountInformation(exch string, assetType asset.Item) (account.Holdings, error)
|
||||
QueryOrder(ctx context.Context, exch, orderid string, pair currency.Pair, assetType asset.Item) (*order.Detail, error)
|
||||
SubmitOrder(ctx context.Context, submit *order.Submit) (*order.SubmitResponse, error)
|
||||
CancelOrder(ctx context.Context, exch, orderid string, pair currency.Pair, item asset.Item) (bool, error)
|
||||
AccountInformation(ctx context.Context, exch string, assetType asset.Item) (account.Holdings, error)
|
||||
DepositAddress(exch string, currencyCode currency.Code) (string, error)
|
||||
WithdrawalFiatFunds(bankAccountID string, request *withdraw.Request) (out string, err error)
|
||||
WithdrawalCryptoFunds(request *withdraw.Request) (out string, err error)
|
||||
OHLCV(exch string, pair currency.Pair, item asset.Item, start, end time.Time, interval kline.Interval) (kline.Item, error)
|
||||
WithdrawalFiatFunds(ctx context.Context, bankAccountID string, request *withdraw.Request) (out string, err error)
|
||||
WithdrawalCryptoFunds(ctx context.Context, request *withdraw.Request) (out string, err error)
|
||||
OHLCV(ctx context.Context, exch string, pair currency.Pair, item asset.Item, start, end time.Time, interval kline.Interval) (kline.Item, error)
|
||||
}
|
||||
|
||||
// SetModuleWrapper link the wrapper and interface to use for modules
|
||||
|
||||
Reference in New Issue
Block a user