Skip to content

Commit ed525ea

Browse files
committed
[futures] lever field type from int change to float64
1 parent b5e104e commit ed525ea

File tree

7 files changed

+19
-19
lines changed

7 files changed

+19
-19
lines changed

FutureRestAPI.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type FutureRestAPI interface {
4949
* @param openType 1:开多 2:开空 3:平多 4:平空
5050
* @param matchPrice 是否为对手价 0:不是 1:是 ,当取值为1时,price无效
5151
*/
52-
PlaceFutureOrder(currencyPair CurrencyPair, contractType, price, amount string, openType, matchPrice, leverRate int) (string, error)
52+
PlaceFutureOrder(currencyPair CurrencyPair, contractType, price, amount string, openType, matchPrice int, leverRate float64) (string, error)
5353

5454
LimitFuturesOrder(currencyPair CurrencyPair, contractType, price, amount string, openType int, opt ...LimitOrderOptionalParameter) (*FutureOrder, error)
5555

Models.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ type APIConfig struct {
119119
ApiPassphrase string //for okex.com v3 api
120120
ClientId string //for bitstamp.net , huobi.pro
121121

122-
Lever int //杠杆倍数 , for future
122+
Lever float64 //杠杆倍数 , for future
123123
}
124124

125125
type Kline struct {
@@ -163,7 +163,7 @@ type FutureOrder struct {
163163
Currency CurrencyPair
164164
OrderType int //ORDINARY=0 POST_ONLY=1 FOK= 2 IOC= 3
165165
OType int //1:开多 2:开空 3:平多 4: 平空
166-
LeverRate int //倍数
166+
LeverRate float64 //倍数
167167
Fee float64 //手续费
168168
ContractName string
169169
FinishedTime int64 // finished timestamp
@@ -180,7 +180,7 @@ type FuturePosition struct {
180180
BuyPriceCost float64
181181
BuyProfitReal float64
182182
CreateDate int64
183-
LeverRate int
183+
LeverRate float64
184184
SellAmount float64
185185
SellAvailable float64
186186
SellPriceAvg float64
@@ -228,7 +228,6 @@ type RepaymentParameter struct {
228228
BorrowId string
229229
}
230230

231-
232231
type TransferParameter struct {
233232
Currency string `json:"currency"`
234233
From int `json:"from"`
@@ -248,7 +247,6 @@ type WithdrawParameter struct {
248247
Fee string `json:"fee"`
249248
}
250249

251-
252250
type DepositWithdrawHistory struct {
253251
WithdrawalId string `json:"withdrawal_id,omitempty"`
254252
Currency string `json:"currency"`

binance/BinanceSwap.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ func (bs *BinanceSwap) Transfer(currency Currency, transferType int, amount floa
289289
return ToInt64(respmap["tranId"]), nil
290290
}
291291

292-
func (bs *BinanceSwap) PlaceFutureOrder(currencyPair CurrencyPair, contractType, price, amount string, openType, matchPrice, leverRate int) (string, error) {
292+
func (bs *BinanceSwap) PlaceFutureOrder(currencyPair CurrencyPair, contractType, price, amount string, openType, matchPrice int, leverRate float64) (string, error) {
293293
fOrder, err := bs.PlaceFutureOrder2(currencyPair, contractType, price, amount, openType, matchPrice, leverRate)
294294
return fOrder.OrderID2, err
295295
}
@@ -304,7 +304,7 @@ func (bs *BinanceSwap) PlaceFutureOrder(currencyPair CurrencyPair, contractType,
304304
* @param openType 1:开多 2:开空 3:平多 4:平空
305305
* @param matchPrice 是否为对手价 0:不是 1:是 ,当取值为1时,price无效
306306
*/
307-
func (bs *BinanceSwap) PlaceFutureOrder2(currencyPair CurrencyPair, contractType, price, amount string, openType, matchPrice, leverRate int) (*FutureOrder, error) {
307+
func (bs *BinanceSwap) PlaceFutureOrder2(currencyPair CurrencyPair, contractType, price, amount string, openType, matchPrice int, leverRate float64) (*FutureOrder, error) {
308308
fOrder := &FutureOrder{
309309
Currency: currencyPair,
310310
ClientOid: GenerateOrderClientId(32),
@@ -490,7 +490,7 @@ func (bs *BinanceSwap) GetFuturePosition(currencyPair CurrencyPair, contractType
490490
continue
491491
}
492492
p := FuturePosition{
493-
LeverRate: ToInt(cont["leverage"]),
493+
LeverRate: ToFloat64(cont["leverage"]),
494494
Symbol: currencyPair,
495495
ForceLiquPrice: ToFloat64(cont["liquidationPrice"]),
496496
}

coinbene/CoinbeneSwap.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type baseResp struct {
2121
type CoinbeneOrder struct {
2222
OrderId string `json:"orderId"`
2323
Direction string `json:"direction"`
24-
Leverage int `json:"leverage,string"`
24+
Leverage float64 `json:"leverage,string"`
2525
Symbol string `json:"symbol"`
2626
OrderType string `json:"orderType"`
2727
Quantity float64 `json:"quantity,string"`
@@ -163,7 +163,7 @@ func (swap *CoinbeneSwap) GetFutureUserinfo(currencyPair ...CurrencyPair) (*Futu
163163
return acc, nil
164164
}
165165

166-
func (swap *CoinbeneSwap) PlaceFutureOrder(currencyPair CurrencyPair, contractType, price, amount string, openType, matchPrice, leverRate int) (string, error) {
166+
func (swap *CoinbeneSwap) PlaceFutureOrder(currencyPair CurrencyPair, contractType, price, amount string, openType, matchPrice int, leverRate float64) (string, error) {
167167
var param struct {
168168
Symbol string `json:"symbol"`
169169
Leverage string `json:"leverage"`
@@ -229,7 +229,7 @@ func (swap *CoinbeneSwap) GetFuturePosition(currencyPair CurrencyPair, contractT
229229
AvailableQuantity float64 `json:"availableQuantity,string"`
230230
AveragePrice float64 `json:"averagePrice,string"`
231231
CreateTime time.Time `json:"createTime"`
232-
Leverage int `json:"leverage,string"`
232+
Leverage float64 `json:"leverage,string"`
233233
LiquidationPrice float64 `json:"liquidationPrice,string"`
234234
RealisedPnl float64 `json:"realisedPnl,string"`
235235
UnrealisedPnl float64 `json:"unrealisedPnl,string"`

huobi/Hbdm.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type OrderInfo struct {
2727
OrderPriceType string `json:"order_price_type"`
2828
Direction string `json:"direction"`
2929
Offset string `json:"offset"`
30-
LeverRate int `json:"lever_rate"`
30+
LeverRate float64 `json:"lever_rate"`
3131
OrderId int64 `json:"order_id"`
3232
ClientOrderId int64 `json:"client_order_id"`
3333
OrderSource string `json:"order_source"`
@@ -184,7 +184,7 @@ func (dm *Hbdm) GetFuturePosition(currencyPair CurrencyPair, contractType string
184184
ProfitRate float64 `json:"profit_rate"`
185185
Profit float64 `json:"profit"`
186186
PositionMargin float64 `json:"position_margin"`
187-
LeverRate int `json:"lever_rate"`
187+
LeverRate float64 `json:"lever_rate"`
188188
Direction string `json:"direction"`
189189
}
190190

@@ -234,12 +234,12 @@ func (dm *Hbdm) GetFuturePosition(currencyPair CurrencyPair, contractType string
234234
return positions, nil
235235
}
236236

237-
func (dm *Hbdm) PlaceFutureOrder(currencyPair CurrencyPair, contractType, price, amount string, openType, matchPrice, leverRate int) (string, error) {
237+
func (dm *Hbdm) PlaceFutureOrder(currencyPair CurrencyPair, contractType, price, amount string, openType, matchPrice int, leverRate float64) (string, error) {
238238
fOrder, err := dm.PlaceFutureOrder2(currencyPair, contractType, price, amount, openType, matchPrice, leverRate)
239239
return fOrder.OrderID2, err
240240
}
241241

242-
func (dm *Hbdm) PlaceFutureOrder2(currencyPair CurrencyPair, contractType, price, amount string, openType, matchPrice, leverRate int, opt ...LimitOrderOptionalParameter) (*FutureOrder, error) {
242+
func (dm *Hbdm) PlaceFutureOrder2(currencyPair CurrencyPair, contractType, price, amount string, openType, matchPrice int, leverRate float64, opt ...LimitOrderOptionalParameter) (*FutureOrder, error) {
243243
var data struct {
244244
OrderId int64 `json:"order_id"`
245245
COrderId int64 `json:"client_order_id"`

okex/OKExFuture.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ func (ok *OKExFuture) PlaceFutureOrder2(matchPrice int, ord *FutureOrder) (*Futu
399399
return ord, nil
400400
}
401401

402-
func (ok *OKExFuture) PlaceFutureOrder(currencyPair CurrencyPair, contractType, price, amount string, openType, matchPrice, leverRate int) (string, error) {
402+
func (ok *OKExFuture) PlaceFutureOrder(currencyPair CurrencyPair, contractType, price, amount string, openType, matchPrice int, leverRate float64) (string, error) {
403403
fOrder, err := ok.PlaceFutureOrder2(matchPrice, &FutureOrder{
404404
Price: ToFloat64(price),
405405
Amount: ToFloat64(amount),
@@ -473,7 +473,7 @@ func (ok *OKExFuture) GetFuturePosition(currencyPair CurrencyPair, contractType
473473
LongPnlRatio float64 `json:"long_pnl_ratio,string"`
474474
LongUnrealisedPnl float64 `json:"long_unrealised_pnl,string"`
475475
RealisedPnl float64 `json:"realised_pnl,string"`
476-
Leverage int `json:"leverage,string"`
476+
Leverage float64 `json:"leverage,string"`
477477
ShortQty float64 `json:"short_qty,string"`
478478
ShortAvailQty float64 `json:"short_avail_qty,string"`
479479
ShortAvgCost float64 `json:"short_avg_cost,string"`

okex/OKExSwap.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ type PlaceOrdersInfo struct {
281281
OrderData []*BasePlaceOrderInfo `json:"order_data"`
282282
}
283283

284-
func (ok *OKExSwap) PlaceFutureOrder(currencyPair CurrencyPair, contractType, price, amount string, openType, matchPrice, leverRate int) (string, error) {
284+
func (ok *OKExSwap) PlaceFutureOrder(currencyPair CurrencyPair, contractType, price, amount string, openType, matchPrice int, leverRate float64) (string, error) {
285285
fOrder, err := ok.PlaceFutureOrder2(currencyPair, contractType, price, amount, openType, matchPrice)
286286
return fOrder.OrderID2, err
287287
}
@@ -511,6 +511,8 @@ func (ok *OKExSwap) GetFuturePosition(currencyPair CurrencyPair, contractType st
511511
positions[0].SellPriceAvg = sellPosition.AvgCost
512512
positions[0].SellProfitReal = sellPosition.RealizedPnl
513513
positions[0].SellPriceCost = sellPosition.SettlementPrice
514+
515+
positions[0].LeverRate = ToFloat64(sellPosition.Leverage)
514516
}
515517
return positions, nil
516518
}

0 commit comments

Comments
 (0)