Skip to content

Commit 2a95011

Browse files
committed
fix bug
1 parent 12ebfb0 commit 2a95011

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

trader/utils/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ def calc_corr(day: datetime.datetime):
448448
'product_code', flat=True):
449449
price_dict[code] = to_df(MainBar.objects.filter(
450450
time__gte=begin_day.date(),
451-
product_code=code).order_by('time').values_list('time', 'close'))
451+
product_code=code).order_by('time').values_list('time', 'close'), index_col='time', parse_dates=['time'])
452452
price_dict[code].index = pd.DatetimeIndex(price_dict[code].time)
453453
price_dict[code]['price'] = price_dict[code].close.pct_change()
454454
return pd.DataFrame({k: v.price for k, v in price_dict.items()}).corr()
@@ -485,7 +485,7 @@ def calc_history_signal(inst: Instrument, day: datetime.datetime, strategy: Stra
485485
df = to_df(MainBar.objects.filter(
486486
time__lte=day.date(),
487487
exchange=inst.exchange, product_code=inst.product_code).order_by('time').values_list(
488-
'time', 'open', 'high', 'low', 'close', 'settlement'))
488+
'time', 'open', 'high', 'low', 'close', 'settlement'), index_col='time', parse_dates=['time'])
489489
df.index = pd.DatetimeIndex(df.time, tz=pytz.FixedOffset(480))
490490
df['atr'] = ATR(df.high, df.low, df.close, timeperiod=atr_n)
491491
# df columns: 0:time,1:open,2:high,3:low,4:close,5:settlement,6:atr,7:short_trend,8:long_trend

0 commit comments

Comments
 (0)