[Add]adjust timestamp of bar data from RQData, close #1573

This commit is contained in:
vn.py 2019-04-30 14:29:35 +08:00
parent dbf37c629a
commit 791fb0d840

View File

@ -16,6 +16,12 @@ INTERVAL_VT2RQ = {
Interval.DAILY: "1d", Interval.DAILY: "1d",
} }
INTERVAL_ADJUSTMENT_MAP = {
Interval.MINUTE: timedelta(minutes=1),
Interval.HOUR: timedelta(hours=1),
Interval.DAILY: timedelta() # no need to adjust for daily bar
}
class RqdataClient: class RqdataClient:
""" """
@ -102,7 +108,11 @@ class RqdataClient:
if not rq_interval: if not rq_interval:
return None return None
end += timedelta(1) # For querying night trading period data # For adjust timestamp from bar close point (RQData) to open point (VN Trader)
adjustment = INTERVAL_ADJUSTMENT_MAP[interval]
# For querying night trading period data
end += timedelta(1)
df = rqdata_get_price( df = rqdata_get_price(
rq_symbol, rq_symbol,
@ -118,7 +128,7 @@ class RqdataClient:
symbol=symbol, symbol=symbol,
exchange=exchange, exchange=exchange,
interval=interval, interval=interval,
datetime=row.name.to_pydatetime(), datetime=row.name.to_pydatetime() - adjustment,
open_price=row["open"], open_price=row["open"],
high_price=row["high"], high_price=row["high"],
low_price=row["low"], low_price=row["low"],