mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-01 07:26:48 +00:00
Binance,Okx: Add Leverage, MarginType, Positions and CollateralMode support (#1220)
* init * surprise train commit * basic distinctions * the terms of binance are confusing * renames and introduction of allocatedMargin * add new margin funcs * pulling out wires * implement proper getposition stuff * bad coding day * investigate order manager next * a broken mess, but a progressing one * finally completes some usdtmargined stuff * coinMfutures eludes me * expand to okx * imports fix * completes okx wrapper implementations * cleans and polishes before rpc implementations * rpc setup, order manager features, exch features * more rpc, collateral and margin things * mini test * looking at rpc response, expansion of features * reorganising before the storm * changing how futures requests work * cleanup and tests of cli usage * remove silly client side logic * cleanup * collateral package, typo fix, margin err, rpc derive * uses convert.StringToFloat ONLY ON STRUCTS FROM THIS PR * fix binance order history bug * niteroos * adds new funcs to exchange standards testing * more post merge fixes * fix binance * replace simepletimeformat * fix for merge * merge fixes * micro fixes * order side now required for leverage * fix up the rest * global -> portfolio collateral * Update exchanges/collateral/collateral_test.go Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io> * adds fields and todos * rm field redundancy * lint fix oopsie daisy * fixes panic, expands error and cli explanations (sorry shaz) * ensures casing is appropriate for underlying * Adds a shiny TODO --------- Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/account"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/collateral"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/deposit"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/fundingrate"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/kline"
|
||||
@@ -920,7 +921,7 @@ func testWrappers(e exchange.IBotExchange, base *exchange.Base, config *Config)
|
||||
Pair: p,
|
||||
}
|
||||
var positionSummaryResponse *order.PositionSummary
|
||||
positionSummaryResponse, err = e.GetPositionSummary(context.TODO(), positionSummaryRequest)
|
||||
positionSummaryResponse, err = e.GetFuturesPositionSummary(context.TODO(), positionSummaryRequest)
|
||||
msg = ""
|
||||
if err != nil {
|
||||
msg = err.Error()
|
||||
@@ -928,7 +929,7 @@ func testWrappers(e exchange.IBotExchange, base *exchange.Base, config *Config)
|
||||
}
|
||||
responseContainer.EndpointResponses = append(responseContainer.EndpointResponses, EndpointResponse{
|
||||
SentParams: jsonifyInterface([]interface{}{positionSummaryRequest}),
|
||||
Function: "GetPositionSummary",
|
||||
Function: "GetFuturesPositionSummary",
|
||||
Error: msg,
|
||||
Response: jsonifyInterface([]interface{}{positionSummaryResponse}),
|
||||
})
|
||||
@@ -968,7 +969,7 @@ func testWrappers(e exchange.IBotExchange, base *exchange.Base, config *Config)
|
||||
LockedCollateral: decimal.NewFromInt(1337),
|
||||
UnrealisedPNL: decimal.NewFromInt(1337),
|
||||
}
|
||||
var scaleCollateralResponse *order.CollateralByCurrency
|
||||
var scaleCollateralResponse *collateral.ByCurrency
|
||||
scaleCollateralResponse, err = e.ScaleCollateral(context.TODO(), collateralCalculator)
|
||||
msg = ""
|
||||
if err != nil {
|
||||
@@ -999,13 +1000,13 @@ func testWrappers(e exchange.IBotExchange, base *exchange.Base, config *Config)
|
||||
Response: jsonifyInterface([]interface{}{calculateTotalCollateralResponse}),
|
||||
})
|
||||
|
||||
var futuresPositionsResponse []order.PositionDetails
|
||||
var futuresPositionsResponse []order.PositionResponse
|
||||
futuresPositionsRequest := &order.PositionsRequest{
|
||||
Asset: assetTypes[i],
|
||||
Pairs: currency.Pairs{p},
|
||||
StartDate: time.Now().Add(-time.Hour),
|
||||
}
|
||||
futuresPositionsResponse, err = e.GetFuturesPositions(context.TODO(), futuresPositionsRequest)
|
||||
futuresPositionsResponse, err = e.GetFuturesPositionOrders(context.TODO(), futuresPositionsRequest)
|
||||
msg = ""
|
||||
if err != nil {
|
||||
msg = err.Error()
|
||||
@@ -1013,7 +1014,7 @@ func testWrappers(e exchange.IBotExchange, base *exchange.Base, config *Config)
|
||||
}
|
||||
responseContainer.EndpointResponses = append(responseContainer.EndpointResponses, EndpointResponse{
|
||||
SentParams: jsonifyInterface([]interface{}{futuresPositionsRequest}),
|
||||
Function: "GetFuturesPositions",
|
||||
Function: "GetFuturesPositionOrders",
|
||||
Error: msg,
|
||||
Response: jsonifyInterface([]interface{}{futuresPositionsResponse}),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user