diff --git a/vnpy/trader/rqdata.py b/vnpy/trader/rqdata.py index f3e650bc..630a82f6 100644 --- a/vnpy/trader/rqdata.py +++ b/vnpy/trader/rqdata.py @@ -36,11 +36,15 @@ class RqdataClient: self.inited = False self.symbols = set() - def init(self): + def init(self, username="", password=""): """""" if self.inited: return True + if username and password: + self.username = username + self.password = password + if not self.username or not self.password: return False @@ -75,6 +79,11 @@ class RqdataClient: if word.isdigit(): break + # Check for index symbol + time_str = symbol[count:] + if time_str in ["88", "888", "99"]: + return symbol + # noinspection PyUnboundLocalVariable product = symbol[:count] year = symbol[count] @@ -118,24 +127,27 @@ class RqdataClient: frequency=rq_interval, fields=["open", "high", "low", "close", "volume"], start_date=start, - end_date=end + end_date=end, + adjust_type="none" ) data: List[BarData] = [] - for ix, row in df.iterrows(): - bar = BarData( - symbol=symbol, - exchange=exchange, - interval=interval, - datetime=row.name.to_pydatetime() - adjustment, - open_price=row["open"], - high_price=row["high"], - low_price=row["low"], - close_price=row["close"], - volume=row["volume"], - gateway_name="RQ" - ) - data.append(bar) + + if df is not None: + for ix, row in df.iterrows(): + bar = BarData( + symbol=symbol, + exchange=exchange, + interval=interval, + datetime=row.name.to_pydatetime() - adjustment, + open_price=row["open"], + high_price=row["high"], + low_price=row["low"], + close_price=row["close"], + volume=row["volume"], + gateway_name="RQ" + ) + data.append(bar) return data