BLD: for issue #144, skipped cash verification when there are open orders.

This commit is contained in:
Frederic Fortier
2018-01-07 02:32:12 -05:00
parent 30448a65c5
commit 33f94b3ef9
2 changed files with 11 additions and 3 deletions
+2 -2
View File
@@ -37,8 +37,8 @@ def initialize(context):
context.base_price = None
context.current_day = None
context.RSI_OVERSOLD = 45
context.RSI_OVERBOUGHT = 55
context.RSI_OVERSOLD = 50
context.RSI_OVERBOUGHT = 60
context.CANDLE_SIZE = '5T'
context.start_time = time.time()
+9 -1
View File
@@ -582,10 +582,18 @@ class ExchangeTradingAlgorithmLive(ExchangeTradingAlgorithmBase):
if base_currency is None:
base_currency = exchange.base_currency
# Don't check the cash if there are open orders. This could
# results in false positives.
orders = []
for asset in self.blotter.open_orders:
asset_orders = self.blotter.open_orders[asset]
orders += asset_orders
required_cash = self.portfolio.cash if not orders else None
cash, positions_value = exchange.sync_positions(
positions=exchange_positions,
check_balances=check_balances,
cash=self.portfolio.cash,
cash=required_cash,
)
total_cash += cash
total_positions_value += positions_value