mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-06 05:14:38 +08:00
MAINT: Insert data into asset_router
This commit is contained in:
@@ -163,8 +163,14 @@ class AssetDBWriter(with_metaclass(ABCMeta)):
|
||||
|
||||
def _write_futures(self, futures, db_conn):
|
||||
|
||||
# Retrieve the data to add to the futures_contracts table
|
||||
data = [tuple(x) for x in futures.to_records()]
|
||||
|
||||
# Retrieve the data to add to the asset_router table
|
||||
sids = [x[0] for x in data]
|
||||
futs = ['future'] * len(sids)
|
||||
to_insert = zip(sids, futs)
|
||||
|
||||
c = db_conn.cursor()
|
||||
c.executemany("""
|
||||
INSERT OR IGNORE INTO futures_contracts
|
||||
@@ -174,6 +180,12 @@ class AssetDBWriter(with_metaclass(ABCMeta)):
|
||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""", data)
|
||||
|
||||
c.executemany("""
|
||||
INSERT INTO asset_router
|
||||
('sid', 'asset_type')
|
||||
VALUES(?,?)
|
||||
""", to_insert)
|
||||
|
||||
def _write_equities(self, equities, db_conn):
|
||||
|
||||
# Apply fuzzy matching.
|
||||
@@ -181,8 +193,14 @@ class AssetDBWriter(with_metaclass(ABCMeta)):
|
||||
equities['fuzzy'] = equities['symbol'].str.\
|
||||
replace(self.fuzzy_char, '')
|
||||
|
||||
# Retrieve the data to add to the equitites table
|
||||
data = [tuple(x) for x in equities.to_records()]
|
||||
|
||||
# Retrieve the data to add to the asset_router table
|
||||
sids = [x[0] for x in data]
|
||||
eqs = ['equity'] * len(sids)
|
||||
to_insert = zip(sids, eqs)
|
||||
|
||||
c = db_conn.cursor()
|
||||
c.executemany("""
|
||||
INSERT OR IGNORE INTO equities
|
||||
@@ -191,6 +209,12 @@ class AssetDBWriter(with_metaclass(ABCMeta)):
|
||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""", data)
|
||||
|
||||
c.executemany("""
|
||||
INSERT INTO asset_router
|
||||
('sid', 'asset_type')
|
||||
VALUES(?,?)
|
||||
""", to_insert)
|
||||
|
||||
def init_db(self,
|
||||
db_conn,
|
||||
constraints=False):
|
||||
|
||||
Reference in New Issue
Block a user