pylivetrader: Pylivetrader fails to call `order_target_percent` if there are untradable stocks

If your portfolio has stocks that are stuck/untradable, and you attempt any sort of order_target_percent action, Pylivetrader crashes when it attempts to lookup the stock price of said-stuck-stock.

It doesn’t matter how large or small the percent is, when the order_target_percent method is invoked it tries to evaluate the size of the portfolio (ie lookup the existing stocks) and the whole action fails.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 18 (15 by maintainers)

Most upvoted comments

i also have the same problem. [2020-09-15 15:07:06.867731] ERROR: Executor: Cannot order TMF, as it not tradable Traceback (most recent call last): File “/usr/local/anaconda3/envs/trade/lib/python3.6/site-packages/pylivetrader/executor/executor.py”, line 67, in wrapper func(*args, **kwargs) File “/usr/local/anaconda3/envs/trade/lib/python3.6/site-packages/pylivetrader/executor/executor.py”, line 88, in every_bar handle_data(algo, current_data, dt_to_use) File “/usr/local/anaconda3/envs/trade/lib/python3.6/site-packages/pylivetrader/misc/events.py”, line 218, in handle_data dt, File “/usr/local/anaconda3/envs/trade/lib/python3.6/site-packages/pylivetrader/misc/events.py”, line 237, in handle_data self.callback(context, data) File “/usr/local/anaconda3/envs/trade/lib/python3.6/site-packages/pylivetrader/algorithm.py”, line 236, in handle_data self._handle_data(self, data) File “algo.py”, line 64, in handle_data order_target_percent(tmf_symbol, 0.3) File “/usr/local/anaconda3/envs/trade/lib/python3.6/site-packages/pylivetrader/misc/api_context.py”, line 62, in wrapped return getattr(algorithm, f.name)(*args, **kwargs) File “/usr/local/anaconda3/envs/trade/lib/python3.6/site-packages/pylivetrader/algorithm.py”, line 621, in order_target_percent amount = self._calculate_order_target_percent_amount(asset, target) File “/usr/local/anaconda3/envs/trade/lib/python3.6/site-packages/pylivetrader/algorithm.py”, line 860, in _calculate_order_target_percent_amount target_amount = self._calculate_order_percent_amount(asset, target) File “/usr/local/anaconda3/envs/trade/lib/python3.6/site-packages/pylivetrader/algorithm.py”, line 850, in _calculate_order_percent_amount return self._calculate_order_value_amount(asset, value) File “/usr/local/anaconda3/envs/trade/lib/python3.6/site-packages/pylivetrader/algorithm.py”, line 825, in _calculate_order_value_amount msg=“Cannot order {0}, as it not tradable”.format(asset.symbol) pylivetrader.errors.CannotOrderDelistedAsset: Cannot order TMF, as it not tradable