Commit 3bb9d66d authored by Dr.李's avatar Dr.李

update model

parent d46f2ebf
...@@ -5,7 +5,7 @@ Created on 2017-6-29 ...@@ -5,7 +5,7 @@ Created on 2017-6-29
@author: cheng.li @author: cheng.li
""" """
from sqlalchemy import BigInteger, Column, DateTime, Float, Index, Integer, JSON, String, Text, Table from sqlalchemy import BigInteger, Column, DateTime, Float, Index, Integer, JSON, String, Text, Boolean
from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base() Base = declarative_base()
...@@ -1707,6 +1707,10 @@ class DailyPortfolios(Base): ...@@ -1707,6 +1707,10 @@ class DailyPortfolios(Base):
portfolio_name = Column(String(50), primary_key=True, nullable=False) portfolio_name = Column(String(50), primary_key=True, nullable=False)
code = Column(BigInteger, primary_key=True, nullable=False) code = Column(BigInteger, primary_key=True, nullable=False)
weight = Column(Float(53), nullable=False) weight = Column(Float(53), nullable=False)
er = Column(Float(53), nullable=False)
industry = Column(String(50), nullable=False)
benchmark_weight = Column(Float(53), nullable=False)
is_tradable = Column(Boolean, nullable=False)
class PortfolioSettings(Base): class PortfolioSettings(Base):
......
...@@ -535,20 +535,16 @@ class SqlEngine(object): ...@@ -535,20 +535,16 @@ class SqlEngine(object):
def fetch_model(self, def fetch_model(self,
ref_date, ref_date,
portfolio=None,
model_type=None, model_type=None,
version=None) -> pd.DataFrame: model_version=None) -> pd.DataFrame:
conditions = [Models.trade_date == ref_date] conditions = [Models.trade_date == ref_date]
if portfolio:
conditions.append(Models.portfolio_name == portfolio)
if model_type: if model_type:
conditions.append(Models.model_type == model_type) conditions.append(Models.model_type == model_type)
if version: if model_version:
conditions.append(Models.version == version) conditions.append(Models.model_version == model_version)
query = select([Models]).where(and_(*conditions)) query = select([Models]).where(and_(*conditions))
......
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