From 6848e11e8a5002a814deb4b0ca01c6eff6df76b0 Mon Sep 17 00:00:00 2001 From: c9s Date: Thu, 23 Mar 2023 00:55:00 +0800 Subject: [PATCH] binance: implement TransferFuturesAsset --- pkg/exchange/binance/exchange.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkg/exchange/binance/exchange.go b/pkg/exchange/binance/exchange.go index aea4e1459..16dbfd39e 100644 --- a/pkg/exchange/binance/exchange.go +++ b/pkg/exchange/binance/exchange.go @@ -367,6 +367,22 @@ func (e *Exchange) QueryMarginBorrowHistory(ctx context.Context, asset string) e return nil } +func (e *Exchange) TransferFuturesAsset(ctx context.Context, asset string, amount fixedpoint.Value, io int) error { + req := e.client2.NewFuturesTransferRequest() + req.Asset(asset) + req.Amount(amount.String()) + + if io > 0 { // int + req.TransferType(binanceapi.FuturesTransferSpotToUsdtFutures) + } else if io < 0 { // out + req.TransferType(binanceapi.FuturesTransferUsdtFuturesToSpot) + } + + resp, err := req.Do(ctx) + log.Debugf("futures transfer %s %s, transaction = %+v", amount.String(), asset, resp) + return err +} + // transferCrossMarginAccountAsset transfer asset to the cross margin account or to the main account func (e *Exchange) transferCrossMarginAccountAsset(ctx context.Context, asset string, amount fixedpoint.Value, io int) error { req := e.client.NewMarginTransferService()