Positions.Find
method · Positions · cAlgo.API
DesktopCLICloud
Find a position by its label.
Overloads
| Signature | Description |
|---|---|
Find(string label) | Find a position by its label. |
Find(string label, string symbolName) | Find a position by its label and symbol name. |
Find(string label, string symbolName, TradeType tradeType) | Find a position by its label, symbol name and trade type |
Find(string label)
Find a position by its label.
Position Find(string label)
api.Positions.Find(label: str) -> Position | None
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
label | string | str | Label to search by |
Returns Position — Position if it exists, null otherwise
Examples
var position = Positions.Find("myLabel");
if (position != null)
Print("Net profit: {0}", position.NetProfit);
position = api.Positions.Find("myLabel")
if position is not None:
api.Print(f"Net profit: {position.NetProfit}")
Find(string label, string symbolName)
Find a position by its label and symbol name.
Position Find(string label, string symbolName)
api.Positions.Find(label: str, symbolName: str) -> Position | None
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
label | string | str | Label to search by |
symbolName | string | str | Symbol name to search by |
Returns Position — Position if it exists, null otherwise
Examples
var position = Positions.Find("myLabel", "EURUSD");
if (position != null)
Print("EURUSD position {0} net profit: {1}", position.Id, position.NetProfit);
position = api.Positions.Find("myLabel", "EURUSD")
if position is not None:
api.Print(f"EURUSD position {position.Id} net profit: {position.NetProfit}")
Find(string label, string symbolName, TradeType tradeType)
Find a position by its label, symbol name and trade type
Position Find(string label, string symbolName, TradeType tradeType)
api.Positions.Find(label: str, symbolName: str, tradeType: TradeType) -> Position | None
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
label | string | str | Label to search by |
symbolName | string | str | Symbol name to search by |
tradeType | TradeType | TradeType | Trade type to search by |
Returns Position — Position if it exists, null otherwise
Examples
var position = Positions.Find("myLabel", "EURUSD", TradeType.Buy);
if (position == null)
ExecuteMarketOrder(TradeType.Buy, "EURUSD", 10000, "myLabel", 20, 40);
position = api.Positions.Find("myLabel", "EURUSD", TradeType.Buy)
if position is None:
api.ExecuteMarketOrder(TradeType.Buy, "EURUSD", 10000, "myLabel", 20, 40)