class Classify(db.Model): """ create table if not exists `fund_classify`( `ID` int not null primary key auto_increment, `WINDCODE` char(10) not null, `FUND_SETUPDATE` datetime comment "报告期" not null, `BRANCH` char(10) not null, `CLASSIFY` char(20) not null, `UPDATE_DATE` datetime not null ); """ __tablename__ = 'fund_classify' id = db.Column(db.Integer, primary_key=True) windcode = db.Column(db.String(10)) fund_setupdate = db.Column(db.DATETIME) branch = db.Column(db.String(10)) classify = db.Column(db.String(20)) update_date = db.Column(db.DATETIME) def __repr__(self): return f"<Classify {self.windcode}>" def to_dict(self): items = self.__dict__ json = {} for k, v in items.items(): if k != "_sa_instance_state": json[k] = v return json
class Indicators(db.Model, ModelToDict): """ CREATE TABLE `indicators` ( `id` int(11) NOT NULL AUTO_INCREMENT, `windcode` varchar(10) NOT NULL COMMENT '证券代码', `indicator` varchar(50) NOT NULL COMMENT '指标', `numeric` double DEFAULT NULL COMMENT '数字型指标值', `text` text COMMENT '文本型指标值', `note` varchar(20) DEFAULT NULL COMMENT '对指标的解释', `rpt_date` datetime NOT NULL COMMENT '报告期', `update_date` datetime NOT NULL COMMENT '更新日期', PRIMARY KEY (`id`), UNIQUE KEY `IDX_CODE_IND_NOTE_UPDATE` (`windcode`,`indicator`,`update_date`,`note`) ) ENGINE=InnoDB AUTO_INCREMENT=188041 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; """ __tablename__ = "indicators" id = db.Column(db.Integer, primary_key=True, autoincrement=True) windcode = db.Column(db.String(10), nullable=False) indicator = db.Column(db.String(50), nullable=False) numeric = db.Column(DOUBLE) text = db.Column(db.Text) note = db.Column(db.String(20)) rpt_date = db.Column(db.DateTime, nullable=False) update_date = db.Column(db.DateTime, nullable=False) def __repr__(self): return f"<Indicators {self.windcode}>"
class FundPerformance(db.Model): __tablename__ = 'fs_fund_performance' id = db.Column(db.Integer, primary_key=True, nullable=False) windcode = db.Column(db.String(10), nullable=False, index=True) indicator = db.Column(db.String(20), nullable=False) numeric = db.Column(db.Float) update_date = db.Column(db.DateTime, nullable=False) def __repr__(self): return f"<FundPerformance {self.windcode}>"
class FundManager(db.Model): __tablename__ = 'fs_fund_manager' id = db.Column(db.Integer, primary_key=True, nullable=False) windcode = db.Column(db.String(10), nullable=False, index=True) fund_fundmanager = db.Column(db.String(20), name="fund_fundmanager") fund_predfundmanager = db.Column(db.TEXT, name="fund_predfundmanager") fund_corp_fundmanagementcompany = db.Column(db.String(20)) update_date = db.Column(db.DateTime) def __repr__(self): return f"<FundManager {self.windcode}>"
class News(db.Model, ModelToDict): __tablename__ = 'finance_news' id = db.Column(db.Integer, primary_key=True, autoincrement=True) title = db.Column(db.String(200), nullable=False, unique=True, index=True) abstract = db.Column(db.TEXT) url = db.Column(db.TEXT) source = db.Column(db.String(20)) savedate = db.Column(db.DateTime) keyword = db.Column(db.String(20)) def __repr__(self): return f"<News {self.title}>"
class Style(db.Model): __tablename__ = "t_ff_style" id = db.Column(db.Integer, primary_key=True, autoincrement=True) windcode = db.Column(db.String(12), index=True) small_value = db.Column(db.Float) small_growth = db.Column(db.Float) mid_value = db.Column(db.Float) mid_growth = db.Column(db.Float) large_value = db.Column(db.Float) large_growth = db.Column(db.Float) bond = db.Column(db.Float) value_date = db.Column(db.Date) freq = db.Column(db.String(2)) def __repr__(self): return f"<Style {self.windcode}>"
class Portfolio(db.Model): __tablename__ = "t_ff_portfolio" port_id = db.Column(db.Integer, primary_key=True, nullable=False) port_name = db.Column(db.String(30), nullable=False) port_type = db.Column(db.Integer, nullable=False) def __repr__(self): return f"<Portfolio {self.port_name}>"
class FundManagerExtend(db.Model): __tablename__ = 'fs_fund_manager_extend' id = db.Column(db.Integer, primary_key=True, nullable=False) windcode = db.Column(db.String(10), db.ForeignKey("fs_fund_manager.windcode"), nullable=False, index=True) fund_manager_totalnetasset = db.Column(db.Float) fund_manager_resume = db.Column(db.Text) fund_manager_gender = db.Column(db.String(2)) nav_periodicannualizedreturn = db.Column(db.Float) rank = db.Column(db.Integer) update_date = db.Column(db.DateTime) managers = db.relationship('FundManager', backref="manager_info") def __repr__(self): return f"<FundManagerExtend {self.windcode}>"
class PortfolioCore(db.Model): __tablename__ = "portfolio_core" id = db.Column(db.Integer, primary_key=True, nullable=False) port_id = db.Column(db.Integer, db.ForeignKey("portfolio.port_id"), nullable=False) windcode = db.Column(db.String(12), nullable=False) update_date = db.Column(db.DateTime, nullable=False) portfolio = db.relationship("Portfolio", backref="core") def __repr__(self): return f"<PortfolioObserve {self.port_id}>"
class BasicInfo(db.Model): """ create table if not exists `bond_basic_info`( `ID` int not null primary key auto_increment, `WINDCODE` char(10) not null, `SEC_NAME` char(50) not null, `FUND_FULLNAME` char(100) not null, `FUND_BENCHMARK` text, `FUND_INVESTSCOPE` text, `FUND_STRUCTUREDFUNDORNOT` char(2), `FUND_SETUPDATE` datetime, `FUND_FIRSTINVESTTYPE` char(25), `FUND_INVESTTYPE` char(25), `TYPE` char(5) not null, `KIND_I` char(20), `KIND_II` char(20) ); """ __tablename__ = "basic_info" id = db.Column(db.Integer, primary_key=True) windcode = db.Column(db.String(10)) sec_name = db.Column(db.String(50)) fund_fullname = db.Column(db.String(100)) fund_benchmark = db.Column(db.TEXT) fund_investscope = db.Column(db.TEXT) fund_structuredfundornot = db.Column(db.String(2)) fund_setupdate = db.Column(db.DATETIME) fund_firstinvesttype = db.Column(db.String(25)) fund_investtype = db.Column(db.String(25)) type = db.Column(db.String(5)) kind_i = db.Column(db.String(20)) kind_ii = db.Column(db.String(20)) def __repr__(self): return f"<BasicInfo {self.sec_name}>" def to_dict(self): items = self.__dict__ json = {} for k, v in items.items(): if k != "_sa_instance_state": json[k] = v return json
class IndicatorsForPlot(db.Model, ModelToDict): """ CREATE TABLE `indicators_for_plot` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `WINDCODE` char(10) NOT NULL, `FUND_SETUPDATE` datetime NOT NULL COMMENT '基金成立日期', `FUND_MGRCOMP` varchar(100) NOT NULL COMMENT '基金管理人', `FUND_CORP_FUNDMANAGEMENTCOMPANY` varchar(25) DEFAULT NULL COMMENT '基金公司简称', `FUND_PCHMSTATUS` char(10) DEFAULT NULL COMMENT '基金申购状态', `FUND_FUNDSCALE` double DEFAULT NULL COMMENT '基金规模', `PRT_NETASSET` double DEFAULT NULL COMMENT '基金净值', `FUND_MANAGEMENTFEERATIO` double DEFAULT NULL COMMENT '管理费率%', `FUND_PURCHASEFEE` text COMMENT '申购费', `FUND_REDEMPTIONFEE` text COMMENT '赎回费', `RPT_DATE` datetime NOT NULL COMMENT '报告期', `UPDATE_DATE` datetime NOT NULL COMMENT '更新日期', PRIMARY KEY (`ID`), KEY `idx_code_date` (`WINDCODE`,`UPDATE_DATE`) ) ENGINE=InnoDB AUTO_INCREMENT=10339 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; """ __tablename__ = 'indicators_for_plot' ID = db.Column(db.Integer, primary_key=True, autoincrement=True) WINDCODE = db.Column(db.String(10), nullable=False) FUND_SETUPDATE = db.Column(db.DateTime, nullable=False) FUND_MGRCOMP = db.Column(db.String(100), nullable=False) FUND_CORP_FUNDMANAGEMENTCOMPANY = db.Column(db.String(25)) FUND_PCHMSTATUS = db.Column(db.String(10)) FUND_FUNDSCALE = db.Column(db.Float) PRT_NETASSET = db.Column(db.Float) FUND_MANAGEMENTFEERATIO = db.Column(db.Float) FUND_PURCHASEFEE = db.Column(db.TEXT) FUND_REDEMPTIONFEE = db.Column(db.TEXT) RPT_DATE = db.Column(db.DateTime) UPDATE_DATE = db.Column(db.DateTime) def __repr__(self): return f"<IndicatorsForPlot {self.WINDCODE}>"