Skip to content

Commit 0f5df58

Browse files
committed
extend Position with extra params from BInance Futures
1 parent 5e051b5 commit 0f5df58

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

exchanges/binancefutures/binancefutures.go

+9
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,16 @@ func (b *BinanceFutures) GetPositions(symbol string) (result []*Position, err er
326326
position.Size = size
327327
position.OpenPrice = utils.ParseFloat64(v.EntryPrice)
328328
position.AvgPrice = position.OpenPrice
329+
position.Profit = utils.ParseFloat64(v.UnRealizedProfit)
329330
}
331+
position.MarginType = v.MarginType
332+
position.IsAutoAddMargin = utils.ParseBool(v.IsAutoAddMargin)
333+
position.IsolatedMargin = utils.ParseFloat64(v.IsolatedMargin)
334+
position.Leverage = utils.ParseFloat64(v.Leverage)
335+
position.LiquidationPrice = utils.ParseFloat64(v.LiquidationPrice)
336+
position.MarkPrice = utils.ParseFloat64(v.MarkPrice)
337+
position.MaxNotionalValue = utils.ParseFloat64(v.MaxNotionalValue)
338+
position.PositionSide = v.PositionSide
330339
result = append(result, position)
331340
}
332341
return

models.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package crex
22

33
import (
4-
"github.com/rocketlaunchr/dataframe-go"
54
"time"
5+
6+
"github.com/rocketlaunchr/dataframe-go"
67
)
78

89
type Balance struct {
@@ -224,6 +225,15 @@ type Position struct {
224225
Size float64 `json:"size"` // 仓位大小
225226
AvgPrice float64 `json:"avg_price"` // 平均价
226227
Profit float64 `json:"profit"` //浮动盈亏
228+
229+
MarginType string `json:"marginType"`
230+
IsAutoAddMargin bool `json:"isAutoAddMargin"`
231+
IsolatedMargin float64 `json:"isolatedMargin"`
232+
Leverage float64 `json:"leverage"`
233+
LiquidationPrice float64 `json:"liquidationPrice"`
234+
MarkPrice float64 `json:"markPrice"`
235+
MaxNotionalValue float64 `json:"maxNotionalValue"`
236+
PositionSide string `json:"positionSide"`
227237
}
228238

229239
func (p *Position) Side() Direction {

utils/str.go

+5
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ func ParseInt(s string) int {
1111
i, _ := strconv.ParseInt(s, 10, 64)
1212
return int(i)
1313
}
14+
15+
func ParseBool(s string) bool {
16+
b, _ := strconv.ParseBool(s)
17+
return b
18+
}

0 commit comments

Comments
 (0)