Commit c19f7bb1 authored by Dr.李's avatar Dr.李

update db models

parent 712a47a8
...@@ -12,6 +12,19 @@ Base = declarative_base() ...@@ -12,6 +12,19 @@ Base = declarative_base()
metadata = Base.metadata metadata = Base.metadata
class Categories(Base):
__tablename__ = 'categories'
__table_args__ = (
Index('categories_pk', 'trade_date', 'code', unique=True),
)
trade_date = Column(DateTime, primary_key=True, nullable=False)
code = Column(BigInteger, primary_key=True, nullable=False)
sw1 = Column(Integer)
sw1_adj = Column(Integer)
class DailyPortfolios(Base): class DailyPortfolios(Base):
__tablename__ = 'daily_portfolios' __tablename__ = 'daily_portfolios'
__table_args__ = ( __table_args__ = (
...@@ -301,21 +314,6 @@ class PortfolioSettings(Base): ...@@ -301,21 +314,6 @@ class PortfolioSettings(Base):
weight = Column(Float(53), nullable=False) weight = Column(Float(53), nullable=False)
class Positions(Base):
__tablename__ = 'positions'
__table_args__ = (
Index('positions_idx', 'trade_date', 'source', 'universe', 'benchmark', 'portfolio', 'type', unique=True),
)
source = Column(String(50), primary_key=True, nullable=False)
universe = Column(String(50), primary_key=True, nullable=False)
benchmark = Column(Integer, primary_key=True, nullable=False)
trade_date = Column(DateTime, primary_key=True, nullable=False)
portfolio = Column(String(50), primary_key=True, nullable=False)
type = Column(String(50), primary_key=True, nullable=False)
weight = Column(JSON)
class RebalanceLog(Base): class RebalanceLog(Base):
__tablename__ = 'rebalance_log' __tablename__ = 'rebalance_log'
__table_args__ = ( __table_args__ = (
...@@ -1316,5 +1314,5 @@ class Outright(Base): ...@@ -1316,5 +1314,5 @@ class Outright(Base):
if __name__ == '__main__': if __name__ == '__main__':
from sqlalchemy import create_engine from sqlalchemy import create_engine
engine = create_engine('postgres+psycopg2://postgres:we083826@192.168.0.102/alpha') engine = create_engine('postgres+psycopg2://postgres:A12345678!@10.63.6.220/alpha')
Base.metadata.create_all(engine) Base.metadata.create_all(engine)
...@@ -32,7 +32,6 @@ from alphamind.data.dbmodel.models import Universe as UniverseTable ...@@ -32,7 +32,6 @@ from alphamind.data.dbmodel.models import Universe as UniverseTable
from alphamind.data.dbmodel.models import Formulas from alphamind.data.dbmodel.models import Formulas
from alphamind.data.dbmodel.models import DailyPortfoliosSchedule from alphamind.data.dbmodel.models import DailyPortfoliosSchedule
from alphamind.data.dbmodel.models import Performance from alphamind.data.dbmodel.models import Performance
from alphamind.data.dbmodel.models import Positions
from alphamind.data.dbmodel.models import Outright from alphamind.data.dbmodel.models import Outright
from alphamind.data.dbmodel.models import RiskExposure from alphamind.data.dbmodel.models import RiskExposure
from alphamind.data.transformer import Transformer from alphamind.data.transformer import Transformer
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment