mirror of
https://github.com/wassname/catalyst.git
synced 2026-06-29 10:26:10 +08:00
BLD: for issue #144, skipped cash verification when there are open orders.
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user