Puzzled by setting order Size on futures
See original GitHub issueHi there - got a small issue which could be down to my understanding of how to work with the various parameters required for creating a Futures order. On reading the documents, it would appear that i must first query the Contract in order to get the metadata related to min/max leverage allowed, plus data related to the Multiplier used. on querying this data, i receive a payload that has all of this metadata :
// symbol = “UNIUSDTM”
var contract = await _clientFutures.FuturesApi.ExchangeData.GetContractAsync(symbol);
all good. However, I’m not entirely sure which data elements I should use as I’ve been getting varied results when applying the Multiplier found in the contract data. Below is my crude attempt to calculate the resulting size required for a fixed currency amount:
// dollarFunds =100m
// bidPrice = 95.6
quantity = (dollarFunds / bidPrice / (contract.Data.Multiplier * leverageRate));
I also tried the simpler version of the below which worked in some cases, but like the other version, not all:
quantity = (dollarFunds / bidPrice * leverageRate);
I then use it as thus:
var orderBuy = await _clientFutures.FuturesApi.Trading.PlaceOrderAsync(
symbol,
orderSideAdd,
Kucoin.Net.Enums.NewOrderType.Limit, leverageRate, quantity, bidPrice,
Kucoin.Net.Enums.TimeInForce.GoodTillCanceled, remark: remark);
The above calc is obviously way wrong as it is fine for some contracts and wildly out for others.
I feel such an idiot, but what on earth am I doing wrong (either in terms of logic, or in terms of the data I’m using).
This is the final piece in a nice little leverage play that I’ve been working on successfully with minimum contract size, the missing puzzle piece now comes when applying hard scalable $$.
Hope you can help. jim
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top GitHub Comments
I figured it out. it was down to using the Multiplier in a particular way 😉
hope this helps someone else. will add more detail later.
well, if you happen to arrive at a nice little extension method or extended library that works against the Kucoin.Net library, then ping me the link if you share it. My version is definitely pretty ropey and too embarrassing to publicly expose!