mirror of
https://github.com/wassname/catalyst.git
synced 2026-06-27 21:06:32 +08:00
BLD: housekeeping and adjustments
This commit is contained in:
@@ -143,7 +143,7 @@ def analyze(context, stats):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
live = False
|
||||
live = True
|
||||
if live:
|
||||
run_algorithm(
|
||||
capital_base=0.001,
|
||||
|
||||
@@ -39,7 +39,7 @@ def initialize(context):
|
||||
|
||||
context.RSI_OVERSOLD = 55
|
||||
context.RSI_OVERBOUGHT = 60
|
||||
context.CANDLE_SIZE = '5T'
|
||||
context.CANDLE_SIZE = '15T'
|
||||
|
||||
context.start_time = time.time()
|
||||
|
||||
@@ -114,7 +114,7 @@ def handle_data(context, data):
|
||||
# TODO: retest with open orders
|
||||
# Since we are using limit orders, some orders may not execute immediately
|
||||
# we wait until all orders are executed before considering more trades.
|
||||
orders = get_open_orders(context.market)
|
||||
orders = context.blotter.open_orders
|
||||
if len(orders) > 0:
|
||||
log.info('exiting because orders are open: {}'.format(orders))
|
||||
return
|
||||
|
||||
@@ -431,18 +431,14 @@ class CCXT(Exchange):
|
||||
bars_to_now = pd.date_range(
|
||||
end_dt, pd.Timestamp.utcnow(), freq=freq
|
||||
)
|
||||
if len(bars_to_now) > 1:
|
||||
# See: https://github.com/ccxt/ccxt/issues/1360
|
||||
if len(bars_to_now) > 1 or self.name in ['poloniex']:
|
||||
dt_range = get_periods_range(
|
||||
end_dt=end_dt,
|
||||
periods=bar_count,
|
||||
freq=freq,
|
||||
)
|
||||
# with some exchanges, skip the left bound of the range
|
||||
# since the open range is on the right bound
|
||||
if self.name in ['poloniex']:
|
||||
start_dt = dt_range[1]
|
||||
else:
|
||||
start_dt = dt_range[0]
|
||||
start_dt = dt_range[0]
|
||||
|
||||
since = None
|
||||
if start_dt is not None:
|
||||
@@ -471,6 +467,9 @@ class CCXT(Exchange):
|
||||
close=ohlcv[4],
|
||||
volume=ohlcv[5]
|
||||
))
|
||||
candles[asset] = sorted(
|
||||
candles[asset], key=lambda c: c['last_traded']
|
||||
)
|
||||
|
||||
if is_single:
|
||||
return six.next(six.itervalues(candles))
|
||||
|
||||
Reference in New Issue
Block a user