burakoner / OKEx.Net

Open source .Net API wrapper for the @OKEx V5 Rest API and V5 Websocket API
MIT License
86 stars 48 forks source link

How to calculate order size? #57

Closed overstartup closed 2 years ago

overstartup commented 2 years ago

Could you please explain to me how I can calculate the order size ? The other question, how I can set the leverage?

For example, I want to order Ethereum : price : 2789 leverage : 40 amount: 300 USDT

overstartup commented 2 years ago

this is the solution:

var instruments = api.GetInstruments(OkexInstrumentType.Swap).Data.Where(x => x.SettlementCurrency == "USDT" && x.Instrument == Symbol).FirstOrDefault();

int lotzize = (int)(2789 instruments.ContractValue); decimal size = Math.Round((decimal)(300 Leverage) / lotzize);