tbapi.api.bases.trading_script
1from __future__ import annotations 2from typing import TYPE_CHECKING 3import clr 4from tbapi.common.decorators import tb_class, tb_interface 5from tbapi.common.converters import to_python_datetime, to_net_datetime 6from datetime import datetime 7from Tickblaze.Scripts.Api.Bases import TradingScript as _TradingScript 8from typing import Any, overload 9from abc import ABC, abstractmethod 10from tbapi.api.bases.symbol_script import SymbolScript 11from tbapi.api.interfaces.orders.iorder_manager import IOrderManager 12from tbapi.api.enums.run_type import RunType 13from tbapi.api.enums.order_action import OrderAction 14from tbapi.api.enums.time_in_force import TimeInForce 15from tbapi.api.enums.order_type import OrderType 16from Tickblaze.Scripts.Api.Enums import RunType as _RunType 17from Tickblaze.Scripts.Api.Enums import OrderAction as _OrderAction 18from Tickblaze.Scripts.Api.Enums import TimeInForce as _TimeInForce 19from Tickblaze.Scripts.Api.Enums import OrderType as _OrderType 20from tbapi.api.interfaces.orders.iorder import IOrder 21if TYPE_CHECKING: 22 from tbapi.api.interfaces.isymbol import ISymbol 23 from tbapi.api.interfaces.iaccount import IAccount 24 from tbapi.api.interfaces.orders.iposition import IPosition 25 26@tb_interface(_TradingScript) 27class TradingScript(SymbolScript, IOrderManager): 28 """Represents a trading script that allows the execution and management of orders and positions in a trading system.""" 29 30 @staticmethod 31 def new(*args, **kwargs): 32 """Generic factory method for TradingScript. Use overloads for IDE type hints.""" 33 return TradingScript(*args, **kwargs) 34 35 @property 36 def symbol(self) -> ISymbol: 37 from tbapi.api.interfaces.isymbol import ISymbol 38 val = self._value.Symbol 39 return ISymbol(_existing=val) 40 @property 41 def account(self) -> IAccount: 42 from tbapi.api.interfaces.iaccount import IAccount 43 val = self._value.Account 44 return IAccount(_existing=val) 45 @property 46 def pending_orders(self) -> IReadOnlyList: 47 val = self._value.PendingOrders 48 return val 49 @property 50 def position(self) -> IPosition: 51 from tbapi.api.interfaces.orders.iposition import IPosition 52 val = self._value.Position 53 return IPosition(_existing=val) 54 @property 55 def run_type(self) -> RunType: 56 val = int(self._value.RunType) 57 return RunType(val) 58 59 def execute_market_order(self, action: OrderAction, quantity: float, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder: 60 result = self._value.ExecuteMarketOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), quantity, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment) 61 from tbapi.api.interfaces.orders.iorder import IOrder 62 return IOrder(_existing=result) 63 64 def place_order(self, action: OrderAction, type: OrderType, quantity: float, stop_price: float | None, limit_price: float | None, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder: 65 result = self._value.PlaceOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), _OrderType(type.value if hasattr(type, 'value') else int(type)), quantity, stop_price, limit_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment) 66 from tbapi.api.interfaces.orders.iorder import IOrder 67 return IOrder(_existing=result) 68 69 def place_limit_order(self, action: OrderAction, quantity: float, limit_price: float, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder: 70 result = self._value.PlaceLimitOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), quantity, limit_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment) 71 from tbapi.api.interfaces.orders.iorder import IOrder 72 return IOrder(_existing=result) 73 74 def place_stop_limit_order(self, action: OrderAction, quantity: float, stop_price: float, limit_price: float, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder: 75 result = self._value.PlaceStopLimitOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), quantity, stop_price, limit_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment) 76 from tbapi.api.interfaces.orders.iorder import IOrder 77 return IOrder(_existing=result) 78 79 def place_stop_order(self, action: OrderAction, quantity: float, stop_price: float, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder: 80 result = self._value.PlaceStopOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), quantity, stop_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment) 81 from tbapi.api.interfaces.orders.iorder import IOrder 82 return IOrder(_existing=result) 83 84 def set_stop_loss(self, order: IOrder, stop_price: float, comment: str = "") -> IOrder: 85 result = self._value.SetStopLoss(order._value, stop_price, comment) 86 from tbapi.api.interfaces.orders.iorder import IOrder 87 return IOrder(_existing=result) 88 89 def set_stop_loss_ticks(self, order: IOrder, ticks: int, comment: str = "") -> IOrder: 90 result = self._value.SetStopLossTicks(order._value, ticks, comment) 91 from tbapi.api.interfaces.orders.iorder import IOrder 92 return IOrder(_existing=result) 93 94 def set_stop_loss_percent(self, order: IOrder, percent: float, comment: str = "") -> IOrder: 95 result = self._value.SetStopLossPercent(order._value, percent, comment) 96 from tbapi.api.interfaces.orders.iorder import IOrder 97 return IOrder(_existing=result) 98 99 def set_take_profit(self, order: IOrder, limit_price: float, comment: str = "") -> IOrder: 100 result = self._value.SetTakeProfit(order._value, limit_price, comment) 101 from tbapi.api.interfaces.orders.iorder import IOrder 102 return IOrder(_existing=result) 103 104 def set_take_profit_ticks(self, order: IOrder, ticks: int, comment: str = "") -> IOrder: 105 result = self._value.SetTakeProfitTicks(order._value, ticks, comment) 106 from tbapi.api.interfaces.orders.iorder import IOrder 107 return IOrder(_existing=result) 108 109 def set_take_profit_percent(self, order: IOrder, percent: float, comment: str = "") -> IOrder: 110 result = self._value.SetTakeProfitPercent(order._value, percent, comment) 111 from tbapi.api.interfaces.orders.iorder import IOrder 112 return IOrder(_existing=result) 113 114 def modify_order(self, order: IOrder, quantity: float, stop_price: float | None, limit_price: float | None, time_in_force: TimeInForce = TimeInForce.Day) -> None: 115 result = self._value.ModifyOrder(order._value, quantity, stop_price, limit_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force))) 116 return result 117 118 def cancel_order(self, order: IOrder, comment: str = "", cancel_silently: bool = False) -> None: 119 result = self._value.CancelOrder(order._value, comment, cancel_silently) 120 return result 121 122 def close_position(self, comment: str = "") -> None: 123 result = self._value.ClosePosition(comment) 124 return result 125 126 def get_exchange_rate(self, from_currency: str, to_currency: str) -> float: 127 result = self._value.GetExchangeRate(from_currency, to_currency) 128 return result 129 130 def get_order_expected_price(self, order: IOrder) -> float: 131 result = self._value.GetOrderExpectedPrice(order._value) 132 return result 133 134 135 @clr.clrmethod(None, [Any]) 136 def on_order_update(self, order: IOrder) -> None: 137 """Called when an order's status is updated. The updated order.""" 138 ... 139 140 @clr.clrmethod(None, [Any]) 141 def on_order_fill_update(self, order: IOrder) -> None: 142 """Called when an order's fill status is updated (after positions, trades, and dependant orders are updated). The updated order.""" 143 ... 144 145 @clr.clrmethod(None, [None]) 146 def on_position_update(self) -> None: 147 """Called when the position's status is updated.""" 148 ... 149 150 @clr.clrmethod(None, [None]) 151 def on_bar_update(self) -> None: 152 """Called when the bar data is updated.""" 153 ... 154 155 @clr.clrmethod(None, [int]) 156 def on_bar(self, index: int) -> None: 157 """Called when bar is updated. The index of the updated bar.""" 158 ...
34@tb_interface(_TradingScript) 35class TradingScript(SymbolScript, IOrderManager): 36 """Represents a trading script that allows the execution and management of orders and positions in a trading system.""" 37 38 @staticmethod 39 def new(*args, **kwargs): 40 """Generic factory method for TradingScript. Use overloads for IDE type hints.""" 41 return TradingScript(*args, **kwargs) 42 43 @property 44 def symbol(self) -> ISymbol: 45 from tbapi.api.interfaces.isymbol import ISymbol 46 val = self._value.Symbol 47 return ISymbol(_existing=val) 48 @property 49 def account(self) -> IAccount: 50 from tbapi.api.interfaces.iaccount import IAccount 51 val = self._value.Account 52 return IAccount(_existing=val) 53 @property 54 def pending_orders(self) -> IReadOnlyList: 55 val = self._value.PendingOrders 56 return val 57 @property 58 def position(self) -> IPosition: 59 from tbapi.api.interfaces.orders.iposition import IPosition 60 val = self._value.Position 61 return IPosition(_existing=val) 62 @property 63 def run_type(self) -> RunType: 64 val = int(self._value.RunType) 65 return RunType(val) 66 67 def execute_market_order(self, action: OrderAction, quantity: float, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder: 68 result = self._value.ExecuteMarketOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), quantity, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment) 69 from tbapi.api.interfaces.orders.iorder import IOrder 70 return IOrder(_existing=result) 71 72 def place_order(self, action: OrderAction, type: OrderType, quantity: float, stop_price: float | None, limit_price: float | None, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder: 73 result = self._value.PlaceOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), _OrderType(type.value if hasattr(type, 'value') else int(type)), quantity, stop_price, limit_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment) 74 from tbapi.api.interfaces.orders.iorder import IOrder 75 return IOrder(_existing=result) 76 77 def place_limit_order(self, action: OrderAction, quantity: float, limit_price: float, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder: 78 result = self._value.PlaceLimitOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), quantity, limit_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment) 79 from tbapi.api.interfaces.orders.iorder import IOrder 80 return IOrder(_existing=result) 81 82 def place_stop_limit_order(self, action: OrderAction, quantity: float, stop_price: float, limit_price: float, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder: 83 result = self._value.PlaceStopLimitOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), quantity, stop_price, limit_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment) 84 from tbapi.api.interfaces.orders.iorder import IOrder 85 return IOrder(_existing=result) 86 87 def place_stop_order(self, action: OrderAction, quantity: float, stop_price: float, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder: 88 result = self._value.PlaceStopOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), quantity, stop_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment) 89 from tbapi.api.interfaces.orders.iorder import IOrder 90 return IOrder(_existing=result) 91 92 def set_stop_loss(self, order: IOrder, stop_price: float, comment: str = "") -> IOrder: 93 result = self._value.SetStopLoss(order._value, stop_price, comment) 94 from tbapi.api.interfaces.orders.iorder import IOrder 95 return IOrder(_existing=result) 96 97 def set_stop_loss_ticks(self, order: IOrder, ticks: int, comment: str = "") -> IOrder: 98 result = self._value.SetStopLossTicks(order._value, ticks, comment) 99 from tbapi.api.interfaces.orders.iorder import IOrder 100 return IOrder(_existing=result) 101 102 def set_stop_loss_percent(self, order: IOrder, percent: float, comment: str = "") -> IOrder: 103 result = self._value.SetStopLossPercent(order._value, percent, comment) 104 from tbapi.api.interfaces.orders.iorder import IOrder 105 return IOrder(_existing=result) 106 107 def set_take_profit(self, order: IOrder, limit_price: float, comment: str = "") -> IOrder: 108 result = self._value.SetTakeProfit(order._value, limit_price, comment) 109 from tbapi.api.interfaces.orders.iorder import IOrder 110 return IOrder(_existing=result) 111 112 def set_take_profit_ticks(self, order: IOrder, ticks: int, comment: str = "") -> IOrder: 113 result = self._value.SetTakeProfitTicks(order._value, ticks, comment) 114 from tbapi.api.interfaces.orders.iorder import IOrder 115 return IOrder(_existing=result) 116 117 def set_take_profit_percent(self, order: IOrder, percent: float, comment: str = "") -> IOrder: 118 result = self._value.SetTakeProfitPercent(order._value, percent, comment) 119 from tbapi.api.interfaces.orders.iorder import IOrder 120 return IOrder(_existing=result) 121 122 def modify_order(self, order: IOrder, quantity: float, stop_price: float | None, limit_price: float | None, time_in_force: TimeInForce = TimeInForce.Day) -> None: 123 result = self._value.ModifyOrder(order._value, quantity, stop_price, limit_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force))) 124 return result 125 126 def cancel_order(self, order: IOrder, comment: str = "", cancel_silently: bool = False) -> None: 127 result = self._value.CancelOrder(order._value, comment, cancel_silently) 128 return result 129 130 def close_position(self, comment: str = "") -> None: 131 result = self._value.ClosePosition(comment) 132 return result 133 134 def get_exchange_rate(self, from_currency: str, to_currency: str) -> float: 135 result = self._value.GetExchangeRate(from_currency, to_currency) 136 return result 137 138 def get_order_expected_price(self, order: IOrder) -> float: 139 result = self._value.GetOrderExpectedPrice(order._value) 140 return result 141 142 143 @clr.clrmethod(None, [Any]) 144 def on_order_update(self, order: IOrder) -> None: 145 """Called when an order's status is updated. The updated order.""" 146 ... 147 148 @clr.clrmethod(None, [Any]) 149 def on_order_fill_update(self, order: IOrder) -> None: 150 """Called when an order's fill status is updated (after positions, trades, and dependant orders are updated). The updated order.""" 151 ... 152 153 @clr.clrmethod(None, [None]) 154 def on_position_update(self) -> None: 155 """Called when the position's status is updated.""" 156 ... 157 158 @clr.clrmethod(None, [None]) 159 def on_bar_update(self) -> None: 160 """Called when the bar data is updated.""" 161 ... 162 163 @clr.clrmethod(None, [int]) 164 def on_bar(self, index: int) -> None: 165 """Called when bar is updated. The index of the updated bar.""" 166 ...
Represents a trading script that allows the execution and management of orders and positions in a trading system.
38 @staticmethod 39 def new(*args, **kwargs): 40 """Generic factory method for TradingScript. Use overloads for IDE type hints.""" 41 return TradingScript(*args, **kwargs)
Generic factory method for TradingScript. Use overloads for IDE type hints.
43 @property 44 def symbol(self) -> ISymbol: 45 from tbapi.api.interfaces.isymbol import ISymbol 46 val = self._value.Symbol 47 return ISymbol(_existing=val)
The financial symbol associated with the orders and position.
48 @property 49 def account(self) -> IAccount: 50 from tbapi.api.interfaces.iaccount import IAccount 51 val = self._value.Account 52 return IAccount(_existing=val)
The account associated with the orders and position.
53 @property 54 def pending_orders(self) -> IReadOnlyList: 55 val = self._value.PendingOrders 56 return val
A collection of orders that are currently pending execution.
57 @property 58 def position(self) -> IPosition: 59 from tbapi.api.interfaces.orders.iposition import IPosition 60 val = self._value.Position 61 return IPosition(_existing=val)
The position associated with the current symbol and account.
67 def execute_market_order(self, action: OrderAction, quantity: float, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder: 68 result = self._value.ExecuteMarketOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), quantity, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment) 69 from tbapi.api.interfaces.orders.iorder import IOrder 70 return IOrder(_existing=result)
Executes a market order immediately based on the given action and quantity. The buy or sell action. The order quantity. Order duration setting. Defaults to Day. Optional order comment.
72 def place_order(self, action: OrderAction, type: OrderType, quantity: float, stop_price: float | None, limit_price: float | None, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder: 73 result = self._value.PlaceOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), _OrderType(type.value if hasattr(type, 'value') else int(type)), quantity, stop_price, limit_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment) 74 from tbapi.api.interfaces.orders.iorder import IOrder 75 return IOrder(_existing=result)
Places an order of specified type with defined price parameters. The buy or sell action. Order type (e.g., Limit, Stop). Order quantity. Stop price if applicable. Limit price if applicable. Order duration. Defaults to Day. Optional comment for the order.
77 def place_limit_order(self, action: OrderAction, quantity: float, limit_price: float, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder: 78 result = self._value.PlaceLimitOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), quantity, limit_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment) 79 from tbapi.api.interfaces.orders.iorder import IOrder 80 return IOrder(_existing=result)
Places a limit order. The buy or sell action. Order quantity. Limit price. Order duration. Defaults to Day. Optional comment for the order.
82 def place_stop_limit_order(self, action: OrderAction, quantity: float, stop_price: float, limit_price: float, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder: 83 result = self._value.PlaceStopLimitOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), quantity, stop_price, limit_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment) 84 from tbapi.api.interfaces.orders.iorder import IOrder 85 return IOrder(_existing=result)
Places a stop-limit order. The buy or sell action. Order quantity. Stop price. Limit price. Order duration. Defaults to Day. Optional comment for the order.
87 def place_stop_order(self, action: OrderAction, quantity: float, stop_price: float, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder: 88 result = self._value.PlaceStopOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), quantity, stop_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment) 89 from tbapi.api.interfaces.orders.iorder import IOrder 90 return IOrder(_existing=result)
Places a stop order that activates when the stop price is reached. The buy or sell action. Order quantity. Stop price. Order duration. Defaults to Day. Optional comment for the order.
92 def set_stop_loss(self, order: IOrder, stop_price: float, comment: str = "") -> IOrder: 93 result = self._value.SetStopLoss(order._value, stop_price, comment) 94 from tbapi.api.interfaces.orders.iorder import IOrder 95 return IOrder(_existing=result)
Sets a stop-loss order on an open position at a specified price. The order of the open position to which the stop-loss is applied. The price at which the stop-loss order is set. Optional comment for the order, providing additional information or notes. The updated order with the stop-loss applied.
97 def set_stop_loss_ticks(self, order: IOrder, ticks: int, comment: str = "") -> IOrder: 98 result = self._value.SetStopLossTicks(order._value, ticks, comment) 99 from tbapi.api.interfaces.orders.iorder import IOrder 100 return IOrder(_existing=result)
Sets a stop-loss order on an open position based on a specified number of ticks from the entry price. The order of the open position to which the stop-loss is applied. The number of ticks away from the entry price to place the stop-loss. Optional comment for the order, providing additional information or notes. The updated order with the stop-loss applied.
102 def set_stop_loss_percent(self, order: IOrder, percent: float, comment: str = "") -> IOrder: 103 result = self._value.SetStopLossPercent(order._value, percent, comment) 104 from tbapi.api.interfaces.orders.iorder import IOrder 105 return IOrder(_existing=result)
Sets a stop-loss order on an open position based on a specified percentage from the entry price. The order of the open position to which the stop-loss is applied. The percentage away from the entry price to place the stop-loss. Optional comment for the order, providing additional information or notes. The updated order with the stop-loss applied.
107 def set_take_profit(self, order: IOrder, limit_price: float, comment: str = "") -> IOrder: 108 result = self._value.SetTakeProfit(order._value, limit_price, comment) 109 from tbapi.api.interfaces.orders.iorder import IOrder 110 return IOrder(_existing=result)
Sets a take-profit order at a specified price to close a position when the price is reached. The order of the open position to which the take-profit is applied. The price at which the take-profit order is set. Optional comment for the order, providing additional information or notes. The updated order with the take-profit applied.
112 def set_take_profit_ticks(self, order: IOrder, ticks: int, comment: str = "") -> IOrder: 113 result = self._value.SetTakeProfitTicks(order._value, ticks, comment) 114 from tbapi.api.interfaces.orders.iorder import IOrder 115 return IOrder(_existing=result)
Sets a take-profit order on an open position based on a specified number of ticks from the entry price. The order of the open position to which the take-profit is applied. The number of ticks away from the entry price to place the take-profit. Optional comment for the order, providing additional information or notes. The updated order with the take-profit applied.
117 def set_take_profit_percent(self, order: IOrder, percent: float, comment: str = "") -> IOrder: 118 result = self._value.SetTakeProfitPercent(order._value, percent, comment) 119 from tbapi.api.interfaces.orders.iorder import IOrder 120 return IOrder(_existing=result)
Sets a take-profit order on an open position based on a specified percentage from the entry price. The order of the open position to which the take-profit is applied. The percentage away from the entry price to place the take-profit. Optional comment for the order, providing additional information or notes. The updated order with the take-profit applied.
122 def modify_order(self, order: IOrder, quantity: float, stop_price: float | None, limit_price: float | None, time_in_force: TimeInForce = TimeInForce.Day) -> None: 123 result = self._value.ModifyOrder(order._value, quantity, stop_price, limit_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force))) 124 return result
Modifies an existing order. The order of open position. Order quantity. Stop price if applicable. Limit price if applicable. Order duration. Defaults to Day.
126 def cancel_order(self, order: IOrder, comment: str = "", cancel_silently: bool = False) -> None: 127 result = self._value.CancelOrder(order._value, comment, cancel_silently) 128 return result
Cancels the specified order with an optional comment. The order to cancel. Optional comment for the order. Indicates if the cancellation should be silent.
130 def close_position(self, comment: str = "") -> None: 131 result = self._value.ClosePosition(comment) 132 return result
Closes the entire position with an optional comment. Optional comment for the order.
134 def get_exchange_rate(self, from_currency: str, to_currency: str) -> float: 135 result = self._value.GetExchangeRate(from_currency, to_currency) 136 return result
Retrieves the exchange rate for converting one currency to another. The currency to convert from (e.g., "USD"). The currency to convert to (e.g., "EUR"). The exchange rate between the specified currencies.
138 def get_order_expected_price(self, order: IOrder) -> float: 139 result = self._value.GetOrderExpectedPrice(order._value) 140 return result
Gets estimated fill price of pending order. The pending order.
Method decorator for exposing python methods to .NET. The argument and return types must be specified as arguments to clrmethod.
e.g.::
class X(object):
@clrmethod(int, [str])
def test(self, x):
return len(x)
Methods decorated this way can be called from .NET, e.g.::
dynamic x = getX(); // get an instance of X declared in Python
int z = x.test("hello"); // calls into python and returns len("hello")
Method decorator for exposing python methods to .NET. The argument and return types must be specified as arguments to clrmethod.
e.g.::
class X(object):
@clrmethod(int, [str])
def test(self, x):
return len(x)
Methods decorated this way can be called from .NET, e.g.::
dynamic x = getX(); // get an instance of X declared in Python
int z = x.test("hello"); // calls into python and returns len("hello")
Method decorator for exposing python methods to .NET. The argument and return types must be specified as arguments to clrmethod.
e.g.::
class X(object):
@clrmethod(int, [str])
def test(self, x):
return len(x)
Methods decorated this way can be called from .NET, e.g.::
dynamic x = getX(); // get an instance of X declared in Python
int z = x.test("hello"); // calls into python and returns len("hello")
Method decorator for exposing python methods to .NET. The argument and return types must be specified as arguments to clrmethod.
e.g.::
class X(object):
@clrmethod(int, [str])
def test(self, x):
return len(x)
Methods decorated this way can be called from .NET, e.g.::
dynamic x = getX(); // get an instance of X declared in Python
int z = x.test("hello"); // calls into python and returns len("hello")
Method decorator for exposing python methods to .NET. The argument and return types must be specified as arguments to clrmethod.
e.g.::
class X(object):
@clrmethod(int, [str])
def test(self, x):
return len(x)
Methods decorated this way can be called from .NET, e.g.::
dynamic x = getX(); // get an instance of X declared in Python
int z = x.test("hello"); // calls into python and returns len("hello")