def init(self, username: str = "", password: str = "") -> bool: """""" 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 try: rqdata_init( self.username, self.password, ("rqdatad-pro.ricequant.com", 16011), use_pool=True, max_pool_size=1 ) df = rqdata_all_instruments() self.symbols = df["order_book_id"].values except (RuntimeError, AuthenticationFailed): return False self.inited = True return True
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 rqdata_init( self.username, self.password, ('rqdatad-pro.ricequant.com', 16011), use_pool=True, ) try: df = rqdata_all_instruments() for ix, row in df.iterrows(): self.symbols.add(row['order_book_id']) except (RuntimeError, AuthenticationFailed): return False self.inited = True return True
def init(self, username: str = "", password: str = "") -> bool: """""" 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 try: rqdata_init(self.username, self.password, ('rqdatad-pro.ricequant.com', 16011), use_pool=True, max_pool_size=3) df = rqdata_all_instruments() for ix, row in df.iterrows(): self.symbols.add(row['order_book_id']) temp = rqdata_get_price('000001.XSHE', start_date='2015-04-01', end_date='2015-04-01', frequency='15m') print('get_price', temp) except (RuntimeError, AuthenticationFailed): print('rqdata error') return False self.inited = True return True
def rqdata_download_cs(): connect_rqdata() cslist = rqdata_all_instruments('CS') engine = create_engine( 'mysql+pymysql://root:[email protected]/vnpy?charset=utf8') # 550 begin, over = 1800, len(cslist) print('rqdata', begin, over) with engine.connect() as con: cursor = begin length = len(cslist) tbname = 'xshedata' Base = declarative_base() # insert into xshedata(order_book_id, datatime, open, close, high, low, volume, total_turnover, interval) values(select order_book_id, datatime, open, close, high, low, volume, total_turnover, interval from ``) # 3. 创建表模型 class User(Base): __tablename__ = tbname id = Column(Integer, primary_key=True, autoincrement=True) order_book_id = Column(String(32)) datetime = Column(DateTime) open = Column(Float) close = Column(Float) high = Column(Float) low = Column(Float) volume = Column(Float) total_turnover = Column(Float) interval = Column(String(32)) def __repr__(self): return self.name Base.metadata.create_all(engine) while cursor < over and cursor < length: row = cslist.iloc[cursor] try: download_stock(row['order_book_id'], engine, tbname) except QuotaExceeded: print('pause', cursor) raise QuotaExceeded except Exception as e: print(e) cursor += 1
def init(self): """""" if self.inited: return True if not self.username or not self.password: return False rqdata_init(self.username, self.password, ('rqdatad-pro.ricequant.com', 16011)) try: df = rqdata_all_instruments(date=datetime.now()) for ix, row in df.iterrows(): self.symbols.add(row['order_book_id']) except RuntimeError: return False self.inited = True return True