Hello dear ctradudes and -dudettes,
I am coding on my cbots for quite some time now (well, seldom but I started a long time ago^^), and there is one error which is prone to my solving attempts:
If I open a position, the Margin of the Position is higher than I formerly anticipated.
double wantedMargin = 50;
double wantedMarginInCorrectAsset = AssetConverter.Convert(wantedMargin, Assets.GetAsset("EUR"), Symbol.QuoteAsset);
double helper = wantedMarginInCorrectAsset / Symbol.Ask; // since Symbol.Ask is in Symbol.QuoteAsset
double volume = helper * Leverage; // in my case 5
double normVolume = Symbol.NormalizeVolume(volume, RoundingMode.Down); // to not exceed bugdet
TradeResult result = executeMarketOrder(TradeType.Buy, Symbol, normVolume, "myLabel");
// BUT after succesfull opening:
// result.Position.Margin == 66.07 != 50 == wantedMargin
Base question is how to get the correct value that executeMarketOrder expects with a given amount of margin I want to invest?
I am struggling with this task for a long time now, and hopefully someone can help.
All the best to you!