mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
binance: implement TransferFuturesAccountAsset api
This commit is contained in:
parent
6797069a40
commit
487fbf8681
|
@ -367,33 +367,38 @@ 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 {
|
||||
func (e *Exchange) TransferFuturesAccountAsset(ctx context.Context, asset string, amount fixedpoint.Value, io types.TransferDirection) error {
|
||||
req := e.client2.NewFuturesTransferRequest()
|
||||
req.Asset(asset)
|
||||
req.Amount(amount.String())
|
||||
|
||||
if io > 0 { // int
|
||||
if io == types.TransferIn {
|
||||
req.TransferType(binanceapi.FuturesTransferSpotToUsdtFutures)
|
||||
} else if io < 0 { // out
|
||||
} else if io == types.TransferOut {
|
||||
req.TransferType(binanceapi.FuturesTransferUsdtFuturesToSpot)
|
||||
} else {
|
||||
return fmt.Errorf("unexpected transfer direction: %d given", io)
|
||||
}
|
||||
|
||||
resp, err := req.Do(ctx)
|
||||
log.Debugf("futures transfer %s %s, transaction = %+v", amount.String(), asset, resp)
|
||||
log.Infof("futures transfer %s %s, transaction = %+v, err = %+v", amount.String(), asset, resp, err)
|
||||
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 {
|
||||
func (e *Exchange) transferCrossMarginAccountAsset(ctx context.Context, asset string, amount fixedpoint.Value, io types.TransferDirection) error {
|
||||
req := e.client.NewMarginTransferService()
|
||||
req.Asset(asset)
|
||||
req.Amount(amount.String())
|
||||
|
||||
if io > 0 { // in
|
||||
if io == types.TransferIn {
|
||||
req.Type(binance.MarginTransferTypeToMargin)
|
||||
} else if io < 0 { // out
|
||||
} else if io == types.TransferOut {
|
||||
req.Type(binance.MarginTransferTypeToMain)
|
||||
} else {
|
||||
return fmt.Errorf("unexpected transfer direction: %d given", io)
|
||||
}
|
||||
|
||||
resp, err := req.Do(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue
Block a user