Skip to content

Symbol.GetEstimatedMargin

method · Symbol · cAlgo.API.Internals

DesktopCLICloud

Returns the amount of margin you need for x amount of volume.

Definition

double GetEstimatedMargin(TradeType tradeType, double volume)
api.Symbol.GetEstimatedMargin(tradeType: TradeType, volume: float) -> float

Parameters

Name C# type Python type Description
tradeType TradeType TradeType Order trade type
volume double float Amount of volume

Returns double — Amount of Margin

Examples

var volume = Symbol.QuantityToVolumeInUnits(1);
var margin = Symbol.GetEstimatedMargin(TradeType.Buy, volume);
if (margin < Account.FreeMargin)
    ExecuteMarketOrder(TradeType.Buy, SymbolName, volume);
else
    Print("Not enough free margin, required: {0}", margin);
volume = api.Symbol.QuantityToVolumeInUnits(1)
margin = api.Symbol.GetEstimatedMargin(TradeType.Buy, volume)
if margin < api.Account.FreeMargin:
    api.ExecuteMarketOrder(TradeType.Buy, api.SymbolName, volume)
else:
    api.Print(f"Not enough free margin, required: {margin}")