mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
max: force type check on max.Exchange
This commit is contained in:
parent
afc864dfc4
commit
f223703247
|
@ -22,6 +22,10 @@ import (
|
|||
|
||||
var log = logrus.WithField("exchange", "max")
|
||||
|
||||
func init() {
|
||||
_ = types.ExchangeTradeHistoryService(&Exchange{})
|
||||
}
|
||||
|
||||
type Exchange struct {
|
||||
types.MarginSettings
|
||||
|
||||
|
@ -266,12 +270,16 @@ func (e *Exchange) QueryOpenOrders(ctx context.Context, symbol string) (orders [
|
|||
}
|
||||
|
||||
// lastOrderID is not supported on MAX
|
||||
func (e *Exchange) QueryClosedOrders(ctx context.Context, symbol string, since, until time.Time, lastOrderID uint64) ([]types.Order, error) {
|
||||
func (e *Exchange) QueryClosedOrders(
|
||||
ctx context.Context, symbol string, since, until time.Time, lastOrderID uint64,
|
||||
) ([]types.Order, error) {
|
||||
log.Warn("!!!MAX EXCHANGE API NOTICE!!! the since/until conditions will not be effected on closed orders query, max exchange does not support time-range-based query")
|
||||
return e.queryClosedOrdersByLastOrderID(ctx, symbol, lastOrderID)
|
||||
}
|
||||
|
||||
func (e *Exchange) queryClosedOrdersByLastOrderID(ctx context.Context, symbol string, lastOrderID uint64) (orders []types.Order, err error) {
|
||||
func (e *Exchange) queryClosedOrdersByLastOrderID(
|
||||
ctx context.Context, symbol string, lastOrderID uint64,
|
||||
) (orders []types.Order, err error) {
|
||||
if err := e.closedOrderQueryLimiter.Wait(ctx); err != nil {
|
||||
return orders, err
|
||||
}
|
||||
|
@ -429,7 +437,9 @@ func (e *Exchange) CancelOrders(ctx context.Context, orders ...types.Order) (err
|
|||
return err2
|
||||
}
|
||||
|
||||
func (e *Exchange) Withdraw(ctx context.Context, asset string, amount fixedpoint.Value, address string, options *types.WithdrawalOptions) error {
|
||||
func (e *Exchange) Withdraw(
|
||||
ctx context.Context, asset string, amount fixedpoint.Value, address string, options *types.WithdrawalOptions,
|
||||
) error {
|
||||
asset = toLocalCurrency(asset)
|
||||
|
||||
addresses, err := e.client.WithdrawalService.NewGetWithdrawalAddressesRequest().
|
||||
|
@ -673,7 +683,9 @@ func (e *Exchange) queryBalances(ctx context.Context, walletType maxapi.WalletTy
|
|||
return balances, nil
|
||||
}
|
||||
|
||||
func (e *Exchange) QueryWithdrawHistory(ctx context.Context, asset string, since, until time.Time) (allWithdraws []types.Withdraw, err error) {
|
||||
func (e *Exchange) QueryWithdrawHistory(
|
||||
ctx context.Context, asset string, since, until time.Time,
|
||||
) (allWithdraws []types.Withdraw, err error) {
|
||||
startTime := since
|
||||
limit := 1000
|
||||
txIDs := map[string]struct{}{}
|
||||
|
@ -769,7 +781,9 @@ func (e *Exchange) QueryWithdrawHistory(ctx context.Context, asset string, since
|
|||
return allWithdraws, nil
|
||||
}
|
||||
|
||||
func (e *Exchange) QueryDepositHistory(ctx context.Context, asset string, since, until time.Time) (allDeposits []types.Deposit, err error) {
|
||||
func (e *Exchange) QueryDepositHistory(
|
||||
ctx context.Context, asset string, since, until time.Time,
|
||||
) (allDeposits []types.Deposit, err error) {
|
||||
startTime := since
|
||||
limit := 1000
|
||||
txIDs := map[string]struct{}{}
|
||||
|
@ -846,7 +860,9 @@ func (e *Exchange) QueryDepositHistory(ctx context.Context, asset string, since,
|
|||
// For this QueryTrades spec (to be compatible with batch.TradeBatchQuery)
|
||||
// give LastTradeID -> ignore start_time (but still can filter the end_time)
|
||||
// without any parameters -> return trades within 24 hours
|
||||
func (e *Exchange) QueryTrades(ctx context.Context, symbol string, options *types.TradeQueryOptions) (trades []types.Trade, err error) {
|
||||
func (e *Exchange) QueryTrades(
|
||||
ctx context.Context, symbol string, options *types.TradeQueryOptions,
|
||||
) (trades []types.Trade, err error) {
|
||||
if err := e.queryTradeLimiter.Wait(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -964,7 +980,9 @@ func (e *Exchange) QueryRewards(ctx context.Context, startTime time.Time) ([]typ
|
|||
// https://max-api.maicoin.com/api/v2/k?market=btctwd&limit=10&period=1×tamp=1620202440
|
||||
// The above query will return a kline that starts with 1620202440 (unix timestamp) without endTime.
|
||||
// We need to calculate the endTime by ourself.
|
||||
func (e *Exchange) QueryKLines(ctx context.Context, symbol string, interval types.Interval, options types.KLineQueryOptions) ([]types.KLine, error) {
|
||||
func (e *Exchange) QueryKLines(
|
||||
ctx context.Context, symbol string, interval types.Interval, options types.KLineQueryOptions,
|
||||
) ([]types.KLine, error) {
|
||||
if err := e.marketDataLimiter.Wait(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -1041,7 +1059,9 @@ func (e *Exchange) BorrowMarginAsset(ctx context.Context, asset string, amount f
|
|||
return nil
|
||||
}
|
||||
|
||||
func (e *Exchange) QueryMarginAssetMaxBorrowable(ctx context.Context, asset string) (amount fixedpoint.Value, err error) {
|
||||
func (e *Exchange) QueryMarginAssetMaxBorrowable(
|
||||
ctx context.Context, asset string,
|
||||
) (amount fixedpoint.Value, err error) {
|
||||
req := e.v3client.NewGetMarginBorrowingLimitsRequest()
|
||||
resp, err := req.Do(ctx)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue
Block a user