tbapi.api.bases.trade_management_strategy
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 TradeManagementStrategy as _TradeManagementStrategy 8from typing import Any, overload 9from abc import ABC, abstractmethod 10from tbapi.api.bases.trading_script import TradingScript 11from tbapi.api.interfaces.orders.iorder import IOrder 12 13@tb_interface(_TradeManagementStrategy) 14class TradeManagementStrategy(TradingScript): 15 """A base class for trade management strategies, providing methods to control the activation and deactivation of the strategy.""" 16 17 @staticmethod 18 def new(*args, **kwargs): 19 """Generic factory method for TradeManagementStrategy. Use overloads for IDE type hints.""" 20 return TradeManagementStrategy(*args, **kwargs) 21 22 @property 23 def is_active(self) -> bool: 24 """Indicates whether the trade management strategy is active.""" 25 val = self._value.IsActive 26 return val 27 28 29 @clr.clrmethod(None, [Any]) 30 def on_entry_order(self, order: IOrder) -> None: 31 """Handles the entry order when it is placed. The entry order for the trade.""" 32 ... 33 34 @clr.clrmethod(None, [None]) 35 def on_shutdown(self) -> None: 36 """Handles shutdown operations when the strategy is stopped or the script is terminated.""" 37 ...
@tb_interface(_TradeManagementStrategy)
class
TradeManagementStrategy21@tb_interface(_TradeManagementStrategy) 22class TradeManagementStrategy(TradingScript): 23 """A base class for trade management strategies, providing methods to control the activation and deactivation of the strategy.""" 24 25 @staticmethod 26 def new(*args, **kwargs): 27 """Generic factory method for TradeManagementStrategy. Use overloads for IDE type hints.""" 28 return TradeManagementStrategy(*args, **kwargs) 29 30 @property 31 def is_active(self) -> bool: 32 """Indicates whether the trade management strategy is active.""" 33 val = self._value.IsActive 34 return val 35 36 37 @clr.clrmethod(None, [Any]) 38 def on_entry_order(self, order: IOrder) -> None: 39 """Handles the entry order when it is placed. The entry order for the trade.""" 40 ... 41 42 @clr.clrmethod(None, [None]) 43 def on_shutdown(self) -> None: 44 """Handles shutdown operations when the strategy is stopped or the script is terminated.""" 45 ...
A base class for trade management strategies, providing methods to control the activation and deactivation of the strategy.
@staticmethod
def
new(*args, **kwargs):
25 @staticmethod 26 def new(*args, **kwargs): 27 """Generic factory method for TradeManagementStrategy. Use overloads for IDE type hints.""" 28 return TradeManagementStrategy(*args, **kwargs)
Generic factory method for TradeManagementStrategy. Use overloads for IDE type hints.
is_active: bool
30 @property 31 def is_active(self) -> bool: 32 """Indicates whether the trade management strategy is active.""" 33 val = self._value.IsActive 34 return val
Indicates whether the trade management strategy is active.
def
on_entry_order(unknown):
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")
def
on_shutdown(unknown):
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")
Inherited Members
- tbapi.api.bases.trading_script.TradingScript
- symbol
- account
- pending_orders
- position
- run_type
- execute_market_order
- place_order
- place_limit_order
- place_stop_limit_order
- place_stop_order
- set_stop_loss
- set_stop_loss_ticks
- set_stop_loss_percent
- set_take_profit
- set_take_profit_ticks
- set_take_profit_percent
- modify_order
- cancel_order
- close_position
- get_exchange_rate
- get_order_expected_price
- on_order_update
- on_order_fill_update
- on_position_update
- on_bar_update
- on_bar