From 769e70290d6373384e7a6fa5518a739faf2fb821 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Mon, 29 Apr 2019 13:30:27 +0800 Subject: [PATCH] [Add]interval map from vt to rqdata --- vnpy/trader/rqdata.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/vnpy/trader/rqdata.py b/vnpy/trader/rqdata.py index 4f0f261e..9b573e0f 100644 --- a/vnpy/trader/rqdata.py +++ b/vnpy/trader/rqdata.py @@ -10,6 +10,13 @@ from .constant import Exchange, Interval from .object import BarData +INTERVAL_VT2RQ = { + Interval.MINUTE: "1m", + Interval.HOUR: "1h", + Interval.DAILY: "1d", +} + + class RqdataClient: """ Client for querying history data from RQData. @@ -91,11 +98,15 @@ class RqdataClient: if rq_symbol not in self.symbols: return None + rq_interval = INTERVAL_VT2RQ.get(interval) + if not rq_interval: + return None + end += timedelta(1) # For querying night trading period data df = rqdata_get_price( rq_symbol, - frequency=interval.value, + frequency=rq_interval, fields=["open", "high", "low", "close", "volume"], start_date=start, end_date=end