mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
add margin borrow endpoint
This commit is contained in:
parent
a8fdd8006c
commit
c2d1ef0fc8
4
go.mod
4
go.mod
|
@ -6,7 +6,7 @@ go 1.17
|
|||
|
||||
require (
|
||||
github.com/DATA-DOG/go-sqlmock v1.5.0
|
||||
github.com/adshao/go-binance/v2 v2.3.3
|
||||
github.com/adshao/go-binance/v2 v2.3.5
|
||||
github.com/c9s/requestgen v1.1.1-0.20211230171502-c042072e23cd
|
||||
github.com/c9s/rockhopper v1.2.1-0.20210217093258-2661955904a9
|
||||
github.com/codingconcepts/env v0.0.0-20200821220118-a8fbf8d84482
|
||||
|
@ -16,7 +16,7 @@ require (
|
|||
github.com/go-redis/redis/v8 v8.8.0
|
||||
github.com/go-sql-driver/mysql v1.5.0
|
||||
github.com/google/uuid v1.3.0
|
||||
github.com/gorilla/websocket v1.4.2
|
||||
github.com/gorilla/websocket v1.5.0
|
||||
github.com/jmoiron/sqlx v1.3.4
|
||||
github.com/joho/godotenv v1.3.0
|
||||
github.com/leekchan/accounting v0.0.0-20191218023648-17a4ce5f94d4
|
||||
|
|
4
go.sum
4
go.sum
|
@ -39,6 +39,8 @@ github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q
|
|||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||
github.com/adshao/go-binance/v2 v2.3.3 h1:ts46Mq4n4Ji9pkbXhcuOZ2T2Zy1x3i5SboC6EKKqzyg=
|
||||
github.com/adshao/go-binance/v2 v2.3.3/go.mod h1:TfcBwfGtmRibSljDDR0XCaPkfBt1kc2N9lnNMYC3dCQ=
|
||||
github.com/adshao/go-binance/v2 v2.3.5 h1:WVYZecm0w8l14YoWlnKZj6xxZT2AKMTHpMQSqIX1xxA=
|
||||
github.com/adshao/go-binance/v2 v2.3.5/go.mod h1:8Pg/FGTLyAhq8QXA0IkoReKyRpoxJcK3LVujKDAZV/c=
|
||||
github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
|
@ -229,6 +231,8 @@ github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORR
|
|||
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
||||
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
||||
|
|
|
@ -227,8 +227,25 @@ func (e *Exchange) NewStream() types.Stream {
|
|||
return stream
|
||||
}
|
||||
|
||||
// transferCrossMarginAccount transfer asset to the cross margin account or to the main account
|
||||
func (e *Exchange) transferCrossMarginAccount(ctx context.Context, asset string, amount fixedpoint.Value, io int) error {
|
||||
func (e *Exchange) repayCrossMarginAccountAsset(ctx context.Context, asset string, amount fixedpoint.Value) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *Exchange) borrowMarginAccountAsset(ctx context.Context, asset string, amount fixedpoint.Value) error {
|
||||
req := e.Client.NewMarginLoanService()
|
||||
req.Asset(asset)
|
||||
req.Amount(amount.String())
|
||||
if e.IsIsolatedMargin {
|
||||
req.IsolatedSymbol(e.IsolatedMarginSymbol)
|
||||
}
|
||||
|
||||
resp, err := req.Do(ctx)
|
||||
log.Debugf("margin borrowed %f %s, transaction id = %d", amount.Float64(), asset, resp.TranID)
|
||||
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()
|
||||
req.Asset(asset)
|
||||
req.Amount(amount.String())
|
||||
|
@ -240,7 +257,7 @@ func (e *Exchange) transferCrossMarginAccount(ctx context.Context, asset string,
|
|||
}
|
||||
resp, err := req.Do(ctx)
|
||||
|
||||
log.Debugf("cross margin transfer, transaction id = %d", resp.TranID)
|
||||
log.Debugf("cross margin transfer %f %s, transaction id = %d", amount.Float64(), asset, resp.TranID)
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user