Merge pull request #1795 from vnpy/bug-fix

Bug fix
This commit is contained in:
vn.py 2019-06-05 19:30:39 +08:00 committed by GitHub
commit c83a762015
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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