mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-03 07:42:47 +08:00
BUG: fixed an issue with open orders
This commit is contained in:
@@ -60,7 +60,7 @@ def _handle_data(context, data):
|
||||
rsi=rsi,
|
||||
)
|
||||
|
||||
orders = get_open_orders(context.asset)
|
||||
orders = context.blotter.open_orders
|
||||
if orders:
|
||||
log.info('skipping bar until all open orders execute')
|
||||
return
|
||||
@@ -146,11 +146,11 @@ if __name__ == '__main__':
|
||||
live = True
|
||||
if live:
|
||||
run_algorithm(
|
||||
capital_base=0.001,
|
||||
capital_base=1000,
|
||||
initialize=initialize,
|
||||
handle_data=handle_data,
|
||||
analyze=analyze,
|
||||
exchange_name='binance',
|
||||
exchange_name='bittrex',
|
||||
live=True,
|
||||
algo_namespace=algo_namespace,
|
||||
base_currency='btc',
|
||||
|
||||
@@ -391,8 +391,6 @@ class ExchangeTradingAlgorithmLive(ExchangeTradingAlgorithmBase):
|
||||
log.warn("Can't initialize signal handler inside another thread."
|
||||
"Exit should be handled by the user.")
|
||||
|
||||
log.info('initialized trading algorithm in live mode')
|
||||
|
||||
def interrupt_algorithm(self):
|
||||
self.is_running = False
|
||||
|
||||
@@ -874,6 +872,13 @@ class ExchangeTradingAlgorithmLive(ExchangeTradingAlgorithmBase):
|
||||
raise NotImplementedError()
|
||||
|
||||
def _get_open_orders(self, asset=None):
|
||||
if self.simulate_orders:
|
||||
raise ValueError(
|
||||
'The get_open_orders() method only works in live mode. '
|
||||
'The purpose is to list open orders on the exchange '
|
||||
'regardless who placed them. To list the open orders of '
|
||||
'this algo, use `context.blotter.open_orders`.'
|
||||
)
|
||||
if asset:
|
||||
exchange = self.exchanges[asset.exchange]
|
||||
return exchange.get_open_orders(asset)
|
||||
@@ -907,6 +912,7 @@ class ExchangeTradingAlgorithmLive(ExchangeTradingAlgorithmBase):
|
||||
If an asset is passed then this will return a list of the open
|
||||
orders for this asset.
|
||||
"""
|
||||
# TODO: should this be a shortcut to the open orders in the blotter?
|
||||
return retry(
|
||||
action=self._get_open_orders,
|
||||
attempts=self.attempts['get_open_orders_attempts'],
|
||||
|
||||
Reference in New Issue
Block a user