modify scripts

This commit is contained in:
oscarz
2025-03-17 11:08:13 +08:00
parent e6327fbe73
commit f43cd53159
177 changed files with 5 additions and 178173 deletions

9
tushare/Dockerfile Normal file
View File

@ -0,0 +1,9 @@
FROM ubuntu:latest
WORKDIR /stock
RUN apt-get update
RUN apt-get install python3-pip
RUN pip3 install --upgrade pip
RUN pip install tushare -i https://pypi.tuna.tsinghua.edu.cn/simple
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
COPY . .

670
tushare/db/ddl.sql Normal file
View File

@ -0,0 +1,670 @@
-- stockdb.t_meta_film definition
CREATE TABLE `t_meta_film` (
`ts_code` varchar(32) NOT NULL DEFAULT '''''' COMMENT 'TS代码',
PRIMARY KEY (`ts_code`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- stockdb.t_meta_game definition
CREATE TABLE `t_meta_game` (
`ts_code` varchar(32) NOT NULL DEFAULT '''''' COMMENT 'TS代码',
PRIMARY KEY (`ts_code`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- stockdb.t_meta_kechuang_50 definition
CREATE TABLE `t_meta_kechuang_50` (
`ts_code` varchar(32) NOT NULL DEFAULT '''''' COMMENT 'TS代码',
PRIMARY KEY (`ts_code`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- stockdb.t_meta_kechuang_chip definition
CREATE TABLE `t_meta_kechuang_chip` (
`ts_code` varchar(32) NOT NULL DEFAULT '' COMMENT 'TS代码',
PRIMARY KEY (`ts_code`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- stockdb.t_ods_hs_base_ipo definition
CREATE TABLE `t_ods_hs_base_ipo` (
`ts_code` varchar(32) NOT NULL DEFAULT '' COMMENT 'TS代码',
`sub_code` varchar(32) DEFAULT '' COMMENT '申购代码',
`name` varchar(32) DEFAULT '' COMMENT '名称',
`ipo_date` varchar(32) DEFAULT '' COMMENT '上网发行日期',
`issue_date` varchar(32) DEFAULT '' COMMENT '上市日期',
`amount` float DEFAULT '0' COMMENT '发行总量(万股)',
`market_amount` float DEFAULT '0' COMMENT '上网发行总量(万股)',
`price` float DEFAULT '0' COMMENT '发行价格',
`pe` float DEFAULT '0' COMMENT '市盈率',
`limit_amount` float DEFAULT '0' COMMENT '个人申购上限(万股)',
`funds` float DEFAULT '0' COMMENT '募集资金(亿)',
`ballot` float DEFAULT '0' COMMENT '中签率',
PRIMARY KEY (`ts_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- stockdb.t_ods_hs_base_list definition
CREATE TABLE `t_ods_hs_base_list` (
`ts_code` varchar(32) NOT NULL DEFAULT '' COMMENT 'TS代码',
`symbol` varchar(32) DEFAULT '' COMMENT '股票代码',
`name` varchar(32) DEFAULT '' COMMENT '股票名称',
`area` varchar(32) DEFAULT '' COMMENT '地域',
`industry` varchar(32) DEFAULT '' COMMENT '所属行业',
`fullname` varchar(128) DEFAULT '' COMMENT '股票全称',
`enname` varchar(128) DEFAULT '' COMMENT '英文全称',
`cnspell` varchar(32) DEFAULT '' COMMENT '拼音缩写',
`market` varchar(32) DEFAULT '' COMMENT '市场类型',
`exchange` varchar(32) DEFAULT '' COMMENT '交易所代码',
`curr_type` varchar(32) DEFAULT '' COMMENT '交易货币',
`list_status` varchar(32) DEFAULT '' COMMENT '上市状态 L上市 D退市 P暂停上市',
`list_date` varchar(32) DEFAULT '' COMMENT '上市日期',
`delist_date` varchar(32) DEFAULT '' COMMENT '退市日期',
`is_hs` varchar(32) DEFAULT '' COMMENT '是否沪深港通标的N否 H沪股通 S深股通',
PRIMARY KEY (`ts_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- stockdb.t_ods_hs_daily_basic definition
CREATE TABLE `t_ods_hs_daily_basic` (
`ts_code` varchar(32) NOT NULL DEFAULT '' COMMENT 'TS代码',
`trade_date` varchar(32) NOT NULL DEFAULT '' COMMENT '交易日期',
`close` decimal(19,4) DEFAULT '0.0000' COMMENT '当日收盘价',
`turnover_rate` decimal(19,4) DEFAULT '0.0000' COMMENT '换手率',
`turnover_rate_f` decimal(19,4) DEFAULT '0.0000' COMMENT '换手率(自由流通股)',
`volume_ratio` decimal(19,4) DEFAULT '0.0000' COMMENT '量比',
`pe` decimal(19,4) DEFAULT '0.0000' COMMENT '市盈率(总市值/净利润)',
`pe_ttm` decimal(19,4) DEFAULT '0.0000' COMMENT '市盈率TTM',
`pb` decimal(19,4) DEFAULT '0.0000' COMMENT '市净率(总市值/净资产)',
`ps` decimal(19,4) DEFAULT '0.0000' COMMENT '市销率',
`ps_ttm` decimal(19,4) DEFAULT '0.0000' COMMENT '市销率TTM',
`dv_ratio` decimal(19,4) DEFAULT '0.0000' COMMENT '股息率(%',
`dv_ttm` decimal(19,4) DEFAULT '0.0000' COMMENT '股息率TTM',
`total_share` decimal(19,4) DEFAULT '0.0000' COMMENT '总股本(万股)',
`float_share` decimal(19,4) DEFAULT '0.0000' COMMENT '流通股本(万股)',
`free_share` decimal(19,4) DEFAULT '0.0000' COMMENT '自由流通股本(万股)',
`total_mv` decimal(22,4) DEFAULT '0.0000' COMMENT '总市值(万元)',
`circ_mv` decimal(22,4) DEFAULT '0.0000' COMMENT '流通市值(万元)',
`limit_status` int(11) DEFAULT '0' COMMENT '涨跌停状态',
PRIMARY KEY (`ts_code`,`trade_date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- stockdb.t_ods_hs_finance_balance definition
CREATE TABLE `t_ods_hs_finance_balance` (
`ts_code` varchar(32) NOT NULL DEFAULT '' COMMENT 'TS股票代码',
`ann_date` varchar(32) NOT NULL DEFAULT '' COMMENT '公告日期',
`f_ann_date` varchar(32) NOT NULL DEFAULT '' COMMENT '实际公告日期',
`end_date` varchar(32) NOT NULL DEFAULT '' COMMENT '报告期',
`report_type` varchar(32) DEFAULT '' COMMENT '报告类型',
`comp_type` varchar(32) DEFAULT '' COMMENT '公司类型(1一般工商业2银行3保险4证券)',
`end_type` varchar(32) DEFAULT '' COMMENT '报告期类型',
`total_share` decimal(19,2) DEFAULT '0.00' COMMENT '期末总股本',
`cap_rese` decimal(19,2) DEFAULT '0.00' COMMENT '资本公积金',
`undistr_porfit` decimal(19,2) DEFAULT '0.00' COMMENT '未分配利润',
`surplus_rese` decimal(19,2) DEFAULT '0.00' COMMENT '盈余公积金',
`special_rese` decimal(19,2) DEFAULT '0.00' COMMENT '专项储备',
`money_cap` decimal(19,2) DEFAULT '0.00' COMMENT '货币基金',
`trad_asset` decimal(19,2) DEFAULT '0.00' COMMENT '交易性金融资产',
`notes_receiv` decimal(19,2) DEFAULT '0.00' COMMENT '应收票据',
`accounts_receiv` decimal(19,2) DEFAULT '0.00' COMMENT '应收账款',
`oth_receiv` decimal(19,2) DEFAULT '0.00' COMMENT '其它应收款',
`prepayment` decimal(19,2) DEFAULT '0.00' COMMENT '预付款项',
`div_receiv` decimal(19,2) DEFAULT '0.00' COMMENT '应收股利',
`int_receiv` decimal(19,2) DEFAULT '0.00' COMMENT '应收利息',
`inventories` decimal(19,2) DEFAULT '0.00' COMMENT '存货',
`amor_exp` decimal(19,2) DEFAULT '0.00' COMMENT '长期待摊费用',
`nca_within_1y` decimal(19,2) DEFAULT '0.00' COMMENT '一年内到期的非流动资产',
`sett_rsrv` decimal(19,2) DEFAULT '0.00' COMMENT '结算备付金',
`loanto_oth_bank_fi` decimal(19,2) DEFAULT '0.00' COMMENT '拆出资金',
`premium_receiv` decimal(19,2) DEFAULT '0.00' COMMENT '应收保费',
`reinsur_receiv` decimal(19,2) DEFAULT '0.00' COMMENT '应收分保账款',
`reinsur_res_receiv` decimal(19,2) DEFAULT '0.00' COMMENT '应收分保合同准备金',
`pur_resale_fa` decimal(19,2) DEFAULT '0.00' COMMENT '买入返售金融资产',
`oth_cur_assets` decimal(19,2) DEFAULT '0.00' COMMENT '其它流动资产',
`total_cur_assets` decimal(19,2) DEFAULT '0.00' COMMENT '流动资产合计',
`fa_avail_for_sale` decimal(19,2) DEFAULT '0.00' COMMENT '可供出售金融资产',
`htm_invest` decimal(19,2) DEFAULT '0.00' COMMENT '持有至到期投资',
`lt_eqt_invest` decimal(19,2) DEFAULT '0.00' COMMENT '长期股权投资',
`invest_real_estate` decimal(19,2) DEFAULT '0.00' COMMENT '投资性房地产',
`time_deposits` decimal(19,2) DEFAULT '0.00' COMMENT '定期存款',
`oth_assets` decimal(19,2) DEFAULT '0.00' COMMENT '其它资产',
`lt_rec` decimal(19,2) DEFAULT '0.00' COMMENT '长期应收款',
`fix_assets` decimal(19,2) DEFAULT '0.00' COMMENT '固定资产',
`cip` decimal(19,2) DEFAULT '0.00' COMMENT '在建工程',
`const_materials` decimal(19,2) DEFAULT '0.00' COMMENT '工程物资',
`fixed_assets_disp` decimal(19,2) DEFAULT '0.00' COMMENT '固定资产清理',
`produc_bio_assets` decimal(19,2) DEFAULT '0.00' COMMENT '生产性生物资产',
`oil_and_gas_assets` decimal(19,2) DEFAULT '0.00' COMMENT '油气资产',
`intan_assets` decimal(19,2) DEFAULT '0.00' COMMENT '无形资产',
`r_and_d` decimal(19,2) DEFAULT '0.00' COMMENT '研发支出',
`goodwill` decimal(19,2) DEFAULT '0.00' COMMENT '商誉',
`lt_amor_exp` decimal(19,2) DEFAULT '0.00' COMMENT '长期待摊费用',
`defer_tax_assets` decimal(19,2) DEFAULT '0.00' COMMENT '递延所得税资产',
`decr_in_disbur` decimal(19,2) DEFAULT '0.00' COMMENT '发放贷款及垫款',
`oth_nca` decimal(19,2) DEFAULT '0.00' COMMENT '其他非流动资产',
`total_nca` decimal(19,2) DEFAULT '0.00' COMMENT '非流动资产合计',
`cash_reser_cb` decimal(19,2) DEFAULT '0.00' COMMENT '现金及存放中央银行款项',
`depos_in_oth_bfi` decimal(19,2) DEFAULT '0.00' COMMENT '存放同业和其它金融机构款项',
`prec_metals` decimal(19,2) DEFAULT '0.00' COMMENT '贵金属',
`deriv_assets` decimal(19,2) DEFAULT '0.00' COMMENT '衍生金融资产',
`rr_reins_une_prem` decimal(19,2) DEFAULT '0.00' COMMENT '应收分保未到期责任准备金',
`rr_reins_outstd_cla` decimal(19,2) DEFAULT '0.00' COMMENT '应收分保未决赔款准备金',
`rr_reins_lins_liab` decimal(19,2) DEFAULT '0.00' COMMENT '应收分保寿险责任准备金',
`rr_reins_lthins_liab` decimal(19,2) DEFAULT '0.00' COMMENT '应收分保长期健康险责任准备金',
`refund_depos` decimal(19,2) DEFAULT '0.00' COMMENT '存出保证金',
`ph_pledge_loans` decimal(19,2) DEFAULT '0.00' COMMENT '保户质押贷款',
`refund_cap_depos` decimal(19,2) DEFAULT '0.00' COMMENT '存出资本保证金',
`indep_acct_assets` decimal(19,2) DEFAULT '0.00' COMMENT '独立账户资产',
`client_depos` decimal(19,2) DEFAULT '0.00' COMMENT '其中:客户资金存款',
`client_prov` decimal(19,2) DEFAULT '0.00' COMMENT '其中:客户备付金',
`transac_seat_fee` decimal(19,2) DEFAULT '0.00' COMMENT '其中:交易席位费',
`invest_as_receiv` decimal(19,2) DEFAULT '0.00' COMMENT '营收款项类投资',
`total_assets` decimal(19,2) DEFAULT '0.00' COMMENT '资产总计',
`lt_borr` decimal(19,2) DEFAULT '0.00' COMMENT '长期借款',
`st_borr` decimal(19,2) DEFAULT '0.00' COMMENT '短期借款',
`cb_borr` decimal(19,2) DEFAULT '0.00' COMMENT '向中央银行借款',
`depos_ib_deposits` decimal(19,2) DEFAULT '0.00' COMMENT '吸收存款及同业存放',
`loan_oth_bank` decimal(19,2) DEFAULT '0.00' COMMENT '拆入资金',
`trading_fl` decimal(19,2) DEFAULT '0.00' COMMENT '交易性金融负债',
`notes_payable` decimal(19,2) DEFAULT '0.00' COMMENT '应付票据',
`acct_payable` decimal(19,2) DEFAULT '0.00' COMMENT '应付账款',
`adv_receipts` decimal(19,2) DEFAULT '0.00' COMMENT '预收款项',
`sold_for_repur_fa` decimal(19,2) DEFAULT '0.00' COMMENT '卖出回购金融资产款',
`comm_payable` decimal(19,2) DEFAULT '0.00' COMMENT '应付手续费及佣金',
`payroll_payable` decimal(19,2) DEFAULT '0.00' COMMENT '应付职工薪酬',
`taxes_payable` decimal(19,2) DEFAULT '0.00' COMMENT '应缴税费',
`int_payable` decimal(19,2) DEFAULT '0.00' COMMENT '应付利息',
`div_payable` decimal(19,2) DEFAULT '0.00' COMMENT '应付股利',
`oth_payable` decimal(19,2) DEFAULT '0.00' COMMENT '其它应付款',
`acc_exp` decimal(19,2) DEFAULT '0.00' COMMENT '预提费用',
`deferred_inc` decimal(19,2) DEFAULT '0.00' COMMENT '递延收益',
`st_bonds_payable` decimal(19,2) DEFAULT '0.00' COMMENT '应付短期债券',
`payable_to_reinsurer` decimal(19,2) DEFAULT '0.00' COMMENT '应付分保账款',
`rsrv_insur_cont` decimal(19,2) DEFAULT '0.00' COMMENT '保险合同准备金',
`acting_trading_sec` decimal(19,2) DEFAULT '0.00' COMMENT '代理买卖证券款',
`acting_uw_sec` decimal(19,2) DEFAULT '0.00' COMMENT '代理承销证券款',
`non_cur_liab_due_1y` decimal(19,2) DEFAULT '0.00' COMMENT '一年内到期的非流动负债',
`oth_cur_liab` decimal(19,2) DEFAULT '0.00' COMMENT '其它流动负债',
`total_cur_liab` decimal(19,2) DEFAULT '0.00' COMMENT '流动负债合计',
`bond_payable` decimal(19,2) DEFAULT '0.00' COMMENT '应付债券',
`lt_payable` decimal(19,2) DEFAULT '0.00' COMMENT '长期应付款',
`specific_payables` decimal(19,2) DEFAULT '0.00' COMMENT '专项应付款',
`estimated_liab` decimal(19,2) DEFAULT '0.00' COMMENT '预计负债',
`defer_tax_liab` decimal(19,2) DEFAULT '0.00' COMMENT '递延所得税负债',
`defer_inc_non_cur_liab` decimal(19,2) DEFAULT '0.00' COMMENT '递延收益-非流动负债',
`oth_ncl` decimal(19,2) DEFAULT '0.00' COMMENT '其它非流动负债',
`total_ncl` decimal(19,2) DEFAULT '0.00' COMMENT '非流动负债合计',
`depos_oth_bfi` decimal(19,2) DEFAULT '0.00' COMMENT '同业和其它金融机构存放款项',
`deriv_liab` decimal(19,2) DEFAULT '0.00' COMMENT '衍生金融负债',
`depos` decimal(19,2) DEFAULT '0.00' COMMENT '吸收存款',
`agency_bus_liab` decimal(19,2) DEFAULT '0.00' COMMENT '代理业务负债',
`oth_liab` decimal(19,2) DEFAULT '0.00' COMMENT '其它负债',
`prem_receiv_adva` decimal(19,2) DEFAULT '0.00' COMMENT '预收保费',
`depos_received` decimal(19,2) DEFAULT '0.00' COMMENT '存入保证金',
`ph_invest` decimal(19,2) DEFAULT '0.00' COMMENT '保户储金及投资款',
`reser_une_prem` decimal(19,2) DEFAULT '0.00' COMMENT '未到期责任准备金',
`reser_outstd_claims` decimal(19,2) DEFAULT '0.00' COMMENT '未决赔款准备金',
`reser_lins_liab` decimal(19,2) DEFAULT '0.00' COMMENT '寿险责任准备金',
`reser_lthins_liab` decimal(19,2) DEFAULT '0.00' COMMENT '长期健康险责任准备金',
`indept_acc_liab` decimal(19,2) DEFAULT '0.00' COMMENT '独立账户负债',
`pledge_borr` decimal(19,2) DEFAULT '0.00' COMMENT '其中:质押借款',
`indem_payable` decimal(19,2) DEFAULT '0.00' COMMENT '应付赔付款',
`policy_div_payable` decimal(19,2) DEFAULT '0.00' COMMENT '应付保单红利',
`total_liab` decimal(19,2) DEFAULT '0.00' COMMENT '负债合计',
`treasury_share` decimal(19,2) DEFAULT '0.00' COMMENT '减:库存股',
`ordin_risk_reser` decimal(19,2) DEFAULT '0.00' COMMENT '一般风险准备',
`forex_differ` decimal(19,2) DEFAULT '0.00' COMMENT '外币报表折算差额',
`invest_loss_unconf` decimal(19,2) DEFAULT '0.00' COMMENT '未确认的投资损失',
`minority_int` decimal(19,2) DEFAULT '0.00' COMMENT '少数股东权益',
`total_hldr_eqy_exc_min_int` decimal(19,2) DEFAULT '0.00' COMMENT '股东权益合计(不含少数股东权益)',
`total_hldr_eqy_inc_min_int` decimal(19,2) DEFAULT '0.00' COMMENT '股东权益合计(含少数股东权益)',
`total_liab_hldr_eqy` decimal(19,2) DEFAULT '0.00' COMMENT '负债及股东权益总计',
`lt_payroll_payable` decimal(19,2) DEFAULT '0.00' COMMENT '长期应付职工薪酬',
`oth_comp_income` decimal(19,2) DEFAULT '0.00' COMMENT '其它综合收益',
`oth_eqt_tools` decimal(19,2) DEFAULT '0.00' COMMENT '其它权益工具',
`oth_eqt_tools_p_shr` decimal(19,2) DEFAULT '0.00' COMMENT '其它权益工具(优先股)',
`lending_funds` decimal(19,2) DEFAULT '0.00' COMMENT '融出资金',
`acc_receivable` decimal(19,2) DEFAULT '0.00' COMMENT '应收款项',
`st_fin_payable` decimal(19,2) DEFAULT '0.00' COMMENT '应付短期融资款',
`payables` decimal(19,2) DEFAULT '0.00' COMMENT '应付款项',
`hfs_assets` decimal(19,2) DEFAULT '0.00' COMMENT '持有代售的资产',
`hfs_sales` decimal(19,2) DEFAULT '0.00' COMMENT '持有代售的负债',
`cost_fin_assets` decimal(19,2) DEFAULT '0.00' COMMENT '以摊余成本计量的金融资产',
`fair_value_fin_assets` decimal(19,2) DEFAULT '0.00' COMMENT '以公允价值计量且其变动计入其他综合收益的金融资产',
`contract_assets` decimal(19,2) DEFAULT '0.00' COMMENT '合同资产',
`contract_liab` decimal(19,2) DEFAULT '0.00' COMMENT '合同负债',
`accounts_receiv_bill` decimal(19,2) DEFAULT '0.00' COMMENT '应收票据及应收账款',
`accounts_pay` decimal(19,2) DEFAULT '0.00' COMMENT '应付票据及应付账款',
`oth_rcv_total` decimal(19,2) DEFAULT '0.00' COMMENT '其它应收款(合计)(元)',
`fix_assets_total` decimal(19,2) DEFAULT '0.00' COMMENT '固定资产(合计)(元)',
`cip_total` decimal(19,2) DEFAULT '0.00' COMMENT '在建工程(合计)(元)',
`oth_pay_total` decimal(19,2) DEFAULT '0.00' COMMENT '其它应付款(合计)(元)',
`long_pay_total` decimal(19,2) DEFAULT '0.00' COMMENT '长期应付款(合计)(元)',
`debt_invest` decimal(19,2) DEFAULT '0.00' COMMENT '债券投资(元)',
`oth_debt_invest` decimal(19,2) DEFAULT '0.00' COMMENT '其它债券投资(元)',
`oth_eq_invest` decimal(19,2) DEFAULT '0.00' COMMENT '其它权益工具投资(元)',
`oth_illiq_fin_assets` decimal(19,2) DEFAULT '0.00' COMMENT '其它非流动金融资产(元)',
`oth_eq_ppbond` decimal(19,2) DEFAULT '0.00' COMMENT '其它权益工具:永续债(元)',
`receiv_financing` decimal(19,2) DEFAULT '0.00' COMMENT '应收款项融资',
`use_right_assets` decimal(19,2) DEFAULT '0.00' COMMENT '使用权资产',
`lease_liab` decimal(19,2) DEFAULT '0.00' COMMENT '租赁负债',
`update_flag` varchar(32) NOT NULL DEFAULT '' COMMENT '更新标志',
PRIMARY KEY (`ts_code`,`ann_date`,`f_ann_date`,`end_date`,`update_flag`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- stockdb.t_ods_hs_finance_cashflow definition
CREATE TABLE `t_ods_hs_finance_cashflow` (
`ts_code` varchar(32) NOT NULL DEFAULT '' COMMENT 'TS股票代码',
`ann_date` varchar(32) NOT NULL DEFAULT '' COMMENT '公告日期',
`f_ann_date` varchar(32) NOT NULL DEFAULT '' COMMENT '实际公告日期',
`end_date` varchar(32) NOT NULL DEFAULT '' COMMENT '报告期',
`report_type` varchar(32) DEFAULT '' COMMENT '报告类型',
`comp_type` varchar(32) DEFAULT '' COMMENT '公司类型(1一般工商业2银行3保险4证券)',
`end_type` varchar(32) DEFAULT '' COMMENT '报告期类型',
`net_profit` decimal(19,2) DEFAULT '0.00' COMMENT '净利润',
`finan_exp` decimal(19,2) DEFAULT '0.00' COMMENT '财务费用',
`c_fr_sale_sg` decimal(19,2) DEFAULT '0.00' COMMENT '销售商品、提供劳务收到的现金',
`recp_tax_rends` decimal(19,2) DEFAULT '0.00' COMMENT '收到的税费返还',
`n_depos_incr_fi` decimal(19,2) DEFAULT '0.00' COMMENT '客户存款和同业存放款项净增加额',
`n_incr_loans_cb` decimal(19,2) DEFAULT '0.00' COMMENT '向中央银行借款净增加额',
`n_inc_borr_oth_fi` decimal(19,2) DEFAULT '0.00' COMMENT '向其它金融机构拆入资金净增加额',
`prem_fr_orig_contr` decimal(19,2) DEFAULT '0.00' COMMENT '收到原保险合同保费取得的现金',
`n_incr_insured_dep` decimal(19,2) DEFAULT '0.00' COMMENT '保户储金净增加额',
`n_reinsur_prem` decimal(19,2) DEFAULT '0.00' COMMENT '收到再保业务现金净额',
`n_incr_disp_tfa` decimal(19,2) DEFAULT '0.00' COMMENT '处置交易性金融资产净增加额',
`ifc_cash_incr` decimal(19,2) DEFAULT '0.00' COMMENT '收取利息和手续费净增加额',
`n_incr_disp_faas` decimal(19,2) DEFAULT '0.00' COMMENT '处置可供出售金融资产净增加额',
`n_incr_loans_oth_bank` decimal(19,2) DEFAULT '0.00' COMMENT '拆入资金净增加额',
`n_cap_incr_repur` decimal(19,2) DEFAULT '0.00' COMMENT '回购业务资金净增加额',
`c_fr_oth_operate_a` decimal(19,2) DEFAULT '0.00' COMMENT '收到其他与经营活动有关的现金',
`c_inf_fr_operate_a` decimal(19,2) DEFAULT '0.00' COMMENT '经营活动现金流入小计',
`c_paid_goods_s` decimal(19,2) DEFAULT '0.00' COMMENT '购买商品、接受劳务支付的现金',
`c_paid_to_for_empl` decimal(19,2) DEFAULT '0.00' COMMENT '支付给职工以及为职工支付的现金',
`c_paid_for_taxes` decimal(19,2) DEFAULT '0.00' COMMENT '支付的各项税费',
`n_incr_clt_loan_adv` decimal(19,2) DEFAULT '0.00' COMMENT '客户贷款及垫款净增加额',
`n_incr_dep_cbob` decimal(19,2) DEFAULT '0.00' COMMENT '存放央行和同业款项净增加额',
`c_pay_claims_orig_inco` decimal(19,2) DEFAULT '0.00' COMMENT '支付原保险合同赔付款项的现金',
`pay_handling_chrg` decimal(19,2) DEFAULT '0.00' COMMENT '支付手续费的现金',
`pay_comm_insur_plcy` decimal(19,2) DEFAULT '0.00' COMMENT '支付保单红利的现金',
`oth_cash_pay_oper_act` decimal(19,2) DEFAULT '0.00' COMMENT '支付其他与经营活动有关的现金',
`st_cash_out_act` decimal(19,2) DEFAULT '0.00' COMMENT '经营活动现金流出小计',
`n_cashflow_act` decimal(19,2) DEFAULT '0.00' COMMENT '经营活动产生的现金流量净额',
`oth_recp_ral_inv_act` decimal(19,2) DEFAULT '0.00' COMMENT '收到其它与投资活动有关的现金',
`c_disp_withdrwl_invest` decimal(19,2) DEFAULT '0.00' COMMENT '收回投资收到的现金',
`c_recp_return_invest` decimal(19,2) DEFAULT '0.00' COMMENT '取得投资收益收到的现金',
`n_recp_disp_fiolta` decimal(19,2) DEFAULT '0.00' COMMENT '处置固定资产、无形资产和其他长期资产收回的现金净额',
`n_recp_disp_sobu` decimal(19,2) DEFAULT '0.00' COMMENT '处置子公司及其他营业单位收到的现金净额',
`stot_inflows_inv_act` decimal(19,2) DEFAULT '0.00' COMMENT '投资活动现金流入小计',
`c_pay_acq_const_fiolta` decimal(19,2) DEFAULT '0.00' COMMENT '购建固定资产、无形资产和其他长期资产支付的现金',
`c_paid_invest` decimal(19,2) DEFAULT '0.00' COMMENT '投资支付的现金',
`n_disp_subs_oth_biz` decimal(19,2) DEFAULT '0.00' COMMENT '取得子公司及其他营业单位支付的现金净额',
`oth_pay_ral_inv_act` decimal(19,2) DEFAULT '0.00' COMMENT '支付其他与投资活动有关的现金',
`n_incr_pledge_loan` decimal(19,2) DEFAULT '0.00' COMMENT '质押贷款净增加额',
`stot_out_inv_act` decimal(19,2) DEFAULT '0.00' COMMENT '投资活动现金流出小计',
`n_cashflow_inv_act` decimal(19,2) DEFAULT '0.00' COMMENT '投资活动产生的现金流量净额',
`c_recp_borrow` decimal(19,2) DEFAULT '0.00' COMMENT '取得借款收到的现金',
`proc_issue_bonds` decimal(19,2) DEFAULT '0.00' COMMENT '发行债券收到的现金',
`oth_cash_recp_ral_fnc_act` decimal(19,2) DEFAULT '0.00' COMMENT '收到其他与筹资活动有关的现金',
`stot_cash_in_fnc_act` decimal(19,2) DEFAULT '0.00' COMMENT '筹资活动现金流入小计',
`free_cashflow` decimal(19,2) DEFAULT '0.00' COMMENT '企业自由现金流量',
`c_prepay_amt_borr` decimal(19,2) DEFAULT '0.00' COMMENT '偿还债务支付的现金',
`c_pay_dist_dpcp_int_exp` decimal(19,2) DEFAULT '0.00' COMMENT '分配股利、利润或偿付利息支付的现金',
`incl_dvd_profit_paid_sc_ms` decimal(19,2) DEFAULT '0.00' COMMENT '其中:子公司支付给少数股东的股利、利润',
`oth_cashpay_ral_fnc_act` decimal(19,2) DEFAULT '0.00' COMMENT '支付其他与筹资活动有关的现金',
`stot_cashout_fnc_act` decimal(19,2) DEFAULT '0.00' COMMENT '筹资活动现金流出小计',
`n_cash_flows_fnc_act` decimal(19,2) DEFAULT '0.00' COMMENT '筹资活动产生的现金流量净额',
`eff_fx_flu_cash` decimal(19,2) DEFAULT '0.00' COMMENT '汇率变动对现金的影响',
`n_incr_cash_cash_equ` decimal(19,2) DEFAULT '0.00' COMMENT '现金及现金等价物净增加额',
`c_cash_equ_beg_period` decimal(19,2) DEFAULT '0.00' COMMENT '期初现金及现金等价物余额',
`c_cash_equ_end_period` decimal(19,2) DEFAULT '0.00' COMMENT '期末现金及现金等价物余额',
`c_recp_cap_contrib` decimal(19,2) DEFAULT '0.00' COMMENT '吸收投资收到的现金',
`incl_cash_rec_saims` decimal(19,2) DEFAULT '0.00' COMMENT '其中:子公司吸收少数股东投资收到的现金',
`uncon_invest_loss` decimal(19,2) DEFAULT '0.00' COMMENT '未确认投资损失',
`prov_depr_assets` decimal(19,2) DEFAULT '0.00' COMMENT '加:资产减值准备',
`depr_fa_coga_dpba` decimal(19,2) DEFAULT '0.00' COMMENT '固定资产折旧、油气资产折耗、生产性生物资产折旧',
`amort_intang_assets` decimal(19,2) DEFAULT '0.00' COMMENT '无形资产摊销',
`lt_amort_deferred_exp` decimal(19,2) DEFAULT '0.00' COMMENT '长期待摊费用摊销',
`decr_deferred_exp` decimal(19,2) DEFAULT '0.00' COMMENT '待摊费用减少',
`incr_acc_exp` decimal(19,2) DEFAULT '0.00' COMMENT '预提费用增加',
`loss_disp_fiolta` decimal(19,2) DEFAULT '0.00' COMMENT '处置固定、无形资产和其他长期资产的损失',
`loss_scr_fa` decimal(19,2) DEFAULT '0.00' COMMENT '固定资产报废损失',
`loss_fv_chg` decimal(19,2) DEFAULT '0.00' COMMENT '公允价值变动损失',
`invest_loss` decimal(19,2) DEFAULT '0.00' COMMENT '投资损失',
`decr_def_inc_tax_assets` decimal(19,2) DEFAULT '0.00' COMMENT '递延所得税资产减少',
`incr_def_inc_tax_liab` decimal(19,2) DEFAULT '0.00' COMMENT '递延所得税负债增加',
`decr_inventories` decimal(19,2) DEFAULT '0.00' COMMENT '存货的减少',
`decr_oper_payable` decimal(19,2) DEFAULT '0.00' COMMENT '经营性应收项目的减少',
`incr_oper_payable` decimal(19,2) DEFAULT '0.00' COMMENT '经营性应付项目的增加',
`others` decimal(19,2) DEFAULT '0.00' COMMENT '其他',
`im_net_cashflow_oper_act` decimal(19,2) DEFAULT '0.00' COMMENT '经营活动产生的现金流量净额(间接法)',
`conv_debt_into_cap` decimal(19,2) DEFAULT '0.00' COMMENT '债务转为资本',
`conv_copbonds_due_within_1y` decimal(19,2) DEFAULT '0.00' COMMENT '一年内到期的可转换公司债券',
`fa_fnc_leases` decimal(19,2) DEFAULT '0.00' COMMENT '融资租入固定资产',
`im_n_incr_cash_equ` decimal(19,2) DEFAULT '0.00' COMMENT '现金及现金等价物净增加额(间接法)',
`net_dism_capital_add` decimal(19,2) DEFAULT '0.00' COMMENT '拆出资金净增加额',
`net_cash_rece_sec` decimal(19,2) DEFAULT '0.00' COMMENT '代理买卖证券收到的现金净额(元)',
`credit_impa_loss` decimal(19,2) DEFAULT '0.00' COMMENT '信用减值损失',
`use_right_asset_dep` decimal(19,2) DEFAULT '0.00' COMMENT '使用权资产折旧',
`oth_loss_asset` decimal(19,2) DEFAULT '0.00' COMMENT '其他资产减值损失',
`end_bal_cash` decimal(19,2) DEFAULT '0.00' COMMENT '现金的期末余额',
`beg_bal_cash` decimal(19,2) DEFAULT '0.00' COMMENT '减:现金的期初余额',
`end_bal_cash_equ` decimal(19,2) DEFAULT '0.00' COMMENT '加:现金等价物的期末余额',
`beg_bal_cash_equ` decimal(19,2) DEFAULT '0.00' COMMENT '减:现金等价物的期初余额',
`update_flag` varchar(32) NOT NULL DEFAULT '' COMMENT '更新标志',
PRIMARY KEY (`ts_code`,`ann_date`,`f_ann_date`,`end_date`,`update_flag`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- stockdb.t_ods_hs_finance_income definition
CREATE TABLE `t_ods_hs_finance_income` (
`ts_code` varchar(32) NOT NULL DEFAULT '' COMMENT 'TS代码',
`ann_date` varchar(32) NOT NULL DEFAULT '' COMMENT '公告日期',
`f_ann_date` varchar(32) NOT NULL DEFAULT '' COMMENT '实际公告日期',
`end_date` varchar(32) NOT NULL DEFAULT '' COMMENT '报告期',
`report_type` varchar(16) DEFAULT '' COMMENT '报告类型',
`comp_type` varchar(16) DEFAULT '' COMMENT '公司类型(1一般工商业2银行3保险4证券)',
`end_type` varchar(32) DEFAULT '' COMMENT '报告期类型',
`basic_eps` decimal(19,2) DEFAULT '0.00' COMMENT '基本每股收益',
`diluted_eps` decimal(19,2) DEFAULT '0.00' COMMENT '稀释每股收益',
`total_revenue` decimal(19,2) DEFAULT '0.00' COMMENT '营业总收入',
`revenue` decimal(19,2) DEFAULT '0.00' COMMENT '营业收入',
`int_income` decimal(19,2) DEFAULT '0.00' COMMENT '利息收入',
`prem_earned` decimal(19,2) DEFAULT '0.00' COMMENT '已赚保费',
`comm_income` decimal(19,2) DEFAULT '0.00' COMMENT '手续费及佣金收入',
`n_commis_income` decimal(19,2) DEFAULT '0.00' COMMENT '手续费及佣金净收入',
`n_oth_income` decimal(19,2) DEFAULT '0.00' COMMENT '其它经营净收益',
`n_oth_b_income` decimal(19,2) DEFAULT '0.00' COMMENT '加:其它业务净收益',
`prem_income` decimal(19,2) DEFAULT '0.00' COMMENT '保险业务收入',
`out_prem` decimal(19,2) DEFAULT '0.00' COMMENT '减:分出保费',
`une_prem_reser` decimal(19,2) DEFAULT '0.00' COMMENT '提取未到期责任准备金',
`reins_income` decimal(19,2) DEFAULT '0.00' COMMENT '其中:分保费收入',
`n_sec_tb_income` decimal(19,2) DEFAULT '0.00' COMMENT '代理买卖证券业务净收入',
`n_sec_uw_income` decimal(19,2) DEFAULT '0.00' COMMENT '证券承销业务净收入',
`n_asset_mg_income` decimal(19,2) DEFAULT '0.00' COMMENT '受托客户资产管理业务净收入',
`oth_b_income` decimal(19,2) DEFAULT '0.00' COMMENT '其它业务收入',
`fv_value_chg_gain` decimal(19,2) DEFAULT '0.00' COMMENT '加:公允价值变动净收益',
`invest_income` decimal(19,2) DEFAULT '0.00' COMMENT '加:投资净收益',
`ass_invest_income` decimal(19,2) DEFAULT '0.00' COMMENT '其中:对联营企业和合营企业的投资收益',
`forex_gain` decimal(19,2) DEFAULT '0.00' COMMENT '加:汇兑净收益',
`total_cogs` decimal(19,2) DEFAULT '0.00' COMMENT '营业总成本',
`oper_cost` decimal(19,2) DEFAULT '0.00' COMMENT '减:营业成本',
`int_exp` decimal(19,2) DEFAULT '0.00' COMMENT '减:利息支出',
`comm_exp` decimal(19,2) DEFAULT '0.00' COMMENT '减:手续费及佣金支出',
`biz_tax_surchg` decimal(19,2) DEFAULT '0.00' COMMENT '减:营业税金及附加',
`sell_exp` decimal(19,2) DEFAULT '0.00' COMMENT '减:销售费用',
`admin_exp` decimal(19,2) DEFAULT '0.00' COMMENT '减:管理费用',
`fin_exp` decimal(19,2) DEFAULT '0.00' COMMENT '减:财务费用',
`assets_impair_loss` decimal(19,2) DEFAULT '0.00' COMMENT '减:资产减值损失',
`prem_refund` decimal(19,2) DEFAULT '0.00' COMMENT '退保金',
`compens_payout` decimal(19,2) DEFAULT '0.00' COMMENT '赔付总支出',
`reser_insur_liab` decimal(19,2) DEFAULT '0.00' COMMENT '提取保险责任准备金',
`div_payt` decimal(19,2) DEFAULT '0.00' COMMENT '保户红利支出',
`reins_exp` decimal(19,2) DEFAULT '0.00' COMMENT '分保费用',
`oper_exp` decimal(19,2) DEFAULT '0.00' COMMENT '营业支出',
`compens_payout_refu` decimal(19,2) DEFAULT '0.00' COMMENT '减:摊回赔付支出',
`insur_reser_refu` decimal(19,2) DEFAULT '0.00' COMMENT '减:摊回保险责任准备金',
`reins_cost_refund` decimal(19,2) DEFAULT '0.00' COMMENT '减:摊回分保费用',
`other_bus_cost` decimal(19,2) DEFAULT '0.00' COMMENT '其它业务成本',
`operate_profit` decimal(19,2) DEFAULT '0.00' COMMENT '营业利润',
`non_oper_income` decimal(19,2) DEFAULT '0.00' COMMENT '加:营业外收入',
`non_oper_exp` decimal(19,2) DEFAULT '0.00' COMMENT '减:营业外支出',
`nca_disploss` decimal(19,2) DEFAULT '0.00' COMMENT '其中:减:非流动资产处置损失',
`total_profit` decimal(19,2) DEFAULT '0.00' COMMENT '利润总额',
`income_tax` decimal(19,2) DEFAULT '0.00' COMMENT '所得税费用',
`n_income` decimal(19,2) DEFAULT '0.00' COMMENT '净利润(含少数股东损益)',
`n_income_attr_p` decimal(19,2) DEFAULT '0.00' COMMENT '净利润(不含少数股东损益)',
`minority_gain` decimal(19,2) DEFAULT '0.00' COMMENT '少数股东损益',
`oth_compr_income` decimal(19,2) DEFAULT '0.00' COMMENT '其它综合收益',
`t_compr_income` decimal(19,2) DEFAULT '0.00' COMMENT '综合收益总额',
`compr_inc_attr_p` decimal(19,2) DEFAULT '0.00' COMMENT '归属于母公司(或股东)的综合收益总额)',
`compr_inc_attr_m_s` decimal(19,2) DEFAULT '0.00' COMMENT '归属于少数股东的综合收益总额',
`ebit` decimal(19,2) DEFAULT '0.00' COMMENT '息税前利润',
`ebitda` decimal(19,2) DEFAULT '0.00' COMMENT '息税折旧摊销前利润',
`insurance_exp` decimal(19,2) DEFAULT '0.00' COMMENT '保险业务支出',
`undist_profit` decimal(19,2) DEFAULT '0.00' COMMENT '年初未分配利润',
`distable_profit` decimal(19,2) DEFAULT '0.00' COMMENT '可分配利润',
`rd_exp` decimal(19,2) DEFAULT '0.00' COMMENT '研发费用',
`fin_exp_int_exp` decimal(19,2) DEFAULT '0.00' COMMENT '财务费用:利息费用',
`fin_exp_int_inc` decimal(19,2) DEFAULT '0.00' COMMENT '财务费用:利息收入',
`transfer_surplus_rese` decimal(19,2) DEFAULT '0.00' COMMENT '盈余公积转入',
`transfer_housing_imprest` decimal(19,2) DEFAULT '0.00' COMMENT '住房周转金转入',
`transfer_oth` decimal(19,2) DEFAULT '0.00' COMMENT '其它转入',
`adj_lossgain` decimal(19,2) DEFAULT '0.00' COMMENT '调整以前年度损益',
`withdra_legal_surplus` decimal(19,2) DEFAULT '0.00' COMMENT '提取法定盈余公积',
`withdra_legal_pubfund` decimal(19,2) DEFAULT '0.00' COMMENT '提取法定公益金',
`withdra_biz_devfund` decimal(19,2) DEFAULT '0.00' COMMENT '提取企业发展基金',
`withdra_rese_fund` decimal(19,2) DEFAULT '0.00' COMMENT '提取储备基金',
`withdra_oth_ersu` decimal(19,2) DEFAULT '0.00' COMMENT '提取任意盈余公积金',
`workers_welfare` decimal(19,2) DEFAULT '0.00' COMMENT '职工奖金福利',
`distr_profit_shrhder` decimal(19,2) DEFAULT '0.00' COMMENT '可供股东分配的利润',
`prfshare_payable_dvd` decimal(19,2) DEFAULT '0.00' COMMENT '应付优先股股利',
`comshare_payable_dvd` decimal(19,2) DEFAULT '0.00' COMMENT '应付普通股股利',
`capit_comstock_div` decimal(19,2) DEFAULT '0.00' COMMENT '转作股本的普通股股利',
`net_after_nr_lp_correct` decimal(19,2) DEFAULT '0.00' COMMENT '扣除非经营损益后的净利润(更正前)',
`oth_income` decimal(19,2) DEFAULT '0.00' COMMENT '其他收益',
`asset_disp_income` decimal(19,2) DEFAULT '0.00' COMMENT '资产处置收益',
`continued_net_profit` decimal(19,2) DEFAULT '0.00' COMMENT '持续经营净利润',
`end_net_profit` decimal(19,2) DEFAULT '0.00' COMMENT '终止经营净利润',
`credit_impa_loss` decimal(19,2) DEFAULT '0.00' COMMENT '信用减值损失',
`net_expo_hedging_benefits` decimal(19,2) DEFAULT '0.00' COMMENT '净敞口套期收益',
`oth_impair_loss_assets` decimal(19,2) DEFAULT '0.00' COMMENT '其它资产减值损失',
`total_opcost` decimal(19,2) DEFAULT '0.00' COMMENT '营业总成本2',
`amodcost_fin_assets` decimal(19,2) DEFAULT '0.00' COMMENT '以摊余成本计量的金融资产终止确认收益',
`update_flag` varchar(16) NOT NULL DEFAULT '' COMMENT '更新标识',
PRIMARY KEY (`ts_code`,`ann_date`,`f_ann_date`,`end_date`,`update_flag`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- stockdb.t_ods_hs_finance_indicator definition
CREATE TABLE `t_ods_hs_finance_indicator` (
`ts_code` varchar(32) NOT NULL DEFAULT '' COMMENT 'TS股票代码',
`ann_date` varchar(32) NOT NULL DEFAULT '' COMMENT '公告日期',
`end_date` varchar(32) NOT NULL DEFAULT '' COMMENT '报告期',
`eps` decimal(19,4) DEFAULT '0.0000' COMMENT '基本每股收益',
`dt_eps` decimal(19,4) DEFAULT '0.0000' COMMENT '稀释每股收益',
`total_revenue_ps` decimal(19,4) DEFAULT '0.0000' COMMENT '每股营业总收入',
`revenue_ps` decimal(19,4) DEFAULT '0.0000' COMMENT '每股营业收入',
`capital_rese_ps` decimal(19,4) DEFAULT '0.0000' COMMENT '每股资本公积',
`surplus_rese_ps` decimal(19,4) DEFAULT '0.0000' COMMENT '每股盈余公积',
`undist_profit_ps` decimal(19,4) DEFAULT '0.0000' COMMENT '每股未分配利润',
`extra_item` decimal(19,4) DEFAULT '0.0000' COMMENT '非经常性损益',
`profit_dedt` decimal(19,4) DEFAULT '0.0000' COMMENT '扣除非经常性损益后的净利润',
`gross_margin` decimal(19,4) DEFAULT '0.0000' COMMENT '毛利',
`current_ratio` decimal(19,4) DEFAULT '0.0000' COMMENT '流动比率',
`quick_ratio` decimal(19,4) DEFAULT '0.0000' COMMENT '速动比率',
`cash_ratio` decimal(19,4) DEFAULT '0.0000' COMMENT '保守速动比率',
`invturn_days` decimal(19,4) DEFAULT '0.0000' COMMENT '存货周转天数',
`arturn_days` decimal(19,4) DEFAULT '0.0000' COMMENT '应收账款周转天数',
`inv_turn` decimal(19,4) DEFAULT '0.0000' COMMENT '存货周转率',
`ar_turn` decimal(19,4) DEFAULT '0.0000' COMMENT '应收账款周转率',
`ca_turn` decimal(19,4) DEFAULT '0.0000' COMMENT '流动资产周转率',
`fa_turn` decimal(19,4) DEFAULT '0.0000' COMMENT '固定资产周转率',
`assets_turn` decimal(19,4) DEFAULT '0.0000' COMMENT '总资产周转率',
`op_income` decimal(19,4) DEFAULT '0.0000' COMMENT '经营活动净收益',
`valuechange_income` decimal(19,4) DEFAULT '0.0000' COMMENT '价值变动净收益',
`interst_income` decimal(19,4) DEFAULT '0.0000' COMMENT '利息费用',
`daa` decimal(19,4) DEFAULT '0.0000' COMMENT '折旧与摊销',
`ebit` decimal(19,4) DEFAULT '0.0000' COMMENT '息税前利润',
`ebitda` decimal(19,4) DEFAULT '0.0000' COMMENT '息税折旧摊销前利润',
`fcff` decimal(19,4) DEFAULT '0.0000' COMMENT '企业自由现金流量',
`fcfe` decimal(19,4) DEFAULT '0.0000' COMMENT '股权自由现金流量',
`current_exint` decimal(19,4) DEFAULT '0.0000' COMMENT '无息流动负债',
`noncurrent_exint` decimal(19,4) DEFAULT '0.0000' COMMENT '无息非流动负债',
`interestdebt` decimal(19,4) DEFAULT '0.0000' COMMENT '带息债务',
`netdebt` decimal(19,4) DEFAULT '0.0000' COMMENT '净债务',
`tangible_asset` decimal(19,4) DEFAULT '0.0000' COMMENT '有形资产',
`working_capital` decimal(19,4) DEFAULT '0.0000' COMMENT '营运资金',
`networking_capital` decimal(19,4) DEFAULT '0.0000' COMMENT '营运流动资本',
`invest_capital` decimal(19,4) DEFAULT '0.0000' COMMENT '全部投入资本',
`retained_earnings` decimal(19,4) DEFAULT '0.0000' COMMENT '留存收益',
`diluted2_eps` decimal(19,4) DEFAULT '0.0000' COMMENT '期末摊薄每股收益',
`bps` decimal(19,4) DEFAULT '0.0000' COMMENT '每股净资产',
`ocfps` decimal(19,4) DEFAULT '0.0000' COMMENT '每股经营活动产生的现金流量净额',
`retainedps` decimal(19,4) DEFAULT '0.0000' COMMENT '每股留存收益',
`cfps` decimal(19,4) DEFAULT '0.0000' COMMENT '每股现金流量净额',
`ebit_ps` decimal(19,4) DEFAULT '0.0000' COMMENT '每股息税前利润',
`fcff_ps` decimal(19,4) DEFAULT '0.0000' COMMENT '每股企业自由现金流量',
`fcfe_ps` decimal(19,4) DEFAULT '0.0000' COMMENT '每股股东自由现金流量',
`netprofit_margin` decimal(19,4) DEFAULT '0.0000' COMMENT '销售净利率',
`grossprofit_margin` decimal(19,4) DEFAULT '0.0000' COMMENT '销售毛利率',
`cogs_of_sales` decimal(19,4) DEFAULT '0.0000' COMMENT '销售成本率',
`expense_of_sales` decimal(19,4) DEFAULT '0.0000' COMMENT '销售期间费用率',
`profit_to_gr` decimal(19,4) DEFAULT '0.0000' COMMENT '净利润/营业总收入',
`saleexp_to_gr` decimal(19,4) DEFAULT '0.0000' COMMENT '销售费用/营业总收入',
`adminexp_of_gr` decimal(19,4) DEFAULT '0.0000' COMMENT '管理费用/营业总收入',
`finaexp_of_gr` decimal(19,4) DEFAULT '0.0000' COMMENT '财务费用/营业总收入',
`impai_ttm` decimal(19,4) DEFAULT '0.0000' COMMENT '资产减值损失/营业总收入',
`gc_of_gr` decimal(19,4) DEFAULT '0.0000' COMMENT '营业总成本/营业总收入',
`op_of_gr` decimal(19,4) DEFAULT '0.0000' COMMENT '营业利润/营业总收入',
`ebit_of_gr` decimal(19,4) DEFAULT '0.0000' COMMENT '息税前利润/营业总收入',
`roe` decimal(19,4) DEFAULT '0.0000' COMMENT '净资产收益率',
`roe_waa` decimal(19,4) DEFAULT '0.0000' COMMENT '加权平均净资产收益率',
`roe_dt` decimal(19,4) DEFAULT '0.0000' COMMENT '净资产收益率(扣除非经常损益)',
`roa` decimal(19,4) DEFAULT '0.0000' COMMENT '总资产报酬率',
`npta` decimal(19,4) DEFAULT '0.0000' COMMENT '总资产净利润',
`roic` decimal(19,4) DEFAULT '0.0000' COMMENT '投入资本回报率',
`roe_yearly` decimal(19,4) DEFAULT '0.0000' COMMENT '年化净资产收益率',
`roa2_yearly` decimal(19,4) DEFAULT '0.0000' COMMENT '年化总资产报酬率',
`roe_avg` decimal(19,4) DEFAULT '0.0000' COMMENT '平均净资产收益率(增发条件)',
`opincome_of_ebt` decimal(19,4) DEFAULT '0.0000' COMMENT '经营活动净收益/利润总额',
`investincome_of_ebt` decimal(19,4) DEFAULT '0.0000' COMMENT '价值变动净收益/利润总额',
`n_op_profit_of_ebt` decimal(19,4) DEFAULT '0.0000' COMMENT '营业外收支净额/利润总额',
`tax_to_ebt` decimal(19,4) DEFAULT '0.0000' COMMENT '所得税/利润总额',
`dtprofit_to_profit` decimal(19,4) DEFAULT '0.0000' COMMENT '扣除非经常损益后的净利润/净利润',
`salescash_to_or` decimal(19,4) DEFAULT '0.0000' COMMENT '销售商品提供劳务收到的现金/营业收入',
`ocf_to_or` decimal(19,4) DEFAULT '0.0000' COMMENT '经营活动产生的现金流量净额/营业收入',
`ocf_to_opincome` decimal(19,4) DEFAULT '0.0000' COMMENT '经营活动产生的现金流量净额/经营活动净收益',
`capitalized_to_da` decimal(19,4) DEFAULT '0.0000' COMMENT '资本支出/折旧和摊销',
`debt_to_assets` decimal(19,4) DEFAULT '0.0000' COMMENT '资产负债率',
`assets_to_eqt` decimal(19,4) DEFAULT '0.0000' COMMENT '权益乘数',
`dp_assets_to_eqt` decimal(19,4) DEFAULT '0.0000' COMMENT '权益乘数(杜邦分析)',
`ca_to_assets` decimal(19,4) DEFAULT '0.0000' COMMENT '流动资产/总资产',
`nca_to_assets` decimal(19,4) DEFAULT '0.0000' COMMENT '非流动资产/总资产',
`tbassets_to_totalassets` decimal(19,4) DEFAULT '0.0000' COMMENT '有形资产/总资产',
`int_to_talcap` decimal(19,4) DEFAULT '0.0000' COMMENT '带息债务/全部投入资本',
`eqt_to_talcapital` decimal(19,4) DEFAULT '0.0000' COMMENT '归属于母公司的股东权益/全部投入资本',
`currentdebt_to_debt` decimal(19,4) DEFAULT '0.0000' COMMENT '流动负债/负债合计',
`longdeb_to_debt` decimal(19,4) DEFAULT '0.0000' COMMENT '非流动负债/负债合计',
`ocf_to_shortdebt` decimal(19,4) DEFAULT '0.0000' COMMENT '经营活动产生的现金流量净额/流动负债',
`debt_to_eqt` decimal(19,4) DEFAULT '0.0000' COMMENT '产权比率',
`eqt_to_debt` decimal(19,4) DEFAULT '0.0000' COMMENT '归属于母公司的股东权益/负债合计',
`eqt_to_interestdebt` decimal(19,4) DEFAULT '0.0000' COMMENT '归属于母公司的股东权益/带息债务',
`tangibleasset_to_debt` decimal(19,4) DEFAULT '0.0000' COMMENT '有形资产/负债合计',
`tangasset_to_intdebt` decimal(19,4) DEFAULT '0.0000' COMMENT '有形资产/带息债务',
`tangibleasset_to_netdebt` decimal(19,4) DEFAULT '0.0000' COMMENT '有形资产/净债务',
`ocf_to_debt` decimal(19,4) DEFAULT '0.0000' COMMENT '经营活动产生的现金流量净额/负债合计',
`ocf_to_interestdebt` decimal(19,4) DEFAULT '0.0000' COMMENT '经营活动产生的现金流量净额/带息债务',
`ocf_to_netdebt` decimal(19,4) DEFAULT '0.0000' COMMENT '经营活动产生的现金流量净额/净债务',
`ebit_to_interest` decimal(19,4) DEFAULT '0.0000' COMMENT '已获利息倍数(EBIT/利息费用)',
`longdebt_to_workingcapital` decimal(19,4) DEFAULT '0.0000' COMMENT '长期债务与营运资金比率',
`ebitda_to_debt` decimal(19,4) DEFAULT '0.0000' COMMENT '息税折旧摊销前利润/负债合计',
`turn_days` decimal(19,4) DEFAULT '0.0000' COMMENT '营业周期',
`roa_yearly` decimal(19,4) DEFAULT '0.0000' COMMENT '年化总资产净利率',
`roa_dp` decimal(19,4) DEFAULT '0.0000' COMMENT '总资产净利率(杜邦分析)',
`fixed_assets` decimal(19,4) DEFAULT '0.0000' COMMENT '固定资产合计',
`profit_prefin_exp` decimal(19,4) DEFAULT '0.0000' COMMENT ' 扣除财务费用前营业利润',
`non_op_profit` decimal(19,4) DEFAULT '0.0000' COMMENT '非营业利润',
`op_to_ebt` decimal(19,4) DEFAULT '0.0000' COMMENT '营业利润/利润总额',
`nop_to_ebt` decimal(19,4) DEFAULT '0.0000' COMMENT '非营业利润/利润总额',
`ocf_to_profit` decimal(19,4) DEFAULT '0.0000' COMMENT '经营活动产生的现金流量净额/营业利润',
`cash_to_liqdebt` decimal(19,4) DEFAULT '0.0000' COMMENT '货币资金/流动负债',
`cash_to_liqdebt_withinterest` decimal(19,4) DEFAULT '0.0000' COMMENT '货币资金/带息流动负债',
`op_to_liqdebt` decimal(19,4) DEFAULT '0.0000' COMMENT '营业利润/流动负债',
`op_to_debt` decimal(19,4) DEFAULT '0.0000' COMMENT '营业利润/负债合计',
`roic_yearly` decimal(19,4) DEFAULT '0.0000' COMMENT '年化投入资本回报率',
`total_fa_trun` decimal(19,4) DEFAULT '0.0000' COMMENT '固定资产合计周转率',
`profit_to_op` decimal(19,4) DEFAULT '0.0000' COMMENT '利润总额/营业收入',
`q_opincome` decimal(19,4) DEFAULT '0.0000' COMMENT '经营活动单季度净收益',
`q_investincome` decimal(19,4) DEFAULT '0.0000' COMMENT '价值变动单季度净收益',
`q_dtprofit` decimal(19,4) DEFAULT '0.0000' COMMENT '扣除非经常损益后的单季度净利润',
`q_eps` decimal(19,4) DEFAULT '0.0000' COMMENT '每股收益(单季度)',
`q_netprofit_margin` decimal(19,4) DEFAULT '0.0000' COMMENT '销售净利率(单季度)',
`q_gsprofit_margin` decimal(19,4) DEFAULT '0.0000' COMMENT '销售毛利率(单季度)',
`q_exp_to_sales` decimal(19,4) DEFAULT '0.0000' COMMENT '销售期间费用率(单季度)',
`q_profit_to_gr` decimal(19,4) DEFAULT '0.0000' COMMENT '净利润/营业总收入(单季度)',
`q_saleexp_to_gr` decimal(19,4) DEFAULT '0.0000' COMMENT '销售费用/营业总收入 (单季度)',
`q_adminexp_to_gr` decimal(19,4) DEFAULT '0.0000' COMMENT '管理费用/营业总收入 (单季度)',
`q_finaexp_to_gr` decimal(19,4) DEFAULT '0.0000' COMMENT '财务费用/营业总收入 (单季度)',
`q_impair_to_gr_ttm` decimal(19,4) DEFAULT '0.0000' COMMENT '资产减值损失/营业总收入(单季度)',
`q_gc_to_gr` decimal(19,4) DEFAULT '0.0000' COMMENT '营业总成本/营业总收入 (单季度)',
`q_op_to_gr` decimal(19,4) DEFAULT '0.0000' COMMENT '营业利润/营业总收入(单季度)',
`q_roe` decimal(19,4) DEFAULT '0.0000' COMMENT '净资产收益率(单季度)',
`q_dt_roe` decimal(19,4) DEFAULT '0.0000' COMMENT '净资产单季度收益率(扣除非经常损益)',
`q_npta` decimal(19,4) DEFAULT '0.0000' COMMENT '总资产净利润(单季度)',
`q_opincome_to_ebt` decimal(19,4) DEFAULT '0.0000' COMMENT '经营活动净收益/利润总额(单季度)',
`q_investincome_to_ebt` decimal(19,4) DEFAULT '0.0000' COMMENT '价值变动净收益/利润总额(单季度)',
`q_dtprofit_to_profit` decimal(19,4) DEFAULT '0.0000' COMMENT '扣除非经常损益后的净利润/净利润(单季度)',
`q_salescash_to_or` decimal(19,4) DEFAULT '0.0000' COMMENT '销售商品提供劳务收到的现金/营业收入(单季度)',
`q_ocf_to_sales` decimal(19,4) DEFAULT '0.0000' COMMENT '经营活动产生的现金流量净额/营业收入(单季度)',
`q_ocf_to_or` decimal(19,4) DEFAULT '0.0000' COMMENT '经营活动产生的现金流量净额/经营活动净收益(单季度)',
`basic_eps_yoy` decimal(19,4) DEFAULT '0.0000' COMMENT '基本每股收益同比增长率(%)',
`dt_eps_yoy` decimal(19,4) DEFAULT '0.0000' COMMENT '稀释每股收益同比增长率(%)',
`cfps_yoy` decimal(19,4) DEFAULT '0.0000' COMMENT ' 每股经营活动产生的现金流量净额同比增长率(%)',
`op_yoy` decimal(19,4) DEFAULT '0.0000' COMMENT '营业利润同比增长率(%)',
`ebt_yoy` decimal(19,4) DEFAULT '0.0000' COMMENT '利润总额同比增长率(%)',
`netprofit_yoy` decimal(19,4) DEFAULT '0.0000' COMMENT '归属母公司股东的净利润同比增长率(%)',
`dt_netprofit_yoy` decimal(19,4) DEFAULT '0.0000' COMMENT '归属母公司股东的净利润-扣除非经常损益同比增长率(%)',
`ocf_yoy` decimal(19,4) DEFAULT '0.0000' COMMENT '经营活动产生的现金流量净额同比增长率(%)',
`roe_yoy` decimal(19,4) DEFAULT '0.0000' COMMENT '净资产收益率(摊薄)同比增长率(%)',
`bps_yoy` decimal(19,4) DEFAULT '0.0000' COMMENT '每股净资产相对年初增长率(%)',
`assets_yoy` decimal(19,4) DEFAULT '0.0000' COMMENT '资产总计相对年初增长率(%)',
`eqt_yoy` decimal(19,4) DEFAULT '0.0000' COMMENT '归属母公司的股东权益相对年初增长率(%)',
`tr_yoy` decimal(19,4) DEFAULT '0.0000' COMMENT '营业总收入同比增长率(%)',
`or_yoy` decimal(19,4) DEFAULT '0.0000' COMMENT '营业收入同比增长率(%)',
`q_gr_yoy` decimal(19,4) DEFAULT '0.0000' COMMENT '营业总收入同比增长率(%)(单季度)',
`q_gr_qoq` decimal(19,4) DEFAULT '0.0000' COMMENT '营业总收入环比增长率(%)(单季度)',
`q_sales_yoy` decimal(19,4) DEFAULT '0.0000' COMMENT '营业收入同比增长率(%)(单季度)',
`q_sales_qoq` decimal(19,4) DEFAULT '0.0000' COMMENT '营业收入环比增长率(%)(单季度)',
`q_op_yoy` decimal(19,4) DEFAULT '0.0000' COMMENT '营业利润同比增长率(%)(单季度)',
`q_op_qoq` decimal(19,4) DEFAULT '0.0000' COMMENT '营业利润环比增长率(%)(单季度)',
`q_profit_yoy` decimal(19,4) DEFAULT '0.0000' COMMENT '净利润同比增长率(%)(单季度)',
`q_profit_qoq` decimal(19,4) DEFAULT '0.0000' COMMENT '净利润环比增长率(%)(单季度)',
`q_netprofit_yoy` decimal(19,4) DEFAULT '0.0000' COMMENT '归属母公司股东的净利润同比增长率(%)(单季度)',
`q_netprofit_qoq` decimal(19,4) DEFAULT '0.0000' COMMENT '归属母公司股东的净利润环比增长率(%)(单季度)',
`equity_yoy` decimal(19,4) DEFAULT '0.0000' COMMENT '净资产同比增长率',
`rd_exp` decimal(19,4) DEFAULT '0.0000' COMMENT '研发费用',
`update_flag` varchar(16) NOT NULL DEFAULT '' COMMENT '更新标识',
PRIMARY KEY (`ts_code`,`ann_date`,`end_date`,`update_flag`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- stockdb.t_ods_hs_indicator_list definition
CREATE TABLE `t_ods_hs_indicator_list` (
`ts_code` varchar(32) NOT NULL DEFAULT '' COMMENT 'TS代码',
`name` varchar(128) DEFAULT '' COMMENT '简称',
`fullname` varchar(128) DEFAULT '' COMMENT '指数全称',
`market` varchar(32) DEFAULT '' COMMENT '市场',
`publisher` varchar(128) DEFAULT '' COMMENT '发布方',
`index_type` varchar(128) DEFAULT '' COMMENT '指数风格',
`category` varchar(32) DEFAULT '' COMMENT '指数类别',
`base_date` varchar(32) DEFAULT '''''' COMMENT '基期',
`base_point` float DEFAULT '0' COMMENT '基点',
`list_date` varchar(32) DEFAULT '' COMMENT '发布日期',
`weight_rule` varchar(32) DEFAULT '' COMMENT '加权方式',
`ts_desc` varchar(4096) DEFAULT '' COMMENT '描述',
`exp_date` varchar(32) DEFAULT '' COMMENT '终止日期',
PRIMARY KEY (`ts_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

89
tushare/db/sql-query.sh Normal file
View File

@ -0,0 +1,89 @@
select end_date,end_type, total_revenue, revenue, oper_cost, sell_exp, admin_exp, update_flag from t_ods_hs_finance_income where ts_code ='000002.SZ';
select ts_code, count(*) as cnt from t_ods_hs_finance_income GROUP BY ts_code ORDER BY ts_code asc;
## 半导体板块
SELECT ts_code, name, market FROM `t_ods_hs_base_list` WHERE industry='半导体';
##
select a.ts_code, b.name, a.end_date, a.update_flag, a.total_revenue, a.revenue, a.n_income_attr_p, a.total_cogs, a.oper_cost, a.sell_exp, a.admin_exp, a.fin_exp, a.rd_exp
from t_ods_hs_finance_income as a, t_ods_hs_base_list as b, t_meta_kechuang_chip as c
WHERE c.ts_code = b.ts_code AND a.ts_code = b.ts_code AND a.report_type = '1' AND a.end_type = '4' and a.update_flag=1
## 游戏行业的数据分析
select b.ts_code, c.name, b.end_date, b.roe, b.grossprofit_margin as '销售毛利率', b.netprofit_margin AS '销售净利率', b.profit_to_gr as '净利润/总收入', b.saleexp_to_gr as '销售成本/营收', b.adminexp_of_gr as '管理成本/营收', b.rd_exp/(b.gross_margin/b.grossprofit_margin) as '研发成本/营收', b.ebt_yoy as '利润增长率', b.tr_yoy AS '总营收增长率', b.netprofit_yoy as '归母利润增长率', b.dt_netprofit_yoy as '归母扣非利润增长率'
from t_meta_game as a, t_ods_hs_finance_indicator as b , t_ods_hs_base_list as c
WHERE a.ts_code = b.ts_code and a.ts_code = c.ts_code AND b.end_date like "%0630" and b.update_flag =1
ORDER BY b.ts_code desc, b.end_date ASC
# 游戏过滤出100亿市值以上的分析
select b.ts_code, c.name, b.end_date, b.roe, b.grossprofit_margin as '销售毛利率', b.netprofit_margin AS '销售净利率', b.saleexp_to_gr as '销售成本/营收', b.adminexp_of_gr as '管理成本/营收', b.rd_exp/(b.gross_margin/b.grossprofit_margin) as '研发成本/营收', b.ebt_yoy as '利润增长率', b.tr_yoy AS '总营收增长率'
from t_meta_game as a, t_ods_hs_finance_indicator as b , t_ods_hs_base_list as c, t_ods_hs_daily_basic as d
WHERE a.ts_code = b.ts_code and a.ts_code = c.ts_code AND a.ts_code=d.ts_code AND b.end_date like "%1231" and b.update_flag =1 AND d.trade_date='20220701' AND d.total_mv > 100*10000
ORDER BY b.ts_code desc, b.end_date ASC
## 科创芯片50亿以上的分析
select b.ts_code, c.name, b.end_date, format(d.total_mv/10000,2) as '当前市值', d.pe as '市盈率', d.ps as '市销率', b.roe, b.grossprofit_margin as '销售毛利率', b.netprofit_margin AS '销售净利率', b.saleexp_to_gr as '销售成本/营收', b.adminexp_of_gr as '管理成本/营收', b.rd_exp/(b.gross_margin/b.grossprofit_margin) as '研发成本/营收', b.ebt_yoy as '利润增长率', b.tr_yoy AS '总营收增长率'
from t_meta_kechuang_chip as a, t_ods_hs_finance_indicator as b , t_ods_hs_base_list as c, t_ods_hs_daily_basic as d
WHERE a.ts_code = b.ts_code and a.ts_code = c.ts_code AND a.ts_code=d.ts_code AND b.end_date like "%1231" and b.update_flag =1 AND d.trade_date='20220701' AND d.total_mv > 50*10000
ORDER BY b.ts_code desc, b.end_date ASC
## 半导体
select b.ts_code, c.name, b.end_date, format(d.total_mv/10000,2) as '当前市值', d.pe as '市盈率', d.ps as '市销率', b.roe, b.grossprofit_margin as '销售毛利率', b.netprofit_margin AS '销售净利率', b.saleexp_to_gr as '销售成本/营收', b.adminexp_of_gr as '管理成本/营收', b.rd_exp/(b.gross_margin/b.grossprofit_margin) as '研发成本/营收', b.netprofit_yoy as '利润增长率', b.tr_yoy AS '总营收增长率'
from t_ods_hs_base_list as a, t_ods_hs_finance_indicator as b , t_ods_hs_base_list as c, t_ods_hs_daily_basic as d
WHERE a.ts_code = b.ts_code and a.industry = '半导体' and a.ts_code = c.ts_code AND a.ts_code=d.ts_code AND b.end_date like "%1231" and b.update_flag =1 AND d.trade_date='20220701' AND d.total_mv > 50*10000
ORDER BY d.total_mv desc, b.end_date ASC
## 数据对比, indicator 表的管理费用/总营收数据不对。
SELECT a.ts_code, a.end_date, a.total_revenue, a.revenue, a.admin_exp, a.sell_exp, a.rd_exp, a.sell_exp/a.total_revenue*100 as '销售费用/总营收', a.admin_exp/a.total_revenue*100 as '管理费用/总营收', a.rd_exp/a.total_revenue*100 as '研发费用/总营收', b.saleexp_to_gr as '指标表.销售费用/营业总收入' , b.adminexp_of_gr as '指标表.管理费用/营业总收入', b.rd_exp/(b.gross_margin/b.grossprofit_margin) as '指标表.管理费用/营业总收入'
FROM t_ods_hs_finance_income as a , t_ods_hs_finance_indicator as b
WHERE a.ts_code= '688396.SH' AND a.end_date LIKE '20211231' and b.ts_code='688396.SH' AND b.update_flag = '1' and b.end_date='20211231'
## 影视
select b.ts_code, c.name, b.end_date, format(d.total_mv/10000,2) as '当前市值', d.pe as '市盈率', d.ps as '市销率', b.roe, b.grossprofit_margin as '销售毛利率', b.netprofit_margin AS '销售净利率', b.saleexp_to_gr as '销售成本/营收', b.adminexp_of_gr as '管理成本/营收', b.rd_exp/(b.gross_margin/b.grossprofit_margin) as '研发成本/营收', b.ebt_yoy as '利润增长率', b.tr_yoy AS '总营收增长率'
from t_meta_film as a, t_ods_hs_finance_indicator as b , t_ods_hs_base_list as c, t_ods_hs_daily_basic as d
WHERE a.ts_code = b.ts_code and a.ts_code = c.ts_code AND a.ts_code=d.ts_code AND b.end_date like "%1231" and b.update_flag =1 AND d.trade_date='20220701' AND d.total_mv > 30*10000
ORDER BY d.total_mv DESC, b.end_date ASC
## ROE 选股
SELECT a.ts_code, b.name, AVG(a.roe) as 'roe'
FROM t_ods_hs_finance_indicator AS a, t_ods_hs_base_list as b
WHERE a.ts_code = b.ts_code
GROUP BY ts_code
ORDER BY roe desc
## 华侨城
SELECT ts_code, end_date, total_revenue, total_cogs, (total_revenue - oper_cost)/total_revenue as '毛利率', n_income_attr_p, n_income_attr_p/total_revenue as '净利率'
FROM `t_ods_hs_finance_income`
WHERE ts_code='000069.SZ' AND end_type = '4' AND update_flag = 0;
SELECT ts_code, end_date, total_assets, total_liab, total_assets - total_liab as '净资产', total_hldr_eqy_exc_min_int , contract_liab, adv_receipts, inventories, fix_assets, (total_liab-contract_liab-adv_receipts)/(total_assets-contract_liab-adv_receipts) as '资产负债率', update_flag
FROM `t_ods_hs_finance_balance`
WHERE ts_code='000069.SZ' AND end_type = '4'
SELECT ts_code, end_date, total_assets, total_liab, total_assets - total_liab as '净资产', total_hldr_eqy_exc_min_int , contract_liab, adv_receipts, inventories, fix_assets, (total_liab-contract_liab-adv_receipts)/(total_assets-contract_liab-adv_receipts) as '资产负债率', inventories/total_assets as '存货/总资产', inventories/(total_assets - total_liab) as '存货/净资产', update_flag
FROM `t_ods_hs_finance_balance`
WHERE ts_code in('000069.SZ', '000002.SZ','600048.SH') AND end_type = '4'
SELECT ts_code, end_date, im_n_incr_cash_equ, c_inf_fr_operate_a, st_cash_out_act, n_cashflow_act, stot_inflows_inv_act, stot_out_inv_act, n_cashflow_inv_act, stot_cash_in_fnc_act, stot_cashout_fnc_act, n_cash_flows_fnc_act,update_flag
FROM `t_ods_hs_finance_cashflow`
WHERE ts_code='000069.SZ' AND end_type = '4'
## 按照毛利率和净利率选股
SELECT a.ts_code, b.name, a.end_date, a.total_revenue, a.revenue, a.oper_cost, format((a.revenue/a.total_revenue)*100, 2) as '主业营收比例', format((1- a.oper_cost/a.revenue)*100, 2) as '毛利率', format((total_profit /a. total_revenue)*100, 2) as '净利率', a.update_flag
FROM `t_ods_hs_finance_income` as a, t_ods_hs_base_list as b
WHERE a.ts_code = b.ts_code and a.end_type = '4'
ORDER BY a.ts_code asc, a.end_date asc
SELECT a.ts_code, b.name, a.end_date, format(a.grossprofit_margin,2) as '毛利率', format(a.netprofit_margin,2) as '净利率', format(a.tr_yoy,2) as '营收同比增长', format(a.ebt_yoy, 2) as '利润同比增长'
FROM `t_ods_hs_finance_indicator` as a, t_ods_hs_base_list as b
WHERE a.ts_code = b.ts_code and a.end_date like '%1231'
SELECT a.ts_code, b.name, format(c.total_mv/10000, 2), a.end_date, format(a.grossprofit_margin,2) as '毛利率', format(a.netprofit_margin,2) as '净利率', format(a.tr_yoy,2) as '营收同比增长', format(a.ebt_yoy, 2) as '利润同比增长'
FROM `t_ods_hs_finance_indicator` as a, t_ods_hs_base_list as b, t_ods_hs_daily_basic as c
WHERE a.ts_code = b.ts_code and c.ts_code =a.ts_code and a.end_date like '%1231'

View File

@ -0,0 +1,19 @@
# yaml 配置
version: '3'
services:
stock:
build: .
ports:
- "2022:22"
redis:
image: "redis:alpine"
mysql:
image: "mysql:5.7"
volumes:
- mysql-data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: "mysqlpw"
MYSQL_DATABASE: "testdb"
volumes:
mysql-data:

50
tushare/kechuang50.txt Normal file
View File

@ -0,0 +1,50 @@
688002.SH
688005.SH
688006.SH
688008.SH
688009.SH
688012.SH
688029.SH
688036.SH
688063.SH
688065.SH
688083.SH
688099.SH
688111.SH
688116.SH
688122.SH
688126.SH
688139.SH
688161.SH
688169.SH
688180.SH
688185.SH
688187.SH
688188.SH
688202.SH
688208.SH
688223.SH
688256.SH
688276.SH
688289.SH
688303.SH
688363.SH
688388.SH
688390.SH
688396.SH
688521.SH
688536.SH
688538.SH
688561.SH
688599.SH
688608.SH
688686.SH
688690.SH
688696.SH
688728.SH
688772.SH
688777.SH
688779.SH
688819.SH
688981.SH
689009.SH

BIN
tushare/mod/00698.xlsx Normal file

Binary file not shown.

52
tushare/mod/HKStock.py Normal file
View File

@ -0,0 +1,52 @@
#!/usr/bin/py
import json
from requests import get
from pandas import DataFrame
def balance_data(code,years):
#query = 'http://HKf10.eastmoney.com/F9HKStock/GetFinanceAssetData.do?securityCode={}.HK&comType=127000000606281483&yearList={}&reportTypeList=1,5,3,6&dateSearchType=1&listedType=0,1&reportTypeInScope=1&reportType=0&rotate=0&seperate=0&order=desc&cashType=1&exchangeValue=1&customSelect=0&CurrencySelect=0'.format(code,years)
query = 'http://emweb.securities.eastmoney.com/PC_HKF10/NewFinancialAnalysis/GetZCFZB?code={}&startdate={}&ctype=4&rtype=0'.format(code,years)
ct = get(query).text.replace('\\u0026nbsp','')
ct = ct.replace('\\u003cb\\u003e','').replace('\\u003c/b\\u003e','')
d = json.loads(ct)['data']
df = DataFrame(d)
print(df)
hdr = df.iloc[0,:].values
hdr[0] = "名目"
df.columns = hdr
df = df.iloc[1:,:]
df.index = df.iloc[:,0]
df = df.iloc[:,1:]
df = df.sort_values('截止日期',axis=1,ascending=False)
return df
def income_data(code,years):
query = 'http://hkf10.eastmoney.com/F9HKStock/GetFinanceProfitData.do?securityCode={c}.HK&comType=127000000606281483&yearList={ny}&reportTypeList=1,5,3,6&dateSearchType=1&listedType=0,1&reportTypeInScope=1&reportType=0&rotate=0&seperate=0&order=desc&cashType=1&exchangeValue=1&customSelect=0&CurrencySelect=0'.format(c=code,ny=years)
ct = get(query).text.replace('\\u0026nbsp','')
ct = ct.replace('\\u003cb\\u003e','').replace('\\u003c/b\\u003e','')
d = json.loads(ct)['resultList']
df = DataFrame(d)
hdr = df.iloc[0,:].values
hdr[0] = "名目"
df.columns = hdr
df = df.iloc[1:,:]
df.index = df.iloc[:,0]
df = df.iloc[:,1:]
df = df.sort_values('截止日期',axis=1,ascending=False)
return df
def cash_data(code,years):
query = 'http://hkf10.eastmoney.com/F9HKStock/GetFinanceCashflowData.do?securityCode={c}.HK&comType=127000000606281483&yearList={ny}&reportTypeList=1,5,3,6&dateSearchType=1&listedType=0,1&reportTypeInScope=1&reportType=0&rotate=0&seperate=0&order=desc&cashType=1&exchangeValue=1&customSelect=0&CurrencySelect=0'.format(c=code,ny=years)
ct = get(query).text.replace('\\u0026nbsp','')
ct = ct.replace('\\u003cb\\u003e','').replace('\\u003c/b\\u003e','')
d = json.loads(ct)['resultList']
df = DataFrame(d)
hdr = df.iloc[0,:].values
hdr[0] = "名目"
df.columns = hdr
df = df.iloc[1:,:]
df.index = df.iloc[:,0]
df = df.iloc[:,1:]
df = df.sort_values('截止日期',axis=1,ascending=False)
return df

BIN
tushare/mod/Template.xlsx Normal file

Binary file not shown.

21
tushare/mod/main.py Normal file
View File

@ -0,0 +1,21 @@
from HKStock import *
import xlwings as xw
code = input("请输入港股代码(不可省略前0):")
years = input("请输入下载年份,以英文逗号分隔:")
t = r'Template.xlsx'
b = balance_data(code,years)
p = income_data(code,years)
c = cash_data(code,years)
bk = xw.Book(t)
bk.sheets['balance_data'].clear_contents()
xw.view(b,bk.sheets['balance_data'])
#bk.sheets['cash_data'].clear_contents()
#xw.view(c,bk.sheets['cash_data'])
#bk.sheets['income_data'].clear_contents()
#xw.view(p,bk.sheets['income_data'])
bk.save(str(code)+'.xlsx')
xw.apps[0].quit()

85
tushare/readme.txt Normal file
View File

@ -0,0 +1,85 @@
需要三个container
用来执行应用的容器使用python环境调用tushare
数据库mysql 可选加个redis
用来呈现结果的web环境安装phpamdin
三个容器使用相同的网络,以便于互联。
由于windows下使用volume管理的数据无法直接可用因此用mount方式
// 创建网络
docker network create stock-net
// 创建应用容器
docker run -itd -p 2022:22 --name stockapp --network stock-net --mount type=bind,source=D:\AppData\docker-project\stock\,destination=/data/ ubuntu:latest
-- 安装软件
apt-get update
apt-get install python3-pip
pip3 install --upgrade pip
pip install tushare -i https://pypi.tuna.tsinghua.edu.cn/simple
apt-get install mysql-client
docker inspect stockdb | grep IPAddress 记录mysql的ip地址程序中使用
// 创建数据库
docker run -d -p 2036:3306 --name stockdb --network stock-net --mount type=bind,source=D:\AppData\docker-project\mysql-data\,destination=/var/lib/mysql -e MYSQL_ROOT_PASSWORD=mysqlpw -e MYSQL_DATABASE=stockdb mysql:5.7
// 创建web服务器
docker run -itd -p 2080:80 --name stockweb --network stock-net --mount type=bind,source=D:\AppData\docker-project\stock\,destination=/data/ ubuntu:latest
-- 安装phpamdin
apt-get install apache2
apt-get install php
apt-get install libapache2-mod-php
apt-get install php-gd
apt-get install php-curl
apt-get install php-mysql
apt-get install phpmyadmin
过程中可以忽略掉db的配置等安装完成后再单独配置配置文件在 /etc/phpmyadmin/config-db.php
// 启动phpadmin
service apache2 restart
// phpadmin 登录账号
root mysqlpw
//登录地址不能用localhost。ipconfig找到本机地址然后用2080端口访问
http://192.168.3.199:2080/phpmyadmin
PS C:\Users\PC> docker run -d `
>> --network stock-net --network-alias mysql `
>> -v mysql-data:D:\AppData\wsl\mysql-data `
>> -e MYSQL_ROOT_PASSWORD=mysqlpw `
>> -e MYSQL_DATABASE=testdb `
>> mysql:5.7
PS C:\Users\PC> docker run -itd `
>> --network stock-net `
>> -e MYSQL_HOST=mysql `
>> -e MYSQL_USER=root `
>> -e MYSQL_PASSWORD=mysqlpw `
>> -e MYSQL_DB=testdb `
>> ubuntu:latest
docker inspect -f {{".NetworkSettings.IPAddress"}} stockdb
All stock income data process succ! total stocks: 4822, total rows: 136268
-- ubuntu 镜像支持ssh登录
// 创建时指定ssh的端口映射
docker run -itd -p 2022:22 --name stockapp --network stock-net ubuntu:latest
// 创建好之后登录容器安装ssh
apt-get update
apt-get install openssh-server
apt-get install openssh-client
// 修改配置文件,支持密码登录
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config
// 修改root密码
echo "root:root" | chpasswd
// 重启ssh
/etc/init.d/ssh restart

2
tushare/requirements.txt Normal file
View File

@ -0,0 +1,2 @@
redis

5223
tushare/src/balance.log Normal file

File diff suppressed because it is too large Load Diff

5223
tushare/src/cashflow.log Normal file

File diff suppressed because it is too large Load Diff

3
tushare/src/config.py Normal file
View File

@ -0,0 +1,3 @@
CONFIG_DB = {"host":"172.18.0.2", "user":"root", "password":"mysqlpw", "database":"tushare-db"}
CONFIG_TS = {"secret":"f4b683b73b5208105564cb2a086f9c687268b8c4a50d7534853889e3"}

627
tushare/src/db.sql Normal file
View File

@ -0,0 +1,627 @@
# drop database stockdb;
# create database stockdb;
use stockdb;
create table if not exists t_ods_hs_base_list(
ts_code varchar(32) default '' comment 'TS代码',
symbol varchar(32) default '' comment '股票代码',
name varchar(32) default '' comment '股票名称',
area varchar(32) default '' comment '地域',
industry varchar(32) default '' comment '所属行业',
fullname varchar(128) default '' comment '股票全称',
enname varchar(128) default '' comment '英文全称',
cnspell varchar(32) default '' comment '拼音缩写',
market varchar(32) default '' comment '市场类型',
exchange varchar(32) default '' comment '交易所代码',
curr_type varchar(32) default '' comment '交易货币',
list_status varchar(32) default '' comment '上市状态 L上市 D退市 P暂停上市',
list_date varchar(32) default '' comment '上市日期',
delist_date varchar(32) default '' comment '退市日期',
is_hs varchar(32) default '' comment '是否沪深港通标的N否 H沪股通 S深股通',
PRIMARY KEY (ts_code)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
create table if not exists t_ods_hs_base_ipo(
ts_code varchar(32) default '' comment 'TS代码',
sub_code varchar(32) default '' comment '申购代码',
name varchar(32) default '' comment '名称',
ipo_date varchar(32) default '' comment '上网发行日期',
issue_date varchar(32) default '' comment '上市日期',
amount float default 0 comment '发行总量(万股)',
market_amount float default 0 comment '上网发行总量(万股)',
price float default 0 comment '发行价格',
pe float default 0 comment '市盈率',
limit_amount float default 0 comment '个人申购上限(万股)',
funds float default 0 comment '募集资金(亿)',
ballot float default 0 comment '中签率',
PRIMARY KEY (ts_code)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS t_meta_kechuang_chip(
ts_code varchar(32) DEFAULT '' COMMENT 'TS代码',
PRIMARY KEY (ts_code)
)
INSERT into t_meta_kechuang_chip values
('688981.SH'), ('688008.SH'), ('688012.SH'), ('688396.SH'), ('688126.SH'), ('688728.SH'), ('688385.SH'), ('688536.SH'), ('688099.SH'), ('688082.SH'),
('688798.SH'), ('688200.SH'), ('688521.SH'), ('688256.SH'), ('688107.SH'), ('688002.SH'), ('688608.SH'), ('688019.SH'), ('688123.SH'), ('688037.SH'),
('688001.SH'), ('688233.SH'), ('688368.SH'), ('688601.SH'), ('688508.SH'), ('688018.SH'), ('688106.SH'), ('688766.SH'), ('688268.SH'), ('688699.SH'),
('688595.SH'), ('688596.SH'), ('688313.SH'), ('688661.SH'), ('688049.SH'), ('688589.SH'), ('688135.SH'), ('688025.SH'), ('688138.SH'), ('688216.SH'),
('688286.SH'), ('688328.SH');
create table if not exists t_ods_hs_finance_income(
ts_code varchar(32) default '' comment 'TS代码',
ann_date varchar(32) default '' comment '公告日期',
f_ann_date varchar(32) default '' comment '实际公告日期',
end_date varchar(32) default '' comment '报告期',
report_type varchar(16) default '' comment '报告类型',
comp_type varchar(16) default '' comment '公司类型(1一般工商业2银行3保险4证券)',
end_type varchar(32) default '' comment '报告期类型',
basic_eps DECIMAL(19,2) default 0 comment '基本每股收益',
diluted_eps DECIMAL(19,2) default 0 comment '稀释每股收益',
total_revenue DECIMAL(19,2) default 0 comment '营业总收入',
revenue DECIMAL(19,2) default 0 comment '营业收入',
int_income DECIMAL(19,2) default 0 comment '利息收入',
prem_earned DECIMAL(19,2) default 0 comment '已赚保费',
comm_income DECIMAL(19,2) default 0 comment '手续费及佣金收入',
n_commis_income DECIMAL(19,2) default 0 comment '手续费及佣金净收入',
n_oth_income DECIMAL(19,2) default 0 comment '其它经营净收益',
n_oth_b_income DECIMAL(19,2) default 0 comment '加:其它业务净收益',
prem_income DECIMAL(19,2) default 0 comment '保险业务收入',
out_prem DECIMAL(19,2) default 0 comment '减:分出保费',
une_prem_reser DECIMAL(19,2) default 0 comment '提取未到期责任准备金',
reins_income DECIMAL(19,2) default 0 comment '其中:分保费收入',
n_sec_tb_income DECIMAL(19,2) default 0 comment '代理买卖证券业务净收入',
n_sec_uw_income DECIMAL(19,2) default 0 comment '证券承销业务净收入',
n_asset_mg_income DECIMAL(19,2) default 0 comment '受托客户资产管理业务净收入',
oth_b_income DECIMAL(19,2) default 0 comment '其它业务收入',
fv_value_chg_gain DECIMAL(19,2) default 0 comment '加:公允价值变动净收益',
invest_income DECIMAL(19,2) default 0 comment '加:投资净收益',
ass_invest_income DECIMAL(19,2) default 0 comment '其中:对联营企业和合营企业的投资收益',
forex_gain DECIMAL(19,2) default 0 comment '加:汇兑净收益',
total_cogs DECIMAL(19,2) default 0 comment '营业总成本',
oper_cost DECIMAL(19,2) default 0 comment '减:营业成本',
int_exp DECIMAL(19,2) default 0 comment '减:利息支出',
comm_exp DECIMAL(19,2) default 0 comment '减:手续费及佣金支出',
biz_tax_surchg DECIMAL(19,2) default 0 comment '减:营业税金及附加',
sell_exp DECIMAL(19,2) default 0 comment '减:销售费用',
admin_exp DECIMAL(19,2) default 0 comment '减:管理费用',
fin_exp DECIMAL(19,2) default 0 comment '减:财务费用',
assets_impair_loss DECIMAL(19,2) default 0 comment '减:资产减值损失',
prem_refund DECIMAL(19,2) default 0 comment '退保金',
compens_payout DECIMAL(19,2) default 0 comment '赔付总支出',
reser_insur_liab DECIMAL(19,2) default 0 comment '提取保险责任准备金',
div_payt DECIMAL(19,2) default 0 comment '保户红利支出',
reins_exp DECIMAL(19,2) default 0 comment '分保费用',
oper_exp DECIMAL(19,2) default 0 comment '营业支出',
compens_payout_refu DECIMAL(19,2) default 0 comment '减:摊回赔付支出',
insur_reser_refu DECIMAL(19,2) default 0 comment '减:摊回保险责任准备金',
reins_cost_refund DECIMAL(19,2) default 0 comment '减:摊回分保费用',
other_bus_cost DECIMAL(19,2) default 0 comment '其它业务成本',
operate_profit DECIMAL(19,2) default 0 comment '营业利润',
non_oper_income DECIMAL(19,2) default 0 comment '加:营业外收入',
non_oper_exp DECIMAL(19,2) default 0 comment '减:营业外支出',
nca_disploss DECIMAL(19,2) default 0 comment '其中:减:非流动资产处置损失',
total_profit DECIMAL(19,2) default 0 comment '利润总额',
income_tax DECIMAL(19,2) default 0 comment '所得税费用',
n_income DECIMAL(19,2) default 0 comment '净利润(含少数股东损益)',
n_income_attr_p DECIMAL(19,2) default 0 comment '净利润(不含少数股东损益)',
minority_gain DECIMAL(19,2) default 0 comment '少数股东损益',
oth_compr_income DECIMAL(19,2) default 0 comment '其它综合收益',
t_compr_income DECIMAL(19,2) default 0 comment '综合收益总额',
compr_inc_attr_p DECIMAL(19,2) default 0 comment '归属于母公司(或股东)的综合收益总额)',
compr_inc_attr_m_s DECIMAL(19,2) default 0 comment '归属于少数股东的综合收益总额',
ebit DECIMAL(19,2) default 0 comment '息税前利润',
ebitda DECIMAL(19,2) default 0 comment '息税折旧摊销前利润',
insurance_exp DECIMAL(19,2) default 0 comment '保险业务支出',
undist_profit DECIMAL(19,2) default 0 comment '年初未分配利润',
distable_profit DECIMAL(19,2) default 0 comment '可分配利润',
rd_exp DECIMAL(19,2) default 0 comment '研发费用',
fin_exp_int_exp DECIMAL(19,2) default 0 comment '财务费用:利息费用',
fin_exp_int_inc DECIMAL(19,2) default 0 comment '财务费用:利息收入',
transfer_surplus_rese DECIMAL(19,2) default 0 comment '盈余公积转入',
transfer_housing_imprest DECIMAL(19,2) default 0 comment '住房周转金转入',
transfer_oth DECIMAL(19,2) default 0 comment '其它转入',
adj_lossgain DECIMAL(19,2) default 0 comment '调整以前年度损益',
withdra_legal_surplus DECIMAL(19,2) default 0 comment '提取法定盈余公积',
withdra_legal_pubfund DECIMAL(19,2) default 0 comment '提取法定公益金',
withdra_biz_devfund DECIMAL(19,2) default 0 comment '提取企业发展基金',
withdra_rese_fund DECIMAL(19,2) default 0 comment '提取储备基金',
withdra_oth_ersu DECIMAL(19,2) default 0 comment '提取任意盈余公积金',
workers_welfare DECIMAL(19,2) default 0 comment '职工奖金福利',
distr_profit_shrhder DECIMAL(19,2) default 0 comment '可供股东分配的利润',
prfshare_payable_dvd DECIMAL(19,2) default 0 comment '应付优先股股利',
comshare_payable_dvd DECIMAL(19,2) default 0 comment '应付普通股股利',
capit_comstock_div DECIMAL(19,2) default 0 comment '转作股本的普通股股利',
net_after_nr_lp_correct DECIMAL(19,2) default 0 comment '扣除非经营损益后的净利润(更正前)',
oth_income DECIMAL(19,2) default 0 comment '其他收益',
asset_disp_income DECIMAL(19,2) default 0 comment '资产处置收益',
continued_net_profit DECIMAL(19,2) default 0 comment '持续经营净利润',
end_net_profit DECIMAL(19,2) default 0 comment '终止经营净利润',
credit_impa_loss DECIMAL(19,2) default 0 comment '信用减值损失',
net_expo_hedging_benefits DECIMAL(19,2) default 0 comment '净敞口套期收益',
oth_impair_loss_assets DECIMAL(19,2) default 0 comment '其它资产减值损失',
total_opcost DECIMAL(19,2) default 0 comment '营业总成本2',
amodcost_fin_assets DECIMAL(19,2) default 0 comment '以摊余成本计量的金融资产终止确认收益',
update_flag varchar(16) default '' comment '更新标识',
PRIMARY KEY (ts_code, ann_date, f_ann_date, end_date, update_flag)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
create table if not exists t_ods_hs_finance_balance (
ts_code varchar(32) default '' comment 'TS股票代码',
ann_date varchar(32) default '' comment '公告日期',
f_ann_date varchar(32) default '' comment '实际公告日期',
end_date varchar(32) default '' comment '报告期',
report_type varchar(32) default '' comment '报告类型',
comp_type varchar(32) default '' comment '公司类型(1一般工商业2银行3保险4证券)',
end_type varchar(32) default '' comment '报告期类型',
total_share DECIMAL(19,2) default 0 comment '期末总股本',
cap_rese DECIMAL(19,2) default 0 comment '资本公积金',
undistr_porfit DECIMAL(19,2) default 0 comment '未分配利润',
surplus_rese DECIMAL(19,2) default 0 comment '盈余公积金',
special_rese DECIMAL(19,2) default 0 comment '专项储备',
money_cap DECIMAL(19,2) default 0 comment '货币基金',
trad_asset DECIMAL(19,2) default 0 comment '交易性金融资产',
notes_receiv DECIMAL(19,2) default 0 comment '应收票据',
accounts_receiv DECIMAL(19,2) default 0 comment '应收账款',
oth_receiv DECIMAL(19,2) default 0 comment '其它应收款',
prepayment DECIMAL(19,2) default 0 comment '预付款项',
div_receiv DECIMAL(19,2) default 0 comment '应收股利',
int_receiv DECIMAL(19,2) default 0 comment '应收利息',
inventories DECIMAL(19,2) default 0 comment '存货',
amor_exp DECIMAL(19,2) default 0 comment '长期待摊费用',
nca_within_1y DECIMAL(19,2) default 0 comment '一年内到期的非流动资产',
sett_rsrv DECIMAL(19,2) default 0 comment '结算备付金',
loanto_oth_bank_fi DECIMAL(19,2) default 0 comment '拆出资金',
premium_receiv DECIMAL(19,2) default 0 comment '应收保费',
reinsur_receiv DECIMAL(19,2) default 0 comment '应收分保账款',
reinsur_res_receiv DECIMAL(19,2) default 0 comment '应收分保合同准备金',
pur_resale_fa DECIMAL(19,2) default 0 comment '买入返售金融资产',
oth_cur_assets DECIMAL(19,2) default 0 comment '其它流动资产',
total_cur_assets DECIMAL(19,2) default 0 comment '流动资产合计',
fa_avail_for_sale DECIMAL(19,2) default 0 comment '可供出售金融资产',
htm_invest DECIMAL(19,2) default 0 comment '持有至到期投资',
lt_eqt_invest DECIMAL(19,2) default 0 comment '长期股权投资',
invest_real_estate DECIMAL(19,2) default 0 comment '投资性房地产',
time_deposits DECIMAL(19,2) default 0 comment '定期存款',
oth_assets DECIMAL(19,2) default 0 comment '其它资产',
lt_rec DECIMAL(19,2) default 0 comment '长期应收款',
fix_assets DECIMAL(19,2) default 0 comment '固定资产',
cip DECIMAL(19,2) default 0 comment '在建工程',
const_materials DECIMAL(19,2) default 0 comment '工程物资',
fixed_assets_disp DECIMAL(19,2) default 0 comment '固定资产清理',
produc_bio_assets DECIMAL(19,2) default 0 comment '生产性生物资产',
oil_and_gas_assets DECIMAL(19,2) default 0 comment '油气资产',
intan_assets DECIMAL(19,2) default 0 comment '无形资产',
r_and_d DECIMAL(19,2) default 0 comment '研发支出',
goodwill DECIMAL(19,2) default 0 comment '商誉',
lt_amor_exp DECIMAL(19,2) default 0 comment '长期待摊费用',
defer_tax_assets DECIMAL(19,2) default 0 comment '递延所得税资产',
decr_in_disbur DECIMAL(19,2) default 0 comment '发放贷款及垫款',
oth_nca DECIMAL(19,2) default 0 comment '其他非流动资产',
total_nca DECIMAL(19,2) default 0 comment '非流动资产合计',
cash_reser_cb DECIMAL(19,2) default 0 comment '现金及存放中央银行款项',
depos_in_oth_bfi DECIMAL(19,2) default 0 comment '存放同业和其它金融机构款项',
prec_metals DECIMAL(19,2) default 0 comment '贵金属',
deriv_assets DECIMAL(19,2) default 0 comment '衍生金融资产',
rr_reins_une_prem DECIMAL(19,2) default 0 comment '应收分保未到期责任准备金',
rr_reins_outstd_cla DECIMAL(19,2) default 0 comment '应收分保未决赔款准备金',
rr_reins_lins_liab DECIMAL(19,2) default 0 comment '应收分保寿险责任准备金',
rr_reins_lthins_liab DECIMAL(19,2) default 0 comment '应收分保长期健康险责任准备金',
refund_depos DECIMAL(19,2) default 0 comment '存出保证金',
ph_pledge_loans DECIMAL(19,2) default 0 comment '保户质押贷款',
refund_cap_depos DECIMAL(19,2) default 0 comment '存出资本保证金',
indep_acct_assets DECIMAL(19,2) default 0 comment '独立账户资产',
client_depos DECIMAL(19,2) default 0 comment '其中:客户资金存款',
client_prov DECIMAL(19,2) default 0 comment '其中:客户备付金',
transac_seat_fee DECIMAL(19,2) default 0 comment '其中:交易席位费',
invest_as_receiv DECIMAL(19,2) default 0 comment '营收款项类投资',
total_assets DECIMAL(19,2) default 0 comment '资产总计',
lt_borr DECIMAL(19,2) default 0 comment '长期借款',
st_borr DECIMAL(19,2) default 0 comment '短期借款',
cb_borr DECIMAL(19,2) default 0 comment '向中央银行借款',
depos_ib_deposits DECIMAL(19,2) default 0 comment '吸收存款及同业存放',
loan_oth_bank DECIMAL(19,2) default 0 comment '拆入资金',
trading_fl DECIMAL(19,2) default 0 comment '交易性金融负债',
notes_payable DECIMAL(19,2) default 0 comment '应付票据',
acct_payable DECIMAL(19,2) default 0 comment '应付账款',
adv_receipts DECIMAL(19,2) default 0 comment '预收款项',
sold_for_repur_fa DECIMAL(19,2) default 0 comment '卖出回购金融资产款',
comm_payable DECIMAL(19,2) default 0 comment '应付手续费及佣金',
payroll_payable DECIMAL(19,2) default 0 comment '应付职工薪酬',
taxes_payable DECIMAL(19,2) default 0 comment '应缴税费',
int_payable DECIMAL(19,2) default 0 comment '应付利息',
div_payable DECIMAL(19,2) default 0 comment '应付股利',
oth_payable DECIMAL(19,2) default 0 comment '其它应付款',
acc_exp DECIMAL(19,2) default 0 comment '预提费用',
deferred_inc DECIMAL(19,2) default 0 comment '递延收益',
st_bonds_payable DECIMAL(19,2) default 0 comment '应付短期债券',
payable_to_reinsurer DECIMAL(19,2) default 0 comment '应付分保账款',
rsrv_insur_cont DECIMAL(19,2) default 0 comment '保险合同准备金',
acting_trading_sec DECIMAL(19,2) default 0 comment '代理买卖证券款',
acting_uw_sec DECIMAL(19,2) default 0 comment '代理承销证券款',
non_cur_liab_due_1y DECIMAL(19,2) default 0 comment '一年内到期的非流动负债',
oth_cur_liab DECIMAL(19,2) default 0 comment '其它流动负债',
total_cur_liab DECIMAL(19,2) default 0 comment '流动负债合计',
bond_payable DECIMAL(19,2) default 0 comment '应付债券',
lt_payable DECIMAL(19,2) default 0 comment '长期应付款',
specific_payables DECIMAL(19,2) default 0 comment '专项应付款',
estimated_liab DECIMAL(19,2) default 0 comment '预计负债',
defer_tax_liab DECIMAL(19,2) default 0 comment '递延所得税负债',
defer_inc_non_cur_liab DECIMAL(19,2) default 0 comment '递延收益-非流动负债',
oth_ncl DECIMAL(19,2) default 0 comment '其它非流动负债',
total_ncl DECIMAL(19,2) default 0 comment '非流动负债合计',
depos_oth_bfi DECIMAL(19,2) default 0 comment '同业和其它金融机构存放款项',
deriv_liab DECIMAL(19,2) default 0 comment '衍生金融负债',
depos DECIMAL(19,2) default 0 comment '吸收存款',
agency_bus_liab DECIMAL(19,2) default 0 comment '代理业务负债',
oth_liab DECIMAL(19,2) default 0 comment '其它负债',
prem_receiv_adva DECIMAL(19,2) default 0 comment '预收保费',
depos_received DECIMAL(19,2) default 0 comment '存入保证金',
ph_invest DECIMAL(19,2) default 0 comment '保户储金及投资款',
reser_une_prem DECIMAL(19,2) default 0 comment '未到期责任准备金',
reser_outstd_claims DECIMAL(19,2) default 0 comment '未决赔款准备金',
reser_lins_liab DECIMAL(19,2) default 0 comment '寿险责任准备金',
reser_lthins_liab DECIMAL(19,2) default 0 comment '长期健康险责任准备金',
indept_acc_liab DECIMAL(19,2) default 0 comment '独立账户负债',
pledge_borr DECIMAL(19,2) default 0 comment '其中:质押借款',
indem_payable DECIMAL(19,2) default 0 comment '应付赔付款',
policy_div_payable DECIMAL(19,2) default 0 comment '应付保单红利',
total_liab DECIMAL(19,2) default 0 comment '负债合计',
treasury_share DECIMAL(19,2) default 0 comment '减:库存股',
ordin_risk_reser DECIMAL(19,2) default 0 comment '一般风险准备',
forex_differ DECIMAL(19,2) default 0 comment '外币报表折算差额',
invest_loss_unconf DECIMAL(19,2) default 0 comment '未确认的投资损失',
minority_int DECIMAL(19,2) default 0 comment '少数股东权益',
total_hldr_eqy_exc_min_int DECIMAL(19,2) default 0 comment '股东权益合计(不含少数股东权益)',
total_hldr_eqy_inc_min_int DECIMAL(19,2) default 0 comment '股东权益合计(含少数股东权益)',
total_liab_hldr_eqy DECIMAL(19,2) default 0 comment '负债及股东权益总计',
lt_payroll_payable DECIMAL(19,2) default 0 comment '长期应付职工薪酬',
oth_comp_income DECIMAL(19,2) default 0 comment '其它综合收益',
oth_eqt_tools DECIMAL(19,2) default 0 comment '其它权益工具',
oth_eqt_tools_p_shr DECIMAL(19,2) default 0 comment '其它权益工具(优先股)',
lending_funds DECIMAL(19,2) default 0 comment '融出资金',
acc_receivable DECIMAL(19,2) default 0 comment '应收款项',
st_fin_payable DECIMAL(19,2) default 0 comment '应付短期融资款',
payables DECIMAL(19,2) default 0 comment '应付款项',
hfs_assets DECIMAL(19,2) default 0 comment '持有代售的资产',
hfs_sales DECIMAL(19,2) default 0 comment '持有代售的负债',
cost_fin_assets DECIMAL(19,2) default 0 comment '以摊余成本计量的金融资产',
fair_value_fin_assets DECIMAL(19,2) default 0 comment '以公允价值计量且其变动计入其他综合收益的金融资产',
contract_assets DECIMAL(19,2) default 0 comment '合同资产',
contract_liab DECIMAL(19,2) default 0 comment '合同负债',
accounts_receiv_bill DECIMAL(19,2) default 0 comment '应收票据及应收账款',
accounts_pay DECIMAL(19,2) default 0 comment '应付票据及应付账款',
oth_rcv_total DECIMAL(19,2) default 0 comment '其它应收款(合计)(元)',
fix_assets_total DECIMAL(19,2) default 0 comment '固定资产(合计)(元)',
cip_total DECIMAL(19,2) default 0 comment '在建工程(合计)(元)',
oth_pay_total DECIMAL(19,2) default 0 comment '其它应付款(合计)(元)',
long_pay_total DECIMAL(19,2) default 0 comment '长期应付款(合计)(元)',
debt_invest DECIMAL(19,2) default 0 comment '债券投资(元)',
oth_debt_invest DECIMAL(19,2) default 0 comment '其它债券投资(元)',
oth_eq_invest DECIMAL(19,2) default 0 comment '其它权益工具投资(元)',
oth_illiq_fin_assets DECIMAL(19,2) default 0 comment '其它非流动金融资产(元)',
oth_eq_ppbond DECIMAL(19,2) default 0 comment '其它权益工具:永续债(元)',
receiv_financing DECIMAL(19,2) default 0 comment '应收款项融资',
use_right_assets DECIMAL(19,2) default 0 comment '使用权资产',
lease_liab DECIMAL(19,2) default 0 comment '租赁负债',
update_flag varchar(32) default '' comment '更新标志',
PRIMARY KEY (ts_code, ann_date, f_ann_date, end_date, update_flag)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
create table if not exists t_ods_hs_finance_cashflow (
ts_code varchar(32) default '' comment 'TS股票代码',
ann_date varchar(32) default '' comment '公告日期',
f_ann_date varchar(32) default '' comment '实际公告日期',
end_date varchar(32) default '' comment '报告期',
report_type varchar(32) default '' comment '报告类型',
comp_type varchar(32) default '' comment '公司类型(1一般工商业2银行3保险4证券)',
end_type varchar(32) default '' comment '报告期类型',
net_profit DECIMAL(19,2) default 0 comment '净利润',
finan_exp DECIMAL(19,2) default 0 comment '财务费用',
c_fr_sale_sg DECIMAL(19,2) default 0 comment '销售商品、提供劳务收到的现金',
recp_tax_rends DECIMAL(19,2) default 0 comment '收到的税费返还',
n_depos_incr_fi DECIMAL(19,2) default 0 comment '客户存款和同业存放款项净增加额',
n_incr_loans_cb DECIMAL(19,2) default 0 comment '向中央银行借款净增加额',
n_inc_borr_oth_fi DECIMAL(19,2) default 0 comment '向其它金融机构拆入资金净增加额',
prem_fr_orig_contr DECIMAL(19,2) default 0 comment '收到原保险合同保费取得的现金',
n_incr_insured_dep DECIMAL(19,2) default 0 comment '保户储金净增加额',
n_reinsur_prem DECIMAL(19,2) default 0 comment '收到再保业务现金净额',
n_incr_disp_tfa DECIMAL(19,2) default 0 comment '处置交易性金融资产净增加额',
ifc_cash_incr DECIMAL(19,2) default 0 comment '收取利息和手续费净增加额',
n_incr_disp_faas DECIMAL(19,2) default 0 comment '处置可供出售金融资产净增加额',
n_incr_loans_oth_bank DECIMAL(19,2) default 0 comment '拆入资金净增加额',
n_cap_incr_repur DECIMAL(19,2) default 0 comment '回购业务资金净增加额',
c_fr_oth_operate_a DECIMAL(19,2) default 0 comment '收到其他与经营活动有关的现金',
c_inf_fr_operate_a DECIMAL(19,2) default 0 comment '经营活动现金流入小计',
c_paid_goods_s DECIMAL(19,2) default 0 comment '购买商品、接受劳务支付的现金',
c_paid_to_for_empl DECIMAL(19,2) default 0 comment '支付给职工以及为职工支付的现金',
c_paid_for_taxes DECIMAL(19,2) default 0 comment '支付的各项税费',
n_incr_clt_loan_adv DECIMAL(19,2) default 0 comment '客户贷款及垫款净增加额',
n_incr_dep_cbob DECIMAL(19,2) default 0 comment '存放央行和同业款项净增加额',
c_pay_claims_orig_inco DECIMAL(19,2) default 0 comment '支付原保险合同赔付款项的现金',
pay_handling_chrg DECIMAL(19,2) default 0 comment '支付手续费的现金',
pay_comm_insur_plcy DECIMAL(19,2) default 0 comment '支付保单红利的现金',
oth_cash_pay_oper_act DECIMAL(19,2) default 0 comment '支付其他与经营活动有关的现金',
st_cash_out_act DECIMAL(19,2) default 0 comment '经营活动现金流出小计',
n_cashflow_act DECIMAL(19,2) default 0 comment '经营活动产生的现金流量净额',
oth_recp_ral_inv_act DECIMAL(19,2) default 0 comment '收到其它与投资活动有关的现金',
c_disp_withdrwl_invest DECIMAL(19,2) default 0 comment '收回投资收到的现金',
c_recp_return_invest DECIMAL(19,2) default 0 comment '取得投资收益收到的现金',
n_recp_disp_fiolta DECIMAL(19,2) default 0 comment '处置固定资产、无形资产和其他长期资产收回的现金净额',
n_recp_disp_sobu DECIMAL(19,2) default 0 comment '处置子公司及其他营业单位收到的现金净额',
stot_inflows_inv_act DECIMAL(19,2) default 0 comment '投资活动现金流入小计',
c_pay_acq_const_fiolta DECIMAL(19,2) default 0 comment '购建固定资产、无形资产和其他长期资产支付的现金',
c_paid_invest DECIMAL(19,2) default 0 comment '投资支付的现金',
n_disp_subs_oth_biz DECIMAL(19,2) default 0 comment '取得子公司及其他营业单位支付的现金净额',
oth_pay_ral_inv_act DECIMAL(19,2) default 0 comment '支付其他与投资活动有关的现金',
n_incr_pledge_loan DECIMAL(19,2) default 0 comment '质押贷款净增加额',
stot_out_inv_act DECIMAL(19,2) default 0 comment '投资活动现金流出小计',
n_cashflow_inv_act DECIMAL(19,2) default 0 comment '投资活动产生的现金流量净额',
c_recp_borrow DECIMAL(19,2) default 0 comment '取得借款收到的现金',
proc_issue_bonds DECIMAL(19,2) default 0 comment '发行债券收到的现金',
oth_cash_recp_ral_fnc_act DECIMAL(19,2) default 0 comment '收到其他与筹资活动有关的现金',
stot_cash_in_fnc_act DECIMAL(19,2) default 0 comment '筹资活动现金流入小计',
free_cashflow DECIMAL(19,2) default 0 comment '企业自由现金流量',
c_prepay_amt_borr DECIMAL(19,2) default 0 comment '偿还债务支付的现金',
c_pay_dist_dpcp_int_exp DECIMAL(19,2) default 0 comment '分配股利、利润或偿付利息支付的现金',
incl_dvd_profit_paid_sc_ms DECIMAL(19,2) default 0 comment '其中:子公司支付给少数股东的股利、利润',
oth_cashpay_ral_fnc_act DECIMAL(19,2) default 0 comment '支付其他与筹资活动有关的现金',
stot_cashout_fnc_act DECIMAL(19,2) default 0 comment '筹资活动现金流出小计',
n_cash_flows_fnc_act DECIMAL(19,2) default 0 comment '筹资活动产生的现金流量净额',
eff_fx_flu_cash DECIMAL(19,2) default 0 comment '汇率变动对现金的影响',
n_incr_cash_cash_equ DECIMAL(19,2) default 0 comment '现金及现金等价物净增加额',
c_cash_equ_beg_period DECIMAL(19,2) default 0 comment '期初现金及现金等价物余额',
c_cash_equ_end_period DECIMAL(19,2) default 0 comment '期末现金及现金等价物余额',
c_recp_cap_contrib DECIMAL(19,2) default 0 comment '吸收投资收到的现金',
incl_cash_rec_saims DECIMAL(19,2) default 0 comment '其中:子公司吸收少数股东投资收到的现金',
uncon_invest_loss DECIMAL(19,2) default 0 comment '未确认投资损失',
prov_depr_assets DECIMAL(19,2) default 0 comment '加:资产减值准备',
depr_fa_coga_dpba DECIMAL(19,2) default 0 comment '固定资产折旧、油气资产折耗、生产性生物资产折旧',
amort_intang_assets DECIMAL(19,2) default 0 comment '无形资产摊销',
lt_amort_deferred_exp DECIMAL(19,2) default 0 comment '长期待摊费用摊销',
decr_deferred_exp DECIMAL(19,2) default 0 comment '待摊费用减少',
incr_acc_exp DECIMAL(19,2) default 0 comment '预提费用增加',
loss_disp_fiolta DECIMAL(19,2) default 0 comment '处置固定、无形资产和其他长期资产的损失',
loss_scr_fa DECIMAL(19,2) default 0 comment '固定资产报废损失',
loss_fv_chg DECIMAL(19,2) default 0 comment '公允价值变动损失',
invest_loss DECIMAL(19,2) default 0 comment '投资损失',
decr_def_inc_tax_assets DECIMAL(19,2) default 0 comment '递延所得税资产减少',
incr_def_inc_tax_liab DECIMAL(19,2) default 0 comment '递延所得税负债增加',
decr_inventories DECIMAL(19,2) default 0 comment '存货的减少',
decr_oper_payable DECIMAL(19,2) default 0 comment '经营性应收项目的减少',
incr_oper_payable DECIMAL(19,2) default 0 comment '经营性应付项目的增加',
others DECIMAL(19,2) default 0 comment '其他',
im_net_cashflow_oper_act DECIMAL(19,2) default 0 comment '经营活动产生的现金流量净额(间接法)',
conv_debt_into_cap DECIMAL(19,2) default 0 comment '债务转为资本',
conv_copbonds_due_within_1y DECIMAL(19,2) default 0 comment '一年内到期的可转换公司债券',
fa_fnc_leases DECIMAL(19,2) default 0 comment '融资租入固定资产',
im_n_incr_cash_equ DECIMAL(19,2) default 0 comment '现金及现金等价物净增加额(间接法)',
net_dism_capital_add DECIMAL(19,2) default 0 comment '拆出资金净增加额',
net_cash_rece_sec DECIMAL(19,2) default 0 comment '代理买卖证券收到的现金净额(元)',
credit_impa_loss DECIMAL(19,2) default 0 comment '信用减值损失',
use_right_asset_dep DECIMAL(19,2) default 0 comment '使用权资产折旧',
oth_loss_asset DECIMAL(19,2) default 0 comment '其他资产减值损失',
end_bal_cash DECIMAL(19,2) default 0 comment '现金的期末余额',
beg_bal_cash DECIMAL(19,2) default 0 comment '减:现金的期初余额',
end_bal_cash_equ DECIMAL(19,2) default 0 comment '加:现金等价物的期末余额',
beg_bal_cash_equ DECIMAL(19,2) default 0 comment '减:现金等价物的期初余额',
update_flag varchar(32) default '' comment '更新标志',
PRIMARY KEY (ts_code, ann_date, f_ann_date, end_date, update_flag)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
create table if not exists t_ods_hs_finance_indicator (
ts_code varchar(32) default '' comment 'TS股票代码',
ann_date varchar(32) default '' comment '公告日期',
end_date varchar(32) default '' comment '报告期',
eps DECIMAL(19,4) default 0 comment '基本每股收益',
dt_eps DECIMAL(19,4) default 0 comment '稀释每股收益',
total_revenue_ps DECIMAL(19,4) default 0 comment '每股营业总收入',
revenue_ps DECIMAL(19,4) default 0 comment '每股营业收入',
capital_rese_ps DECIMAL(19,4) default 0 comment '每股资本公积',
surplus_rese_ps DECIMAL(19,4) default 0 comment '每股盈余公积',
undist_profit_ps DECIMAL(19,4) default 0 comment '每股未分配利润',
extra_item DECIMAL(19,4) default 0 comment '非经常性损益',
profit_dedt DECIMAL(19,4) default 0 comment '扣除非经常性损益后的净利润',
gross_margin DECIMAL(19,4) default 0 comment '毛利',
current_ratio DECIMAL(19,4) default 0 comment '流动比率',
quick_ratio DECIMAL(19,4) default 0 comment '速动比率',
cash_ratio DECIMAL(19,4) default 0 comment '保守速动比率',
invturn_days DECIMAL(19,4) default 0 comment '存货周转天数',
arturn_days DECIMAL(19,4) default 0 comment '应收账款周转天数',
inv_turn DECIMAL(19,4) default 0 comment '存货周转率',
ar_turn DECIMAL(19,4) default 0 comment '应收账款周转率',
ca_turn DECIMAL(19,4) default 0 comment '流动资产周转率',
fa_turn DECIMAL(19,4) default 0 comment '固定资产周转率',
assets_turn DECIMAL(19,4) default 0 comment '总资产周转率',
op_income DECIMAL(19,4) default 0 comment '经营活动净收益',
valuechange_income DECIMAL(19,4) default 0 comment '价值变动净收益',
interst_income DECIMAL(19,4) default 0 comment '利息费用',
daa DECIMAL(19,4) default 0 comment '折旧与摊销',
ebit DECIMAL(19,4) default 0 comment '息税前利润',
ebitda DECIMAL(19,4) default 0 comment '息税折旧摊销前利润',
fcff DECIMAL(19,4) default 0 comment '企业自由现金流量',
fcfe DECIMAL(19,4) default 0 comment '股权自由现金流量',
current_exint DECIMAL(19,4) default 0 comment '无息流动负债',
noncurrent_exint DECIMAL(19,4) default 0 comment '无息非流动负债',
interestdebt DECIMAL(19,4) default 0 comment '带息债务',
netdebt DECIMAL(19,4) default 0 comment '净债务',
tangible_asset DECIMAL(19,4) default 0 comment '有形资产',
working_capital DECIMAL(19,4) default 0 comment '营运资金',
networking_capital DECIMAL(19,4) default 0 comment '营运流动资本',
invest_capital DECIMAL(19,4) default 0 comment '全部投入资本',
retained_earnings DECIMAL(19,4) default 0 comment '留存收益',
diluted2_eps DECIMAL(19,4) default 0 comment '期末摊薄每股收益',
bps DECIMAL(19,4) default 0 comment '每股净资产',
ocfps DECIMAL(19,4) default 0 comment '每股经营活动产生的现金流量净额',
retainedps DECIMAL(19,4) default 0 comment '每股留存收益',
cfps DECIMAL(19,4) default 0 comment '每股现金流量净额',
ebit_ps DECIMAL(19,4) default 0 comment '每股息税前利润',
fcff_ps DECIMAL(19,4) default 0 comment '每股企业自由现金流量',
fcfe_ps DECIMAL(19,4) default 0 comment '每股股东自由现金流量',
netprofit_margin DECIMAL(19,4) default 0 comment '销售净利率',
grossprofit_margin DECIMAL(19,4) default 0 comment '销售毛利率',
cogs_of_sales DECIMAL(19,4) default 0 comment '销售成本率',
expense_of_sales DECIMAL(19,4) default 0 comment '销售期间费用率',
profit_to_gr DECIMAL(19,4) default 0 comment '净利润/营业总收入',
saleexp_to_gr DECIMAL(19,4) default 0 comment '销售费用/营业总收入',
adminexp_of_gr DECIMAL(19,4) default 0 comment '管理费用/营业总收入',
finaexp_of_gr DECIMAL(19,4) default 0 comment '财务费用/营业总收入',
impai_ttm DECIMAL(19,4) default 0 comment '资产减值损失/营业总收入',
gc_of_gr DECIMAL(19,4) default 0 comment '营业总成本/营业总收入',
op_of_gr DECIMAL(19,4) default 0 comment '营业利润/营业总收入',
ebit_of_gr DECIMAL(19,4) default 0 comment '息税前利润/营业总收入',
roe DECIMAL(19,4) default 0 comment '净资产收益率',
roe_waa DECIMAL(19,4) default 0 comment '加权平均净资产收益率',
roe_dt DECIMAL(19,4) default 0 comment '净资产收益率(扣除非经常损益)',
roa DECIMAL(19,4) default 0 comment '总资产报酬率',
npta DECIMAL(19,4) default 0 comment '总资产净利润',
roic DECIMAL(19,4) default 0 comment '投入资本回报率',
roe_yearly DECIMAL(19,4) default 0 comment '年化净资产收益率',
roa2_yearly DECIMAL(19,4) default 0 comment '年化总资产报酬率',
roe_avg DECIMAL(19,4) default 0 comment '平均净资产收益率(增发条件)',
opincome_of_ebt DECIMAL(19,4) default 0 comment '经营活动净收益/利润总额',
investincome_of_ebt DECIMAL(19,4) default 0 comment '价值变动净收益/利润总额',
n_op_profit_of_ebt DECIMAL(19,4) default 0 comment '营业外收支净额/利润总额',
tax_to_ebt DECIMAL(19,4) default 0 comment '所得税/利润总额',
dtprofit_to_profit DECIMAL(19,4) default 0 comment '扣除非经常损益后的净利润/净利润',
salescash_to_or DECIMAL(19,4) default 0 comment '销售商品提供劳务收到的现金/营业收入',
ocf_to_or DECIMAL(19,4) default 0 comment '经营活动产生的现金流量净额/营业收入',
ocf_to_opincome DECIMAL(19,4) default 0 comment '经营活动产生的现金流量净额/经营活动净收益',
capitalized_to_da DECIMAL(19,4) default 0 comment '资本支出/折旧和摊销',
debt_to_assets DECIMAL(19,4) default 0 comment '资产负债率',
assets_to_eqt DECIMAL(19,4) default 0 comment '权益乘数',
dp_assets_to_eqt DECIMAL(19,4) default 0 comment '权益乘数(杜邦分析)',
ca_to_assets DECIMAL(19,4) default 0 comment '流动资产/总资产',
nca_to_assets DECIMAL(19,4) default 0 comment '非流动资产/总资产',
tbassets_to_totalassets DECIMAL(19,4) default 0 comment '有形资产/总资产',
int_to_talcap DECIMAL(19,4) default 0 comment '带息债务/全部投入资本',
eqt_to_talcapital DECIMAL(19,4) default 0 comment '归属于母公司的股东权益/全部投入资本',
currentdebt_to_debt DECIMAL(19,4) default 0 comment '流动负债/负债合计',
longdeb_to_debt DECIMAL(19,4) default 0 comment '非流动负债/负债合计',
ocf_to_shortdebt DECIMAL(19,4) default 0 comment '经营活动产生的现金流量净额/流动负债',
debt_to_eqt DECIMAL(19,4) default 0 comment '产权比率',
eqt_to_debt DECIMAL(19,4) default 0 comment '归属于母公司的股东权益/负债合计',
eqt_to_interestdebt DECIMAL(19,4) default 0 comment '归属于母公司的股东权益/带息债务',
tangibleasset_to_debt DECIMAL(19,4) default 0 comment '有形资产/负债合计',
tangasset_to_intdebt DECIMAL(19,4) default 0 comment '有形资产/带息债务',
tangibleasset_to_netdebt DECIMAL(19,4) default 0 comment '有形资产/净债务',
ocf_to_debt DECIMAL(19,4) default 0 comment '经营活动产生的现金流量净额/负债合计',
ocf_to_interestdebt DECIMAL(19,4) default 0 comment '经营活动产生的现金流量净额/带息债务',
ocf_to_netdebt DECIMAL(19,4) default 0 comment '经营活动产生的现金流量净额/净债务',
ebit_to_interest DECIMAL(19,4) default 0 comment '已获利息倍数(EBIT/利息费用)',
longdebt_to_workingcapital DECIMAL(19,4) default 0 comment '长期债务与营运资金比率',
ebitda_to_debt DECIMAL(19,4) default 0 comment '息税折旧摊销前利润/负债合计',
turn_days DECIMAL(19,4) default 0 comment '营业周期',
roa_yearly DECIMAL(19,4) default 0 comment '年化总资产净利率',
roa_dp DECIMAL(19,4) default 0 comment '总资产净利率(杜邦分析)',
fixed_assets DECIMAL(19,4) default 0 comment '固定资产合计',
profit_prefin_exp DECIMAL(19,4) default 0 comment ' 扣除财务费用前营业利润',
non_op_profit DECIMAL(19,4) default 0 comment '非营业利润',
op_to_ebt DECIMAL(19,4) default 0 comment '营业利润/利润总额',
nop_to_ebt DECIMAL(19,4) default 0 comment '非营业利润/利润总额',
ocf_to_profit DECIMAL(19,4) default 0 comment '经营活动产生的现金流量净额/营业利润',
cash_to_liqdebt DECIMAL(19,4) default 0 comment '货币资金/流动负债',
cash_to_liqdebt_withinterest DECIMAL(19,4) default 0 comment '货币资金/带息流动负债',
op_to_liqdebt DECIMAL(19,4) default 0 comment '营业利润/流动负债',
op_to_debt DECIMAL(19,4) default 0 comment '营业利润/负债合计',
roic_yearly DECIMAL(19,4) default 0 comment '年化投入资本回报率',
total_fa_trun DECIMAL(19,4) default 0 comment '固定资产合计周转率',
profit_to_op DECIMAL(19,4) default 0 comment '利润总额/营业收入',
q_opincome DECIMAL(19,4) default 0 comment '经营活动单季度净收益',
q_investincome DECIMAL(19,4) default 0 comment '价值变动单季度净收益',
q_dtprofit DECIMAL(19,4) default 0 comment '扣除非经常损益后的单季度净利润',
q_eps DECIMAL(19,4) default 0 comment '每股收益(单季度)',
q_netprofit_margin DECIMAL(19,4) default 0 comment '销售净利率(单季度)',
q_gsprofit_margin DECIMAL(19,4) default 0 comment '销售毛利率(单季度)',
q_exp_to_sales DECIMAL(19,4) default 0 comment '销售期间费用率(单季度)',
q_profit_to_gr DECIMAL(19,4) default 0 comment '净利润/营业总收入(单季度)',
q_saleexp_to_gr DECIMAL(19,4) default 0 comment '销售费用/营业总收入 (单季度)',
q_adminexp_to_gr DECIMAL(19,4) default 0 comment '管理费用/营业总收入 (单季度)',
q_finaexp_to_gr DECIMAL(19,4) default 0 comment '财务费用/营业总收入 (单季度)',
q_impair_to_gr_ttm DECIMAL(19,4) default 0 comment '资产减值损失/营业总收入(单季度)',
q_gc_to_gr DECIMAL(19,4) default 0 comment '营业总成本/营业总收入 (单季度)',
q_op_to_gr DECIMAL(19,4) default 0 comment '营业利润/营业总收入(单季度)',
q_roe DECIMAL(19,4) default 0 comment '净资产收益率(单季度)',
q_dt_roe DECIMAL(19,4) default 0 comment '净资产单季度收益率(扣除非经常损益)',
q_npta DECIMAL(19,4) default 0 comment '总资产净利润(单季度)',
q_opincome_to_ebt DECIMAL(19,4) default 0 comment '经营活动净收益/利润总额(单季度)',
q_investincome_to_ebt DECIMAL(19,4) default 0 comment '价值变动净收益/利润总额(单季度)',
q_dtprofit_to_profit DECIMAL(19,4) default 0 comment '扣除非经常损益后的净利润/净利润(单季度)',
q_salescash_to_or DECIMAL(19,4) default 0 comment '销售商品提供劳务收到的现金/营业收入(单季度)',
q_ocf_to_sales DECIMAL(19,4) default 0 comment '经营活动产生的现金流量净额/营业收入(单季度)',
q_ocf_to_or DECIMAL(19,4) default 0 comment '经营活动产生的现金流量净额/经营活动净收益(单季度)',
basic_eps_yoy DECIMAL(19,4) default 0 comment '基本每股收益同比增长率(%)',
dt_eps_yoy DECIMAL(19,4) default 0 comment '稀释每股收益同比增长率(%)',
cfps_yoy DECIMAL(19,4) default 0 comment ' 每股经营活动产生的现金流量净额同比增长率(%)',
op_yoy DECIMAL(19,4) default 0 comment '营业利润同比增长率(%)',
ebt_yoy DECIMAL(19,4) default 0 comment '利润总额同比增长率(%)',
netprofit_yoy DECIMAL(19,4) default 0 comment '归属母公司股东的净利润同比增长率(%)',
dt_netprofit_yoy DECIMAL(19,4) default 0 comment '归属母公司股东的净利润-扣除非经常损益同比增长率(%)',
ocf_yoy DECIMAL(19,4) default 0 comment '经营活动产生的现金流量净额同比增长率(%)',
roe_yoy DECIMAL(19,4) default 0 comment '净资产收益率(摊薄)同比增长率(%)',
bps_yoy DECIMAL(19,4) default 0 comment '每股净资产相对年初增长率(%)',
assets_yoy DECIMAL(19,4) default 0 comment '资产总计相对年初增长率(%)',
eqt_yoy DECIMAL(19,4) default 0 comment '归属母公司的股东权益相对年初增长率(%)',
tr_yoy DECIMAL(19,4) default 0 comment '营业总收入同比增长率(%)',
or_yoy DECIMAL(19,4) default 0 comment '营业收入同比增长率(%)',
q_gr_yoy DECIMAL(19,4) default 0 comment '营业总收入同比增长率(%)(单季度)',
q_gr_qoq DECIMAL(19,4) default 0 comment '营业总收入环比增长率(%)(单季度)',
q_sales_yoy DECIMAL(19,4) default 0 comment '营业收入同比增长率(%)(单季度)',
q_sales_qoq DECIMAL(19,4) default 0 comment '营业收入环比增长率(%)(单季度)',
q_op_yoy DECIMAL(19,4) default 0 comment '营业利润同比增长率(%)(单季度)',
q_op_qoq DECIMAL(19,4) default 0 comment '营业利润环比增长率(%)(单季度)',
q_profit_yoy DECIMAL(19,4) default 0 comment '净利润同比增长率(%)(单季度)',
q_profit_qoq DECIMAL(19,4) default 0 comment '净利润环比增长率(%)(单季度)',
q_netprofit_yoy DECIMAL(19,4) default 0 comment '归属母公司股东的净利润同比增长率(%)(单季度)',
q_netprofit_qoq DECIMAL(19,4) default 0 comment '归属母公司股东的净利润环比增长率(%)(单季度)',
equity_yoy DECIMAL(19,4) default 0 comment '净资产同比增长率',
rd_exp DECIMAL(19,4) default 0 comment '研发费用',
update_flag varchar(16) default '' comment '更新标识',
PRIMARY KEY (ts_code, ann_date, end_date, update_flag)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
create table if not exists t_ods_hs_indicator_list (
ts_code varchar(32) default '' comment 'TS代码',
name varchar(32) default '' comment '简称',
fullname varchar(128) default '' comment '指数全称',
market varchar(32) default '' comment '市场',
publisher varchar(128) default '' comment '发布方',
index_type varchar(128) default '' comment '指数风格',
category varchar(32) default '' comment '指数类别',
base_date varchar(32) default '' comment '基期',
base_point float default 0 comment '基点',
list_date varchar(32) default '' comment '发布日期',
weight_rule varchar(32) default '' comment '加权方式',
ts_desc varchar(1024) default '' comment '描述',
exp_date varchar(32) default '' comment '终止日期',
PRIMARY KEY (ts_code)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
create table if not exists t_ods_hs_daily_basic (
ts_code varchar(32) default '' comment 'TS代码',
trade_date varchar(32) default '' comment '交易日期',
close DECIMAL(19,4) default 0 comment '当日收盘价',
turnover_rate DECIMAL(19,4) default 0 comment '换手率',
turnover_rate_f DECIMAL(19,4) default 0 comment '换手率(自由流通股)',
volume_ratio DECIMAL(19,4) default 0 comment '量比',
pe DECIMAL(19,4) default 0 comment '市盈率(总市值/净利润)',
pe_ttm DECIMAL(19,4) default 0 comment '市盈率TTM',
pb DECIMAL(19,4) default 0 comment '市净率(总市值/净资产)',
ps DECIMAL(19,4) default 0 comment '市销率',
ps_ttm DECIMAL(19,4) default 0 comment '市销率TTM',
dv_ratio DECIMAL(19,4) default 0 comment '股息率(%',
dv_ttm DECIMAL(19,4) default 0 comment '股息率TTM',
total_share DECIMAL(19,4) default 0 comment '总股本',
float_share DECIMAL(19,4) default 0 comment '流通股本',
free_share DECIMAL(19,4) default 0 comment '自由流通股本',
total_mv DECIMAL(22,4) default 0 comment '总市值',
circ_mv DECIMAL(22,4) default 0 comment '流通市值',
limit_status int default 0 comment '涨跌停状态',
PRIMARY KEY (ts_code, trade_date)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

5223
tushare/src/income.log Normal file

File diff suppressed because it is too large Load Diff

5223
tushare/src/indicator.log Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,72 @@
import tushare as ts
import MySQLdb
from config import CONFIG_DB
from config import CONFIG_TS
db = MySQLdb.connect(CONFIG_DB['host'], CONFIG_DB['user'], CONFIG_DB['password'], CONFIG_DB['database'], charset='utf8')
pro = ts.pro_api(CONFIG_TS['secret'])
# limit 2000 rows per request
df = pro.new_share(**{
"start_date": 20000101,
"end_date": 20071231,
# "start_date": 20080101,
# "end_date": 20111231,
# "start_date": 20120101,
# "end_date": 20131231,
# "start_date": 20140101,
# "end_date": 20151231,
# "start_date": 20160101,
# "end_date": 20171231,
# "start_date": 20180101,
# "end_date": 20191231,
# "start_date": 20200101,
# "end_date": 20220629,
"limit": "",
"offset": ""
}, fields=[
"ts_code",
"sub_code",
"name",
"ipo_date",
"issue_date",
"amount",
"market_amount",
"price",
"pe",
"limit_amount",
"funds",
"ballot"
])
cursor = db.cursor()
loop = 0
for row in df.itertuples():
sql = "insert into t_ods_hs_base_ipo(ts_code, sub_code, name, ipo_date, issue_date, \
amount, market_amount, price, pe, limit_amount, funds, ballot) \
values('%s', '%s', '%s', '%s', '%s', %f, %f, %f, %f, %f, %f, %f ) \
on duplicate key update sub_code= '%s', name='%s', ipo_date='%s', issue_date='%s', \
amount=%f, market_amount=%f, price=%f, pe=%f, limit_amount=%f, funds=%f, ballot=%f " % \
(getattr(row, 'ts_code'), getattr(row, 'sub_code'), getattr(row, 'name'), getattr(row, 'ipo_date')
, getattr(row, 'issue_date'), float(getattr(row, 'amount')), float(getattr(row, 'market_amount'))
, float(getattr(row, 'price')), float(getattr(row, 'pe')), float(getattr(row, 'limit_amount'))
, float(getattr(row, 'funds')), float(getattr(row, 'ballot'))
, getattr(row, 'sub_code'), getattr(row, 'name'), getattr(row, 'ipo_date')
, getattr(row, 'issue_date'), float(getattr(row, 'amount')), float(getattr(row, 'market_amount'))
, float(getattr(row, 'price')), float(getattr(row, 'pe')), float(getattr(row, 'limit_amount'))
, float(getattr(row, 'funds')), float(getattr(row, 'ballot')))
try:
cursor.execute(sql)
db.commit()
loop = loop+1
except Exception as ex:
print (ex)
db.rollback()
break
print("task complete! total rows: %d" % loop)
db.close()

View File

@ -0,0 +1,65 @@
import tushare as ts
import MySQLdb
from config import CONFIG_DB
from config import CONFIG_TS
db = MySQLdb.connect(CONFIG_DB['host'], CONFIG_DB['user'], CONFIG_DB['password'], CONFIG_DB['database'], charset='utf8')
pro = ts.pro_api(CONFIG_TS['secret'])
df = pro.stock_basic(**{
"ts_code": "",
"name": "",
"exchange": "",
"market": "",
"is_hs": "",
"list_status": "",
"limit": "",
"offset": ""
}, fields=[
"ts_code",
"symbol",
"name",
"area",
"industry",
"market",
"list_date",
"fullname",
"enname",
"cnspell",
"exchange",
"curr_type",
"list_status",
"delist_date",
"is_hs"
])
cursor = db.cursor()
for row in df.itertuples():
sql = "insert into t_ods_hs_base_list(ts_code, symbol, name, area, industry, fullname, enname, \
cnspell, market, exchange, curr_type, list_status, list_date, is_hs) \
values('%s', '%s', '%s', '%s', '%s', '%s', \"%s\", '%s', '%s', '%s', '%s', '%s', '%s', '%s') \
on duplicate key update symbol= '%s', name= '%s', area='%s', industry='%s', fullname='%s', \
enname=\"%s\", cnspell='%s', market='%s', exchange='%s', curr_type='%s', list_status='%s', \
list_date='%s', is_hs='%s' " % \
(getattr(row, 'ts_code'), getattr(row, 'symbol'), getattr(row, 'name'), getattr(row, 'area')
, getattr(row, 'industry'), getattr(row, 'fullname'), getattr(row, 'enname'), getattr(row, 'cnspell')
, getattr(row, 'market'), getattr(row, 'exchange'), getattr(row, 'curr_type'), getattr(row, 'list_status')
, getattr(row, 'list_date'), getattr(row, 'is_hs'),
getattr(row, 'symbol'), getattr(row, 'name'), getattr(row, 'area')
, getattr(row, 'industry'), getattr(row, 'fullname'), getattr(row, 'enname'), getattr(row, 'cnspell')
, getattr(row, 'market'), getattr(row, 'exchange'), getattr(row, 'curr_type'), getattr(row, 'list_status')
, getattr(row, 'list_date'), getattr(row, 'is_hs'))
try:
cursor.execute(sql)
db.commit()
except Exception as ex:
print (ex)
db.rollback()
break
db.close()

View File

@ -0,0 +1,82 @@
import tushare as ts
import MySQLdb
import math
from config import CONFIG_DB
from config import CONFIG_TS
db = MySQLdb.connect(CONFIG_DB['host'], CONFIG_DB['user'], CONFIG_DB['password'], CONFIG_DB['database'], charset='utf8')
pro = ts.pro_api(CONFIG_TS['secret'])
def NanVal( val ):
if (val is None) :
return 0.0
if (math.isnan(val)):
return 0.0
return val
df = pro.daily_basic(**{
"ts_code": "",
"trade_date": 20230531,
"start_date": "",
"end_date": "",
"limit": "",
"offset": ""
}, fields=[
"ts_code",
"trade_date",
"close",
"turnover_rate",
"turnover_rate_f",
"volume_ratio",
"pe",
"pe_ttm",
"pb",
"ps",
"ps_ttm",
"dv_ratio",
"dv_ttm",
"total_share",
"float_share",
"free_share",
"total_mv",
"circ_mv",
"limit_status"
])
cursor = db.cursor()
for row in df.itertuples():
sql = "insert into t_ods_hs_daily_basic(ts_code, trade_date, close, turnover_rate, turnover_rate_f, volume_ratio, pe, \
pe_ttm, pb, ps, ps_ttm, dv_ratio, dv_ttm, total_share, float_share, free_share, total_mv, circ_mv, limit_status) \
values('%s', '%s', %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %d) \
on duplicate key update close=%f, turnover_rate=%f, turnover_rate_f=%f, volume_ratio=%f, pe=%f, pe_ttm=%f, pb=%f, \
ps=%f, ps_ttm=%f, dv_ratio=%f, dv_ttm=%f, total_share=%f, float_share=%f, free_share=%f, total_mv=%f, circ_mv=%f, \
limit_status=%d " % \
(getattr(row, 'ts_code'), getattr(row, 'trade_date'),
NanVal(getattr(row, 'close')), NanVal(getattr(row, 'turnover_rate')), NanVal(getattr(row, 'turnover_rate_f')),
NanVal(getattr(row, 'volume_ratio')), NanVal(getattr(row, 'pe')), NanVal(getattr(row, 'pe_ttm')), NanVal(getattr(row, 'pb')),
NanVal(getattr(row, 'ps')), NanVal(getattr(row, 'ps_ttm')), NanVal(getattr(row, 'dv_ratio')), NanVal(getattr(row, 'dv_ttm')),
NanVal(getattr(row, 'total_share')), NanVal(getattr(row, 'float_share')), NanVal(getattr(row, 'free_share')),
NanVal(getattr(row, 'total_mv')), NanVal(getattr(row, 'circ_mv')), NanVal(getattr(row, 'limit_status')),
NanVal(getattr(row, 'close')), NanVal(getattr(row, 'turnover_rate')), NanVal(getattr(row, 'turnover_rate_f')),
NanVal(getattr(row, 'volume_ratio')), NanVal(getattr(row, 'pe')), NanVal(getattr(row, 'pe_ttm')), NanVal(getattr(row, 'pb')),
NanVal(getattr(row, 'ps')), NanVal(getattr(row, 'ps_ttm')), NanVal(getattr(row, 'dv_ratio')), NanVal(getattr(row, 'dv_ttm')),
NanVal(getattr(row, 'total_share')), NanVal(getattr(row, 'float_share')), NanVal(getattr(row, 'free_share')),
NanVal(getattr(row, 'total_mv')), NanVal(getattr(row, 'circ_mv')), NanVal(getattr(row, 'limit_status'))
)
try:
cursor.execute(sql)
db.commit()
except Exception as ex:
print(sql)
print (ex)
db.rollback()
break
db.close()

View File

@ -0,0 +1,401 @@
import tushare as ts
import MySQLdb
import math
import time
from config import CONFIG_DB
from config import CONFIG_TS
db = MySQLdb.connect(CONFIG_DB['host'], CONFIG_DB['user'], CONFIG_DB['password'], CONFIG_DB['database'], charset='utf8')
pro = ts.pro_api(CONFIG_TS['secret'])
def str2float( str ):
try:
val = float(str)
if math.isinf(val) or math.isnan(val) :
val = 0
return val
except Exception as e:
return 0.0
def queryts( code ) :
df = pro.balancesheet(**{
"ts_code": code,
"ann_date": "",
"f_ann_date": "",
"start_date": 20220630,
"end_date": 20230604,
"period": "",
"report_type": "",
"comp_type": "",
"end_type": "",
"limit": "",
"offset": ""
}, fields=[
"ts_code",
"ann_date",
"f_ann_date",
"end_date",
"report_type",
"comp_type",
"end_type",
"total_share",
"cap_rese",
"undistr_porfit",
"surplus_rese",
"special_rese",
"money_cap",
"trad_asset",
"notes_receiv",
"accounts_receiv",
"oth_receiv",
"prepayment",
"div_receiv",
"int_receiv",
"inventories",
"amor_exp",
"nca_within_1y",
"sett_rsrv",
"loanto_oth_bank_fi",
"premium_receiv",
"reinsur_receiv",
"reinsur_res_receiv",
"pur_resale_fa",
"oth_cur_assets",
"total_cur_assets",
"fa_avail_for_sale",
"htm_invest",
"lt_eqt_invest",
"invest_real_estate",
"time_deposits",
"oth_assets",
"lt_rec",
"fix_assets",
"cip",
"const_materials",
"fixed_assets_disp",
"produc_bio_assets",
"oil_and_gas_assets",
"intan_assets",
"r_and_d",
"goodwill",
"lt_amor_exp",
"defer_tax_assets",
"decr_in_disbur",
"oth_nca",
"total_nca",
"cash_reser_cb",
"depos_in_oth_bfi",
"prec_metals",
"deriv_assets",
"rr_reins_une_prem",
"rr_reins_outstd_cla",
"rr_reins_lins_liab",
"rr_reins_lthins_liab",
"refund_depos",
"ph_pledge_loans",
"refund_cap_depos",
"indep_acct_assets",
"client_depos",
"client_prov",
"transac_seat_fee",
"invest_as_receiv",
"total_assets",
"lt_borr",
"st_borr",
"cb_borr",
"depos_ib_deposits",
"loan_oth_bank",
"trading_fl",
"notes_payable",
"acct_payable",
"adv_receipts",
"sold_for_repur_fa",
"comm_payable",
"payroll_payable",
"taxes_payable",
"int_payable",
"div_payable",
"oth_payable",
"acc_exp",
"deferred_inc",
"st_bonds_payable",
"payable_to_reinsurer",
"rsrv_insur_cont",
"acting_trading_sec",
"acting_uw_sec",
"non_cur_liab_due_1y",
"oth_cur_liab",
"total_cur_liab",
"bond_payable",
"lt_payable",
"specific_payables",
"estimated_liab",
"defer_tax_liab",
"defer_inc_non_cur_liab",
"oth_ncl",
"total_ncl",
"depos_oth_bfi",
"deriv_liab",
"depos",
"agency_bus_liab",
"oth_liab",
"prem_receiv_adva",
"depos_received",
"ph_invest",
"reser_une_prem",
"reser_outstd_claims",
"reser_lins_liab",
"reser_lthins_liab",
"indept_acc_liab",
"pledge_borr",
"indem_payable",
"policy_div_payable",
"total_liab",
"treasury_share",
"ordin_risk_reser",
"forex_differ",
"invest_loss_unconf",
"minority_int",
"total_hldr_eqy_exc_min_int",
"total_hldr_eqy_inc_min_int",
"total_liab_hldr_eqy",
"lt_payroll_payable",
"oth_comp_income",
"oth_eqt_tools",
"oth_eqt_tools_p_shr",
"lending_funds",
"acc_receivable",
"st_fin_payable",
"payables",
"hfs_assets",
"hfs_sales",
"cost_fin_assets",
"fair_value_fin_assets",
"contract_assets",
"contract_liab",
"accounts_receiv_bill",
"accounts_pay",
"oth_rcv_total",
"fix_assets_total",
"cip_total",
"oth_pay_total",
"long_pay_total",
"debt_invest",
"oth_debt_invest",
"oth_eq_invest",
"oth_illiq_fin_assets",
"oth_eq_ppbond",
"receiv_financing",
"use_right_assets",
"lease_liab",
"update_flag"
])
return df
def getsqlstr(row):
sqlstr = "insert into t_ods_hs_finance_balance(ts_code, ann_date, f_ann_date, end_date, report_type, comp_type, \
end_type, total_share, cap_rese, undistr_porfit, surplus_rese, special_rese, money_cap, trad_asset, notes_receiv, \
accounts_receiv, oth_receiv, prepayment, div_receiv, int_receiv, inventories, amor_exp, nca_within_1y, sett_rsrv, \
loanto_oth_bank_fi, premium_receiv, reinsur_receiv, reinsur_res_receiv, pur_resale_fa, oth_cur_assets, total_cur_assets, \
fa_avail_for_sale, htm_invest, lt_eqt_invest, invest_real_estate, time_deposits, oth_assets, lt_rec, fix_assets, cip, \
const_materials, fixed_assets_disp, produc_bio_assets, oil_and_gas_assets, intan_assets, r_and_d, goodwill, lt_amor_exp, \
defer_tax_assets, decr_in_disbur, oth_nca, total_nca, cash_reser_cb, depos_in_oth_bfi, prec_metals, deriv_assets, rr_reins_une_prem, \
rr_reins_outstd_cla, rr_reins_lins_liab, rr_reins_lthins_liab, refund_depos, ph_pledge_loans, refund_cap_depos, indep_acct_assets, \
client_depos, client_prov, transac_seat_fee, invest_as_receiv, total_assets, lt_borr, st_borr, cb_borr, depos_ib_deposits, loan_oth_bank, \
trading_fl, notes_payable, acct_payable, adv_receipts, sold_for_repur_fa, comm_payable, payroll_payable, taxes_payable, int_payable, \
div_payable, oth_payable, acc_exp, deferred_inc, st_bonds_payable, payable_to_reinsurer, rsrv_insur_cont, acting_trading_sec, acting_uw_sec, \
non_cur_liab_due_1y, oth_cur_liab, total_cur_liab, bond_payable, lt_payable, specific_payables, estimated_liab, defer_tax_liab, \
defer_inc_non_cur_liab, oth_ncl, total_ncl, depos_oth_bfi, deriv_liab, depos, agency_bus_liab, oth_liab, prem_receiv_adva, depos_received, \
ph_invest, reser_une_prem, reser_outstd_claims, reser_lins_liab, reser_lthins_liab, indept_acc_liab, pledge_borr, indem_payable, policy_div_payable, \
total_liab, treasury_share, ordin_risk_reser, forex_differ, invest_loss_unconf, minority_int, total_hldr_eqy_exc_min_int, total_hldr_eqy_inc_min_int, \
total_liab_hldr_eqy, lt_payroll_payable, oth_comp_income, oth_eqt_tools, oth_eqt_tools_p_shr, lending_funds, acc_receivable, st_fin_payable, \
payables, hfs_assets, hfs_sales, cost_fin_assets, fair_value_fin_assets, contract_assets, contract_liab, accounts_receiv_bill, accounts_pay, \
oth_rcv_total, fix_assets_total, cip_total, oth_pay_total, long_pay_total, debt_invest, oth_debt_invest, oth_eq_invest, oth_illiq_fin_assets, \
oth_eq_ppbond, receiv_financing, use_right_assets, lease_liab, update_flag) \
values('%s', '%s', '%s', '%s', '%s', '%s', '%s', \
%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, \
%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, \
%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, \
%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, \
%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, \
%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, \
%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, \
%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, '%s') \
on duplicate key update report_type='%s', comp_type='%s', end_type='%s', \
total_share=%f, cap_rese=%f, undistr_porfit=%f, surplus_rese=%f, special_rese=%f, money_cap=%f, trad_asset=%f, notes_receiv=%f, accounts_receiv=%f, \
oth_receiv=%f, prepayment=%f, div_receiv=%f, int_receiv=%f, inventories=%f, amor_exp=%f, nca_within_1y=%f, sett_rsrv=%f, loanto_oth_bank_fi=%f, \
premium_receiv=%f, reinsur_receiv=%f, reinsur_res_receiv=%f, pur_resale_fa=%f, oth_cur_assets=%f, total_cur_assets=%f, fa_avail_for_sale=%f, \
htm_invest=%f, lt_eqt_invest=%f, invest_real_estate=%f, time_deposits=%f, oth_assets=%f, lt_rec=%f, fix_assets=%f, cip=%f, const_materials=%f, \
fixed_assets_disp=%f, produc_bio_assets=%f, oil_and_gas_assets=%f, intan_assets=%f, r_and_d=%f, goodwill=%f, lt_amor_exp=%f, defer_tax_assets=%f, \
decr_in_disbur=%f, oth_nca=%f, total_nca=%f, cash_reser_cb=%f, depos_in_oth_bfi=%f, prec_metals=%f, deriv_assets=%f, rr_reins_une_prem=%f, \
rr_reins_outstd_cla=%f, rr_reins_lins_liab=%f, rr_reins_lthins_liab=%f, refund_depos=%f, ph_pledge_loans=%f, refund_cap_depos=%f, indep_acct_assets=%f, \
client_depos=%f, client_prov=%f, transac_seat_fee=%f, invest_as_receiv=%f, total_assets=%f, lt_borr=%f, st_borr=%f, cb_borr=%f, depos_ib_deposits=%f, \
loan_oth_bank=%f, trading_fl=%f, notes_payable=%f, acct_payable=%f, adv_receipts=%f, sold_for_repur_fa=%f, comm_payable=%f, payroll_payable=%f, \
taxes_payable=%f, int_payable=%f, div_payable=%f, oth_payable=%f, acc_exp=%f, deferred_inc=%f, st_bonds_payable=%f, payable_to_reinsurer=%f, \
rsrv_insur_cont=%f, acting_trading_sec=%f, acting_uw_sec=%f, non_cur_liab_due_1y=%f, oth_cur_liab=%f, total_cur_liab=%f, bond_payable=%f, lt_payable=%f, \
specific_payables=%f, estimated_liab=%f, defer_tax_liab=%f, defer_inc_non_cur_liab=%f, oth_ncl=%f, total_ncl=%f, depos_oth_bfi=%f, deriv_liab=%f, depos=%f, \
agency_bus_liab=%f, oth_liab=%f, prem_receiv_adva=%f, depos_received=%f, ph_invest=%f, reser_une_prem=%f, reser_outstd_claims=%f, reser_lins_liab=%f, \
reser_lthins_liab=%f, indept_acc_liab=%f, pledge_borr=%f, indem_payable=%f, policy_div_payable=%f, total_liab=%f, treasury_share=%f, ordin_risk_reser=%f, \
forex_differ=%f, invest_loss_unconf=%f, minority_int=%f, total_hldr_eqy_exc_min_int=%f, total_hldr_eqy_inc_min_int=%f, total_liab_hldr_eqy=%f, \
lt_payroll_payable=%f, oth_comp_income=%f, oth_eqt_tools=%f, oth_eqt_tools_p_shr=%f, lending_funds=%f, acc_receivable=%f, st_fin_payable=%f, payables=%f, \
hfs_assets=%f, hfs_sales=%f, cost_fin_assets=%f, fair_value_fin_assets=%f, contract_assets=%f, contract_liab=%f, accounts_receiv_bill=%f, accounts_pay=%f, \
oth_rcv_total=%f, fix_assets_total=%f, cip_total=%f, oth_pay_total=%f, long_pay_total=%f, debt_invest=%f, oth_debt_invest=%f, oth_eq_invest=%f, \
oth_illiq_fin_assets=%f, oth_eq_ppbond=%f, receiv_financing=%f, use_right_assets=%f, lease_liab=%f " % (
getattr(row, 'ts_code'), getattr(row, 'ann_date'), getattr(row, 'f_ann_date'), getattr(row, 'end_date'),
getattr(row, 'report_type'), getattr(row, 'comp_type'), getattr(row, 'end_type'),
str2float(getattr(row, 'total_share')), str2float(getattr(row, 'cap_rese')), str2float(getattr(row, 'undistr_porfit')),
str2float(getattr(row, 'surplus_rese')), str2float(getattr(row, 'special_rese')), str2float(getattr(row, 'money_cap')),
str2float(getattr(row, 'trad_asset')), str2float(getattr(row, 'notes_receiv')), str2float(getattr(row, 'accounts_receiv')),
str2float(getattr(row, 'oth_receiv')), str2float(getattr(row, 'prepayment')), str2float(getattr(row, 'div_receiv')),
str2float(getattr(row, 'int_receiv')), str2float(getattr(row, 'inventories')), str2float(getattr(row, 'amor_exp')),
str2float(getattr(row, 'nca_within_1y')), str2float(getattr(row, 'sett_rsrv')), str2float(getattr(row, 'loanto_oth_bank_fi')),
str2float(getattr(row, 'premium_receiv')), str2float(getattr(row, 'reinsur_receiv')), str2float(getattr(row, 'reinsur_res_receiv')),
str2float(getattr(row, 'pur_resale_fa')), str2float(getattr(row, 'oth_cur_assets')), str2float(getattr(row, 'total_cur_assets')),
str2float(getattr(row, 'fa_avail_for_sale')), str2float(getattr(row, 'htm_invest')), str2float(getattr(row, 'lt_eqt_invest')),
str2float(getattr(row, 'invest_real_estate')), str2float(getattr(row, 'time_deposits')), str2float(getattr(row, 'oth_assets')),
str2float(getattr(row, 'lt_rec')), str2float(getattr(row, 'fix_assets')), str2float(getattr(row, 'cip')),
str2float(getattr(row, 'const_materials')), str2float(getattr(row, 'fixed_assets_disp')), str2float(getattr(row, 'produc_bio_assets')),
str2float(getattr(row, 'oil_and_gas_assets')), str2float(getattr(row, 'intan_assets')), str2float(getattr(row, 'r_and_d')),
str2float(getattr(row, 'goodwill')), str2float(getattr(row, 'lt_amor_exp')), str2float(getattr(row, 'defer_tax_assets')),
str2float(getattr(row, 'decr_in_disbur')), str2float(getattr(row, 'oth_nca')), str2float(getattr(row, 'total_nca')),
str2float(getattr(row, 'cash_reser_cb')), str2float(getattr(row, 'depos_in_oth_bfi')), str2float(getattr(row, 'prec_metals')),
str2float(getattr(row, 'deriv_assets')), str2float(getattr(row, 'rr_reins_une_prem')), str2float(getattr(row, 'rr_reins_outstd_cla')),
str2float(getattr(row, 'rr_reins_lins_liab')), str2float(getattr(row, 'rr_reins_lthins_liab')), str2float(getattr(row, 'refund_depos')),
str2float(getattr(row, 'ph_pledge_loans')), str2float(getattr(row, 'refund_cap_depos')), str2float(getattr(row, 'indep_acct_assets')),
str2float(getattr(row, 'client_depos')), str2float(getattr(row, 'client_prov')), str2float(getattr(row, 'transac_seat_fee')),
str2float(getattr(row, 'invest_as_receiv')), str2float(getattr(row, 'total_assets')), str2float(getattr(row, 'lt_borr')),
str2float(getattr(row, 'st_borr')), str2float(getattr(row, 'cb_borr')), str2float(getattr(row, 'depos_ib_deposits')),
str2float(getattr(row, 'loan_oth_bank')), str2float(getattr(row, 'trading_fl')), str2float(getattr(row, 'notes_payable')),
str2float(getattr(row, 'acct_payable')), str2float(getattr(row, 'adv_receipts')), str2float(getattr(row, 'sold_for_repur_fa')),
str2float(getattr(row, 'comm_payable')), str2float(getattr(row, 'payroll_payable')), str2float(getattr(row, 'taxes_payable')),
str2float(getattr(row, 'int_payable')), str2float(getattr(row, 'div_payable')), str2float(getattr(row, 'oth_payable')),
str2float(getattr(row, 'acc_exp')), str2float(getattr(row, 'deferred_inc')), str2float(getattr(row, 'st_bonds_payable')),
str2float(getattr(row, 'payable_to_reinsurer')), str2float(getattr(row, 'rsrv_insur_cont')), str2float(getattr(row, 'acting_trading_sec')),
str2float(getattr(row, 'acting_uw_sec')), str2float(getattr(row, 'non_cur_liab_due_1y')), str2float(getattr(row, 'oth_cur_liab')),
str2float(getattr(row, 'total_cur_liab')), str2float(getattr(row, 'bond_payable')), str2float(getattr(row, 'lt_payable')),
str2float(getattr(row, 'specific_payables')), str2float(getattr(row, 'estimated_liab')), str2float(getattr(row, 'defer_tax_liab')),
str2float(getattr(row, 'defer_inc_non_cur_liab')), str2float(getattr(row, 'oth_ncl')), str2float(getattr(row, 'total_ncl')),
str2float(getattr(row, 'depos_oth_bfi')), str2float(getattr(row, 'deriv_liab')), str2float(getattr(row, 'depos')),
str2float(getattr(row, 'agency_bus_liab')), str2float(getattr(row, 'oth_liab')), str2float(getattr(row, 'prem_receiv_adva')),
str2float(getattr(row, 'depos_received')), str2float(getattr(row, 'ph_invest')), str2float(getattr(row, 'reser_une_prem')),
str2float(getattr(row, 'reser_outstd_claims')), str2float(getattr(row, 'reser_lins_liab')), str2float(getattr(row, 'reser_lthins_liab')),
str2float(getattr(row, 'indept_acc_liab')), str2float(getattr(row, 'pledge_borr')), str2float(getattr(row, 'indem_payable')),
str2float(getattr(row, 'policy_div_payable')), str2float(getattr(row, 'total_liab')), str2float(getattr(row, 'treasury_share')),
str2float(getattr(row, 'ordin_risk_reser')), str2float(getattr(row, 'forex_differ')), str2float(getattr(row, 'invest_loss_unconf')),
str2float(getattr(row, 'minority_int')), str2float(getattr(row, 'total_hldr_eqy_exc_min_int')), str2float(getattr(row, 'total_hldr_eqy_inc_min_int')),
str2float(getattr(row, 'total_liab_hldr_eqy')), str2float(getattr(row, 'lt_payroll_payable')), str2float(getattr(row, 'oth_comp_income')),
str2float(getattr(row, 'oth_eqt_tools')), str2float(getattr(row, 'oth_eqt_tools_p_shr')), str2float(getattr(row, 'lending_funds')),
str2float(getattr(row, 'acc_receivable')), str2float(getattr(row, 'st_fin_payable')), str2float(getattr(row, 'payables')),
str2float(getattr(row, 'hfs_assets')), str2float(getattr(row, 'hfs_sales')), str2float(getattr(row, 'cost_fin_assets')),
str2float(getattr(row, 'fair_value_fin_assets')), str2float(getattr(row, 'contract_assets')), str2float(getattr(row, 'contract_liab')),
str2float(getattr(row, 'accounts_receiv_bill')), str2float(getattr(row, 'accounts_pay')), str2float(getattr(row, 'oth_rcv_total')),
str2float(getattr(row, 'fix_assets_total')), str2float(getattr(row, 'cip_total')), str2float(getattr(row, 'oth_pay_total')),
str2float(getattr(row, 'long_pay_total')), str2float(getattr(row, 'debt_invest')), str2float(getattr(row, 'oth_debt_invest')),
str2float(getattr(row, 'oth_eq_invest')), str2float(getattr(row, 'oth_illiq_fin_assets')), str2float(getattr(row, 'oth_eq_ppbond')),
str2float(getattr(row, 'receiv_financing')), str2float(getattr(row, 'use_right_assets')), str2float(getattr(row, 'lease_liab')),
getattr(row, 'update_flag'),
getattr(row, 'report_type'), getattr(row, 'comp_type'), getattr(row, 'end_type'),
str2float(getattr(row, 'total_share')), str2float(getattr(row, 'cap_rese')), str2float(getattr(row, 'undistr_porfit')),
str2float(getattr(row, 'surplus_rese')), str2float(getattr(row, 'special_rese')), str2float(getattr(row, 'money_cap')),
str2float(getattr(row, 'trad_asset')), str2float(getattr(row, 'notes_receiv')), str2float(getattr(row, 'accounts_receiv')),
str2float(getattr(row, 'oth_receiv')), str2float(getattr(row, 'prepayment')), str2float(getattr(row, 'div_receiv')),
str2float(getattr(row, 'int_receiv')), str2float(getattr(row, 'inventories')), str2float(getattr(row, 'amor_exp')),
str2float(getattr(row, 'nca_within_1y')), str2float(getattr(row, 'sett_rsrv')), str2float(getattr(row, 'loanto_oth_bank_fi')),
str2float(getattr(row, 'premium_receiv')), str2float(getattr(row, 'reinsur_receiv')), str2float(getattr(row, 'reinsur_res_receiv')),
str2float(getattr(row, 'pur_resale_fa')), str2float(getattr(row, 'oth_cur_assets')), str2float(getattr(row, 'total_cur_assets')),
str2float(getattr(row, 'fa_avail_for_sale')), str2float(getattr(row, 'htm_invest')), str2float(getattr(row, 'lt_eqt_invest')),
str2float(getattr(row, 'invest_real_estate')), str2float(getattr(row, 'time_deposits')), str2float(getattr(row, 'oth_assets')),
str2float(getattr(row, 'lt_rec')), str2float(getattr(row, 'fix_assets')), str2float(getattr(row, 'cip')),
str2float(getattr(row, 'const_materials')), str2float(getattr(row, 'fixed_assets_disp')), str2float(getattr(row, 'produc_bio_assets')),
str2float(getattr(row, 'oil_and_gas_assets')), str2float(getattr(row, 'intan_assets')), str2float(getattr(row, 'r_and_d')),
str2float(getattr(row, 'goodwill')), str2float(getattr(row, 'lt_amor_exp')), str2float(getattr(row, 'defer_tax_assets')),
str2float(getattr(row, 'decr_in_disbur')), str2float(getattr(row, 'oth_nca')), str2float(getattr(row, 'total_nca')),
str2float(getattr(row, 'cash_reser_cb')), str2float(getattr(row, 'depos_in_oth_bfi')), str2float(getattr(row, 'prec_metals')),
str2float(getattr(row, 'deriv_assets')), str2float(getattr(row, 'rr_reins_une_prem')), str2float(getattr(row, 'rr_reins_outstd_cla')),
str2float(getattr(row, 'rr_reins_lins_liab')), str2float(getattr(row, 'rr_reins_lthins_liab')), str2float(getattr(row, 'refund_depos')),
str2float(getattr(row, 'ph_pledge_loans')), str2float(getattr(row, 'refund_cap_depos')), str2float(getattr(row, 'indep_acct_assets')),
str2float(getattr(row, 'client_depos')), str2float(getattr(row, 'client_prov')), str2float(getattr(row, 'transac_seat_fee')),
str2float(getattr(row, 'invest_as_receiv')), str2float(getattr(row, 'total_assets')), str2float(getattr(row, 'lt_borr')),
str2float(getattr(row, 'st_borr')), str2float(getattr(row, 'cb_borr')), str2float(getattr(row, 'depos_ib_deposits')),
str2float(getattr(row, 'loan_oth_bank')), str2float(getattr(row, 'trading_fl')), str2float(getattr(row, 'notes_payable')),
str2float(getattr(row, 'acct_payable')), str2float(getattr(row, 'adv_receipts')), str2float(getattr(row, 'sold_for_repur_fa')),
str2float(getattr(row, 'comm_payable')), str2float(getattr(row, 'payroll_payable')), str2float(getattr(row, 'taxes_payable')),
str2float(getattr(row, 'int_payable')), str2float(getattr(row, 'div_payable')), str2float(getattr(row, 'oth_payable')),
str2float(getattr(row, 'acc_exp')), str2float(getattr(row, 'deferred_inc')), str2float(getattr(row, 'st_bonds_payable')),
str2float(getattr(row, 'payable_to_reinsurer')), str2float(getattr(row, 'rsrv_insur_cont')), str2float(getattr(row, 'acting_trading_sec')),
str2float(getattr(row, 'acting_uw_sec')), str2float(getattr(row, 'non_cur_liab_due_1y')), str2float(getattr(row, 'oth_cur_liab')),
str2float(getattr(row, 'total_cur_liab')), str2float(getattr(row, 'bond_payable')), str2float(getattr(row, 'lt_payable')),
str2float(getattr(row, 'specific_payables')), str2float(getattr(row, 'estimated_liab')), str2float(getattr(row, 'defer_tax_liab')),
str2float(getattr(row, 'defer_inc_non_cur_liab')), str2float(getattr(row, 'oth_ncl')), str2float(getattr(row, 'total_ncl')),
str2float(getattr(row, 'depos_oth_bfi')), str2float(getattr(row, 'deriv_liab')), str2float(getattr(row, 'depos')),
str2float(getattr(row, 'agency_bus_liab')), str2float(getattr(row, 'oth_liab')), str2float(getattr(row, 'prem_receiv_adva')),
str2float(getattr(row, 'depos_received')), str2float(getattr(row, 'ph_invest')), str2float(getattr(row, 'reser_une_prem')),
str2float(getattr(row, 'reser_outstd_claims')), str2float(getattr(row, 'reser_lins_liab')), str2float(getattr(row, 'reser_lthins_liab')),
str2float(getattr(row, 'indept_acc_liab')), str2float(getattr(row, 'pledge_borr')), str2float(getattr(row, 'indem_payable')),
str2float(getattr(row, 'policy_div_payable')), str2float(getattr(row, 'total_liab')), str2float(getattr(row, 'treasury_share')),
str2float(getattr(row, 'ordin_risk_reser')), str2float(getattr(row, 'forex_differ')), str2float(getattr(row, 'invest_loss_unconf')),
str2float(getattr(row, 'minority_int')), str2float(getattr(row, 'total_hldr_eqy_exc_min_int')), str2float(getattr(row, 'total_hldr_eqy_inc_min_int')),
str2float(getattr(row, 'total_liab_hldr_eqy')), str2float(getattr(row, 'lt_payroll_payable')), str2float(getattr(row, 'oth_comp_income')),
str2float(getattr(row, 'oth_eqt_tools')), str2float(getattr(row, 'oth_eqt_tools_p_shr')), str2float(getattr(row, 'lending_funds')),
str2float(getattr(row, 'acc_receivable')), str2float(getattr(row, 'st_fin_payable')), str2float(getattr(row, 'payables')),
str2float(getattr(row, 'hfs_assets')), str2float(getattr(row, 'hfs_sales')), str2float(getattr(row, 'cost_fin_assets')),
str2float(getattr(row, 'fair_value_fin_assets')), str2float(getattr(row, 'contract_assets')), str2float(getattr(row, 'contract_liab')),
str2float(getattr(row, 'accounts_receiv_bill')), str2float(getattr(row, 'accounts_pay')), str2float(getattr(row, 'oth_rcv_total')),
str2float(getattr(row, 'fix_assets_total')), str2float(getattr(row, 'cip_total')), str2float(getattr(row, 'oth_pay_total')),
str2float(getattr(row, 'long_pay_total')), str2float(getattr(row, 'debt_invest')), str2float(getattr(row, 'oth_debt_invest')),
str2float(getattr(row, 'oth_eq_invest')), str2float(getattr(row, 'oth_illiq_fin_assets')), str2float(getattr(row, 'oth_eq_ppbond')),
str2float(getattr(row, 'receiv_financing')), str2float(getattr(row, 'use_right_assets')), str2float(getattr(row, 'lease_liab'))
)
return sqlstr
def process():
stock_list = []
cursor = db.cursor()
total_stocks = 0
total_rows = 0
fd = open("./balance.log", 'w+')
# get stock list
sqlstr = "select ts_code from t_ods_hs_base_list where list_status = 'L' "
try:
cursor.execute(sqlstr)
results = cursor.fetchall()
for row in results :
stock_list.append(row[0])
total_stocks = total_stocks+1
except Exception as ex:
print (ex)
print ("get stock list error!")
db.close()
return
# get income data
for st_code in stock_list :
df = queryts(st_code)
loop = 0
for row in df.itertuples():
sql = getsqlstr(row)
try:
cursor.execute(sql)
db.commit()
loop = loop+1
except Exception as ex:
print (ex)
print ("get stock %s error!" % st_code )
db.rollback()
return
print("get %s balance data succ! total rows: %d" % (st_code, loop))
fd.write("get %s balance data succ! total rows: %d \n" % (st_code, loop))
fd.flush()
total_rows = total_rows+loop
time.sleep(0.5)
# get all data
print("All stock balance data process succ! total stocks: %d, total rows: %d " % (total_stocks, total_rows))
fd.write("All stock balance data process succ! total stocks: %d, total rows: %d \n" % (total_stocks, total_rows))
# close db and file
fd.close()
db.close()
process()

View File

@ -0,0 +1,286 @@
import tushare as ts
import MySQLdb
import math
import time
from config import CONFIG_DB
from config import CONFIG_TS
db = MySQLdb.connect(CONFIG_DB['host'], CONFIG_DB['user'], CONFIG_DB['password'], CONFIG_DB['database'], charset='utf8')
pro = ts.pro_api(CONFIG_TS['secret'])
def str2float( str ):
try:
val = float(str)
if math.isinf(val) or math.isnan(val) :
val = 0
return val
except Exception as e:
return 0.0
def queryts( code ) :
df = pro.cashflow(**{
"ts_code": code,
"ann_date": "",
"f_ann_date": "",
"start_date": 20220630,
"end_date": 20230604,
#"start_date": 20170101,
#"end_date": 20220630,
"period": "",
"report_type": "",
"comp_type": "",
"end_type": "",
"is_calc": "",
"limit": "",
"offset": ""
}, fields=[
"ts_code",
"ann_date",
"f_ann_date",
"end_date",
"comp_type",
"report_type",
"end_type",
"net_profit",
"finan_exp",
"c_fr_sale_sg",
"recp_tax_rends",
"n_depos_incr_fi",
"n_incr_loans_cb",
"n_inc_borr_oth_fi",
"prem_fr_orig_contr",
"n_incr_insured_dep",
"n_reinsur_prem",
"n_incr_disp_tfa",
"ifc_cash_incr",
"n_incr_disp_faas",
"n_incr_loans_oth_bank",
"n_cap_incr_repur",
"c_fr_oth_operate_a",
"c_inf_fr_operate_a",
"c_paid_goods_s",
"c_paid_to_for_empl",
"c_paid_for_taxes",
"n_incr_clt_loan_adv",
"n_incr_dep_cbob",
"c_pay_claims_orig_inco",
"pay_handling_chrg",
"pay_comm_insur_plcy",
"oth_cash_pay_oper_act",
"st_cash_out_act",
"n_cashflow_act",
"oth_recp_ral_inv_act",
"c_disp_withdrwl_invest",
"c_recp_return_invest",
"n_recp_disp_fiolta",
"n_recp_disp_sobu",
"stot_inflows_inv_act",
"c_pay_acq_const_fiolta",
"c_paid_invest",
"n_disp_subs_oth_biz",
"oth_pay_ral_inv_act",
"n_incr_pledge_loan",
"stot_out_inv_act",
"n_cashflow_inv_act",
"c_recp_borrow",
"proc_issue_bonds",
"oth_cash_recp_ral_fnc_act",
"stot_cash_in_fnc_act",
"free_cashflow",
"c_prepay_amt_borr",
"c_pay_dist_dpcp_int_exp",
"incl_dvd_profit_paid_sc_ms",
"oth_cashpay_ral_fnc_act",
"stot_cashout_fnc_act",
"n_cash_flows_fnc_act",
"eff_fx_flu_cash",
"n_incr_cash_cash_equ",
"c_cash_equ_beg_period",
"c_cash_equ_end_period",
"c_recp_cap_contrib",
"incl_cash_rec_saims",
"uncon_invest_loss",
"prov_depr_assets",
"depr_fa_coga_dpba",
"amort_intang_assets",
"lt_amort_deferred_exp",
"decr_deferred_exp",
"incr_acc_exp",
"loss_disp_fiolta",
"loss_scr_fa",
"loss_fv_chg",
"invest_loss",
"decr_def_inc_tax_assets",
"incr_def_inc_tax_liab",
"decr_inventories",
"decr_oper_payable",
"incr_oper_payable",
"others",
"im_net_cashflow_oper_act",
"conv_debt_into_cap",
"conv_copbonds_due_within_1y",
"fa_fnc_leases",
"im_n_incr_cash_equ",
"net_dism_capital_add",
"net_cash_rece_sec",
"credit_impa_loss",
"use_right_asset_dep",
"oth_loss_asset",
"end_bal_cash",
"beg_bal_cash",
"end_bal_cash_equ",
"beg_bal_cash_equ",
"update_flag"
])
return df
def getsqlstr(row):
sqlstr = "insert into t_ods_hs_finance_cashflow(ts_code, ann_date, f_ann_date, end_date, comp_type, report_type, end_type, net_profit, finan_exp, c_fr_sale_sg, \
recp_tax_rends, n_depos_incr_fi, n_incr_loans_cb, n_inc_borr_oth_fi, prem_fr_orig_contr, n_incr_insured_dep, n_reinsur_prem, n_incr_disp_tfa, ifc_cash_incr, \
n_incr_disp_faas, n_incr_loans_oth_bank, n_cap_incr_repur, c_fr_oth_operate_a, c_inf_fr_operate_a, c_paid_goods_s, c_paid_to_for_empl, c_paid_for_taxes, \
n_incr_clt_loan_adv, n_incr_dep_cbob, c_pay_claims_orig_inco, pay_handling_chrg, pay_comm_insur_plcy, oth_cash_pay_oper_act, st_cash_out_act, n_cashflow_act, \
oth_recp_ral_inv_act, c_disp_withdrwl_invest, c_recp_return_invest, n_recp_disp_fiolta, n_recp_disp_sobu, stot_inflows_inv_act, c_pay_acq_const_fiolta, c_paid_invest, \
n_disp_subs_oth_biz, oth_pay_ral_inv_act, n_incr_pledge_loan, stot_out_inv_act, n_cashflow_inv_act, c_recp_borrow, proc_issue_bonds, oth_cash_recp_ral_fnc_act, \
stot_cash_in_fnc_act, free_cashflow, c_prepay_amt_borr, c_pay_dist_dpcp_int_exp, incl_dvd_profit_paid_sc_ms, oth_cashpay_ral_fnc_act, stot_cashout_fnc_act, \
n_cash_flows_fnc_act, eff_fx_flu_cash, n_incr_cash_cash_equ, c_cash_equ_beg_period, c_cash_equ_end_period, c_recp_cap_contrib, incl_cash_rec_saims, uncon_invest_loss, \
prov_depr_assets, depr_fa_coga_dpba, amort_intang_assets, lt_amort_deferred_exp, decr_deferred_exp, incr_acc_exp, loss_disp_fiolta, loss_scr_fa, loss_fv_chg, invest_loss, \
decr_def_inc_tax_assets, incr_def_inc_tax_liab, decr_inventories, decr_oper_payable, incr_oper_payable, others, im_net_cashflow_oper_act, conv_debt_into_cap, \
conv_copbonds_due_within_1y, fa_fnc_leases, im_n_incr_cash_equ, net_dism_capital_add, net_cash_rece_sec, credit_impa_loss, use_right_asset_dep, oth_loss_asset, \
end_bal_cash, beg_bal_cash, end_bal_cash_equ, beg_bal_cash_equ, update_flag) \
values('%s', '%s', '%s', '%s', '%s', '%s', '%s', \
%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, \
%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, \
%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, \
%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, \
%f, %f, %f, %f, %f, %f, %f, %f, %f, '%s') \
on duplicate key update report_type='%s', comp_type='%s', end_type='%s', \
net_profit=%f, finan_exp=%f, c_fr_sale_sg=%f, recp_tax_rends=%f, n_depos_incr_fi=%f, n_incr_loans_cb=%f, n_inc_borr_oth_fi=%f, prem_fr_orig_contr=%f, \
n_incr_insured_dep=%f, n_reinsur_prem=%f, n_incr_disp_tfa=%f, ifc_cash_incr=%f, n_incr_disp_faas=%f, n_incr_loans_oth_bank=%f, n_cap_incr_repur=%f, \
c_fr_oth_operate_a=%f, c_inf_fr_operate_a=%f, c_paid_goods_s=%f, c_paid_to_for_empl=%f, c_paid_for_taxes=%f, n_incr_clt_loan_adv=%f, n_incr_dep_cbob=%f, \
c_pay_claims_orig_inco=%f, pay_handling_chrg=%f, pay_comm_insur_plcy=%f, oth_cash_pay_oper_act=%f, st_cash_out_act=%f, n_cashflow_act=%f, \
oth_recp_ral_inv_act=%f, c_disp_withdrwl_invest=%f, c_recp_return_invest=%f, n_recp_disp_fiolta=%f, n_recp_disp_sobu=%f, stot_inflows_inv_act=%f, \
c_pay_acq_const_fiolta=%f, c_paid_invest=%f, n_disp_subs_oth_biz=%f, oth_pay_ral_inv_act=%f, n_incr_pledge_loan=%f, stot_out_inv_act=%f, n_cashflow_inv_act=%f, \
c_recp_borrow=%f, proc_issue_bonds=%f, oth_cash_recp_ral_fnc_act=%f, stot_cash_in_fnc_act=%f, free_cashflow=%f, c_prepay_amt_borr=%f, c_pay_dist_dpcp_int_exp=%f, \
incl_dvd_profit_paid_sc_ms=%f, oth_cashpay_ral_fnc_act=%f, stot_cashout_fnc_act=%f, n_cash_flows_fnc_act=%f, eff_fx_flu_cash=%f, n_incr_cash_cash_equ=%f, \
c_cash_equ_beg_period=%f, c_cash_equ_end_period=%f, c_recp_cap_contrib=%f, incl_cash_rec_saims=%f, uncon_invest_loss=%f, prov_depr_assets=%f, \
depr_fa_coga_dpba=%f, amort_intang_assets=%f, lt_amort_deferred_exp=%f, decr_deferred_exp=%f, incr_acc_exp=%f, loss_disp_fiolta=%f, loss_scr_fa=%f, \
loss_fv_chg=%f, invest_loss=%f, decr_def_inc_tax_assets=%f, incr_def_inc_tax_liab=%f, decr_inventories=%f, decr_oper_payable=%f, incr_oper_payable=%f, \
others=%f, im_net_cashflow_oper_act=%f, conv_debt_into_cap=%f, conv_copbonds_due_within_1y=%f, fa_fnc_leases=%f, im_n_incr_cash_equ=%f, net_dism_capital_add=%f, \
net_cash_rece_sec=%f, credit_impa_loss=%f, use_right_asset_dep=%f, oth_loss_asset=%f, end_bal_cash=%f, beg_bal_cash=%f, end_bal_cash_equ=%f, \
beg_bal_cash_equ=%f " % (
getattr(row, 'ts_code'), getattr(row, 'ann_date'), getattr(row, 'f_ann_date'), getattr(row, 'end_date'),
getattr(row, 'report_type'), getattr(row, 'comp_type'), getattr(row, 'end_type'),
str2float(getattr(row, 'net_profit')), str2float(getattr(row, 'finan_exp')), str2float(getattr(row, 'c_fr_sale_sg')), str2float(getattr(row, 'recp_tax_rends')),
str2float(getattr(row, 'n_depos_incr_fi')), str2float(getattr(row, 'n_incr_loans_cb')), str2float(getattr(row, 'n_inc_borr_oth_fi')),
str2float(getattr(row, 'prem_fr_orig_contr')), str2float(getattr(row, 'n_incr_insured_dep')), str2float(getattr(row, 'n_reinsur_prem')),
str2float(getattr(row, 'n_incr_disp_tfa')), str2float(getattr(row, 'ifc_cash_incr')), str2float(getattr(row, 'n_incr_disp_faas')),
str2float(getattr(row, 'n_incr_loans_oth_bank')), str2float(getattr(row, 'n_cap_incr_repur')), str2float(getattr(row, 'c_fr_oth_operate_a')),
str2float(getattr(row, 'c_inf_fr_operate_a')), str2float(getattr(row, 'c_paid_goods_s')), str2float(getattr(row, 'c_paid_to_for_empl')),
str2float(getattr(row, 'c_paid_for_taxes')), str2float(getattr(row, 'n_incr_clt_loan_adv')), str2float(getattr(row, 'n_incr_dep_cbob')),
str2float(getattr(row, 'c_pay_claims_orig_inco')), str2float(getattr(row, 'pay_handling_chrg')), str2float(getattr(row, 'pay_comm_insur_plcy')),
str2float(getattr(row, 'oth_cash_pay_oper_act')), str2float(getattr(row, 'st_cash_out_act')), str2float(getattr(row, 'n_cashflow_act')),
str2float(getattr(row, 'oth_recp_ral_inv_act')), str2float(getattr(row, 'c_disp_withdrwl_invest')), str2float(getattr(row, 'c_recp_return_invest')),
str2float(getattr(row, 'n_recp_disp_fiolta')), str2float(getattr(row, 'n_recp_disp_sobu')), str2float(getattr(row, 'stot_inflows_inv_act')),
str2float(getattr(row, 'c_pay_acq_const_fiolta')), str2float(getattr(row, 'c_paid_invest')), str2float(getattr(row, 'n_disp_subs_oth_biz')),
str2float(getattr(row, 'oth_pay_ral_inv_act')), str2float(getattr(row, 'n_incr_pledge_loan')), str2float(getattr(row, 'stot_out_inv_act')),
str2float(getattr(row, 'n_cashflow_inv_act')), str2float(getattr(row, 'c_recp_borrow')), str2float(getattr(row, 'proc_issue_bonds')),
str2float(getattr(row, 'oth_cash_recp_ral_fnc_act')), str2float(getattr(row, 'stot_cash_in_fnc_act')), str2float(getattr(row, 'free_cashflow')),
str2float(getattr(row, 'c_prepay_amt_borr')), str2float(getattr(row, 'c_pay_dist_dpcp_int_exp')), str2float(getattr(row, 'incl_dvd_profit_paid_sc_ms')),
str2float(getattr(row, 'oth_cashpay_ral_fnc_act')), str2float(getattr(row, 'stot_cashout_fnc_act')), str2float(getattr(row, 'n_cash_flows_fnc_act')),
str2float(getattr(row, 'eff_fx_flu_cash')), str2float(getattr(row, 'n_incr_cash_cash_equ')), str2float(getattr(row, 'c_cash_equ_beg_period')),
str2float(getattr(row, 'c_cash_equ_end_period')), str2float(getattr(row, 'c_recp_cap_contrib')), str2float(getattr(row, 'incl_cash_rec_saims')),
str2float(getattr(row, 'uncon_invest_loss')), str2float(getattr(row, 'prov_depr_assets')), str2float(getattr(row, 'depr_fa_coga_dpba')),
str2float(getattr(row, 'amort_intang_assets')), str2float(getattr(row, 'lt_amort_deferred_exp')), str2float(getattr(row, 'decr_deferred_exp')),
str2float(getattr(row, 'incr_acc_exp')), str2float(getattr(row, 'loss_disp_fiolta')), str2float(getattr(row, 'loss_scr_fa')), str2float(getattr(row, 'loss_fv_chg')),
str2float(getattr(row, 'invest_loss')), str2float(getattr(row, 'decr_def_inc_tax_assets')), str2float(getattr(row, 'incr_def_inc_tax_liab')),
str2float(getattr(row, 'decr_inventories')), str2float(getattr(row, 'decr_oper_payable')), str2float(getattr(row, 'incr_oper_payable')),
str2float(getattr(row, 'others')), str2float(getattr(row, 'im_net_cashflow_oper_act')), str2float(getattr(row, 'conv_debt_into_cap')),
str2float(getattr(row, 'conv_copbonds_due_within_1y')), str2float(getattr(row, 'fa_fnc_leases')), str2float(getattr(row, 'im_n_incr_cash_equ')),
str2float(getattr(row, 'net_dism_capital_add')), str2float(getattr(row, 'net_cash_rece_sec')), str2float(getattr(row, 'credit_impa_loss')),
str2float(getattr(row, 'use_right_asset_dep')), str2float(getattr(row, 'oth_loss_asset')), str2float(getattr(row, 'end_bal_cash')),
str2float(getattr(row, 'beg_bal_cash')), str2float(getattr(row, 'end_bal_cash_equ')), str2float(getattr(row, 'beg_bal_cash_equ')),
getattr(row, 'update_flag'),
getattr(row, 'report_type'), getattr(row, 'comp_type'), getattr(row, 'end_type'),
str2float(getattr(row, 'net_profit')), str2float(getattr(row, 'finan_exp')), str2float(getattr(row, 'c_fr_sale_sg')), str2float(getattr(row, 'recp_tax_rends')),
str2float(getattr(row, 'n_depos_incr_fi')), str2float(getattr(row, 'n_incr_loans_cb')), str2float(getattr(row, 'n_inc_borr_oth_fi')),
str2float(getattr(row, 'prem_fr_orig_contr')), str2float(getattr(row, 'n_incr_insured_dep')), str2float(getattr(row, 'n_reinsur_prem')),
str2float(getattr(row, 'n_incr_disp_tfa')), str2float(getattr(row, 'ifc_cash_incr')), str2float(getattr(row, 'n_incr_disp_faas')),
str2float(getattr(row, 'n_incr_loans_oth_bank')), str2float(getattr(row, 'n_cap_incr_repur')), str2float(getattr(row, 'c_fr_oth_operate_a')),
str2float(getattr(row, 'c_inf_fr_operate_a')), str2float(getattr(row, 'c_paid_goods_s')), str2float(getattr(row, 'c_paid_to_for_empl')),
str2float(getattr(row, 'c_paid_for_taxes')), str2float(getattr(row, 'n_incr_clt_loan_adv')), str2float(getattr(row, 'n_incr_dep_cbob')),
str2float(getattr(row, 'c_pay_claims_orig_inco')), str2float(getattr(row, 'pay_handling_chrg')), str2float(getattr(row, 'pay_comm_insur_plcy')),
str2float(getattr(row, 'oth_cash_pay_oper_act')), str2float(getattr(row, 'st_cash_out_act')), str2float(getattr(row, 'n_cashflow_act')),
str2float(getattr(row, 'oth_recp_ral_inv_act')), str2float(getattr(row, 'c_disp_withdrwl_invest')), str2float(getattr(row, 'c_recp_return_invest')),
str2float(getattr(row, 'n_recp_disp_fiolta')), str2float(getattr(row, 'n_recp_disp_sobu')), str2float(getattr(row, 'stot_inflows_inv_act')),
str2float(getattr(row, 'c_pay_acq_const_fiolta')), str2float(getattr(row, 'c_paid_invest')), str2float(getattr(row, 'n_disp_subs_oth_biz')),
str2float(getattr(row, 'oth_pay_ral_inv_act')), str2float(getattr(row, 'n_incr_pledge_loan')), str2float(getattr(row, 'stot_out_inv_act')),
str2float(getattr(row, 'n_cashflow_inv_act')), str2float(getattr(row, 'c_recp_borrow')), str2float(getattr(row, 'proc_issue_bonds')),
str2float(getattr(row, 'oth_cash_recp_ral_fnc_act')), str2float(getattr(row, 'stot_cash_in_fnc_act')), str2float(getattr(row, 'free_cashflow')),
str2float(getattr(row, 'c_prepay_amt_borr')), str2float(getattr(row, 'c_pay_dist_dpcp_int_exp')), str2float(getattr(row, 'incl_dvd_profit_paid_sc_ms')),
str2float(getattr(row, 'oth_cashpay_ral_fnc_act')), str2float(getattr(row, 'stot_cashout_fnc_act')), str2float(getattr(row, 'n_cash_flows_fnc_act')),
str2float(getattr(row, 'eff_fx_flu_cash')), str2float(getattr(row, 'n_incr_cash_cash_equ')), str2float(getattr(row, 'c_cash_equ_beg_period')),
str2float(getattr(row, 'c_cash_equ_end_period')), str2float(getattr(row, 'c_recp_cap_contrib')), str2float(getattr(row, 'incl_cash_rec_saims')),
str2float(getattr(row, 'uncon_invest_loss')), str2float(getattr(row, 'prov_depr_assets')), str2float(getattr(row, 'depr_fa_coga_dpba')),
str2float(getattr(row, 'amort_intang_assets')), str2float(getattr(row, 'lt_amort_deferred_exp')), str2float(getattr(row, 'decr_deferred_exp')),
str2float(getattr(row, 'incr_acc_exp')), str2float(getattr(row, 'loss_disp_fiolta')), str2float(getattr(row, 'loss_scr_fa')), str2float(getattr(row, 'loss_fv_chg')),
str2float(getattr(row, 'invest_loss')), str2float(getattr(row, 'decr_def_inc_tax_assets')), str2float(getattr(row, 'incr_def_inc_tax_liab')),
str2float(getattr(row, 'decr_inventories')), str2float(getattr(row, 'decr_oper_payable')), str2float(getattr(row, 'incr_oper_payable')),
str2float(getattr(row, 'others')), str2float(getattr(row, 'im_net_cashflow_oper_act')), str2float(getattr(row, 'conv_debt_into_cap')),
str2float(getattr(row, 'conv_copbonds_due_within_1y')), str2float(getattr(row, 'fa_fnc_leases')), str2float(getattr(row, 'im_n_incr_cash_equ')),
str2float(getattr(row, 'net_dism_capital_add')), str2float(getattr(row, 'net_cash_rece_sec')), str2float(getattr(row, 'credit_impa_loss')),
str2float(getattr(row, 'use_right_asset_dep')), str2float(getattr(row, 'oth_loss_asset')), str2float(getattr(row, 'end_bal_cash')),
str2float(getattr(row, 'beg_bal_cash')), str2float(getattr(row, 'end_bal_cash_equ')), str2float(getattr(row, 'beg_bal_cash_equ'))
)
return sqlstr
def process():
stock_list = []
cursor = db.cursor()
total_stocks = 0
total_rows = 0
fd = open("./cashflow.log", 'w+')
# get stock list
sqlstr = "select ts_code from t_ods_hs_base_list where list_status = 'L' "
try:
cursor.execute(sqlstr)
results = cursor.fetchall()
for row in results :
stock_list.append(row[0])
total_stocks = total_stocks+1
except Exception as ex:
print (ex)
print ("get stock list error!")
db.close()
return
# get income data
for st_code in stock_list :
df = queryts(st_code)
loop = 0
for row in df.itertuples():
sql = getsqlstr(row)
try:
cursor.execute(sql)
db.commit()
loop = loop+1
except Exception as ex:
print (ex)
print ("get stock %s error!" % st_code )
db.rollback()
return
print("get %s cashflow data succ! total rows: %d" % (st_code, loop))
fd.write("get %s cashflow data succ! total rows: %d \n" % (st_code, loop))
fd.flush()
total_rows = total_rows+loop
time.sleep(0.5)
# get all data
print("All stock cashflow data process succ! total stocks: %d, total rows: %d " % (total_stocks, total_rows))
fd.write("All stock cashflow data process succ! total stocks: %d, total rows: %d \n" % (total_stocks, total_rows))
# close db and file
fd.close()
db.close()
process()

View File

@ -0,0 +1,283 @@
import tushare as ts
import MySQLdb
import math
import time
from config import CONFIG_DB
db = MySQLdb.connect(CONFIG_DB['host'], CONFIG_DB['user'], CONFIG_DB['password'], CONFIG_DB['database'], charset='utf8')
pro = ts.pro_api('f4b683b73b5208105564cb2a086f9c687268b8c4a50d7534853889e3')
def str2float( str ):
try:
val = float(str)
if math.isinf(val) or math.isnan(val) :
val = 0
return val
except Exception as e:
return 0.0
def queryts( code ) :
df = pro.income(**{
"ts_code": code,
"ann_date": "",
"f_ann_date": "",
"start_date": 20220630,
"end_date": 20230604,
"period": "",
"report_type": "",
"comp_type": "",
"end_type": "",
"is_calc": "",
"limit": "",
"offset": ""
}, fields=[
"ts_code",
"ann_date",
"f_ann_date",
"end_date",
"report_type",
"comp_type",
"end_type",
"basic_eps",
"diluted_eps",
"total_revenue",
"revenue",
"int_income",
"prem_earned",
"comm_income",
"n_commis_income",
"n_oth_income",
"n_oth_b_income",
"prem_income",
"out_prem",
"une_prem_reser",
"reins_income",
"n_sec_tb_income",
"n_sec_uw_income",
"n_asset_mg_income",
"oth_b_income",
"fv_value_chg_gain",
"invest_income",
"ass_invest_income",
"forex_gain",
"total_cogs",
"oper_cost",
"int_exp",
"comm_exp",
"biz_tax_surchg",
"sell_exp",
"admin_exp",
"fin_exp",
"assets_impair_loss",
"prem_refund",
"compens_payout",
"reser_insur_liab",
"div_payt",
"reins_exp",
"oper_exp",
"compens_payout_refu",
"insur_reser_refu",
"reins_cost_refund",
"other_bus_cost",
"operate_profit",
"non_oper_income",
"non_oper_exp",
"nca_disploss",
"total_profit",
"income_tax",
"n_income",
"n_income_attr_p",
"minority_gain",
"oth_compr_income",
"t_compr_income",
"compr_inc_attr_p",
"compr_inc_attr_m_s",
"ebit",
"ebitda",
"insurance_exp",
"undist_profit",
"distable_profit",
"rd_exp",
"fin_exp_int_exp",
"fin_exp_int_inc",
"transfer_surplus_rese",
"transfer_housing_imprest",
"transfer_oth",
"adj_lossgain",
"withdra_legal_surplus",
"withdra_legal_pubfund",
"withdra_biz_devfund",
"withdra_rese_fund",
"withdra_oth_ersu",
"workers_welfare",
"distr_profit_shrhder",
"prfshare_payable_dvd",
"comshare_payable_dvd",
"capit_comstock_div",
"net_after_nr_lp_correct",
"oth_income",
"asset_disp_income",
"continued_net_profit",
"end_net_profit",
"credit_impa_loss",
"net_expo_hedging_benefits",
"oth_impair_loss_assets",
"total_opcost",
"amodcost_fin_assets",
"update_flag"
])
return df
def getsqlstr(row):
sqlstr = "insert into t_ods_hs_finance_income(ts_code, ann_date, f_ann_date, end_date, report_type, comp_type, end_type, \
basic_eps, diluted_eps, total_revenue, revenue, int_income, prem_earned, comm_income, n_commis_income, n_oth_income, \
n_oth_b_income, prem_income, out_prem, une_prem_reser, reins_income, n_sec_tb_income, n_sec_uw_income, n_asset_mg_income, \
oth_b_income, fv_value_chg_gain, invest_income, ass_invest_income, forex_gain, total_cogs, oper_cost, int_exp, comm_exp, \
biz_tax_surchg, sell_exp, admin_exp, fin_exp, assets_impair_loss, prem_refund, compens_payout, reser_insur_liab, div_payt, \
reins_exp, oper_exp, compens_payout_refu, insur_reser_refu, reins_cost_refund, other_bus_cost, operate_profit, non_oper_income, \
non_oper_exp, nca_disploss, total_profit, income_tax, n_income, n_income_attr_p, minority_gain, oth_compr_income, t_compr_income, \
compr_inc_attr_p, compr_inc_attr_m_s, ebit, ebitda, insurance_exp, undist_profit, distable_profit, rd_exp, fin_exp_int_exp, \
fin_exp_int_inc, transfer_surplus_rese, transfer_housing_imprest, transfer_oth, adj_lossgain, withdra_legal_surplus, \
withdra_legal_pubfund, withdra_biz_devfund, withdra_rese_fund, withdra_oth_ersu, workers_welfare, distr_profit_shrhder, \
prfshare_payable_dvd, comshare_payable_dvd, capit_comstock_div, net_after_nr_lp_correct, oth_income, asset_disp_income, \
continued_net_profit, end_net_profit, credit_impa_loss, net_expo_hedging_benefits, oth_impair_loss_assets, total_opcost, \
amodcost_fin_assets, update_flag) \
values('%s', '%s', '%s', '%s', '%s', '%s', '%s', \
%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, \
%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, \
%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, \
%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, \
%f, %f, %f, %f, %f, %f, '%s') \
on duplicate key update report_type='%s', comp_type='%s', end_type='%s', \
basic_eps=%f, diluted_eps=%f, total_revenue=%f, revenue=%f, int_income=%f, prem_earned=%f, \
comm_income=%f, n_commis_income=%f, n_oth_income=%f, n_oth_b_income=%f, prem_income=%f, \
out_prem=%f, une_prem_reser=%f, reins_income=%f, n_sec_tb_income=%f, n_sec_uw_income=%f, \
n_asset_mg_income=%f, oth_b_income=%f, fv_value_chg_gain=%f, invest_income=%f, ass_invest_income=%f, \
forex_gain=%f, total_cogs=%f, oper_cost=%f, int_exp=%f, comm_exp=%f, biz_tax_surchg=%f, \
sell_exp=%f, admin_exp=%f, fin_exp=%f, assets_impair_loss=%f, prem_refund=%f, compens_payout=%f, \
reser_insur_liab=%f, div_payt=%f, reins_exp=%f, oper_exp=%f, compens_payout_refu=%f, \
insur_reser_refu=%f, reins_cost_refund=%f, other_bus_cost=%f, operate_profit=%f, non_oper_income=%f, \
non_oper_exp=%f, nca_disploss=%f, total_profit=%f, income_tax=%f, n_income=%f, n_income_attr_p=%f, \
minority_gain=%f, oth_compr_income=%f, t_compr_income=%f, compr_inc_attr_p=%f, compr_inc_attr_m_s=%f, \
ebit=%f, ebitda=%f, insurance_exp=%f, undist_profit=%f, distable_profit=%f, rd_exp=%f, fin_exp_int_exp=%f, \
fin_exp_int_inc=%f, transfer_surplus_rese=%f, transfer_housing_imprest=%f, transfer_oth=%f, \
adj_lossgain=%f, withdra_legal_surplus=%f, withdra_legal_pubfund=%f, withdra_biz_devfund=%f, \
withdra_rese_fund=%f, withdra_oth_ersu=%f, workers_welfare=%f, distr_profit_shrhder=%f, \
prfshare_payable_dvd=%f, comshare_payable_dvd=%f, capit_comstock_div=%f, net_after_nr_lp_correct=%f, \
oth_income=%f, asset_disp_income=%f, continued_net_profit=%f, end_net_profit=%f, credit_impa_loss=%f, \
net_expo_hedging_benefits=%f, oth_impair_loss_assets=%f, total_opcost=%f, amodcost_fin_assets=%f " % (
getattr(row, 'ts_code'), getattr(row, 'ann_date'), getattr(row, 'f_ann_date'), getattr(row, 'end_date'),
getattr(row, 'report_type'), getattr(row, 'comp_type'), getattr(row, 'end_type'),
str2float(getattr(row, 'basic_eps')), str2float(getattr(row, 'diluted_eps')), str2float(getattr(row, 'total_revenue')),
str2float(getattr(row, 'revenue')), str2float(getattr(row, 'int_income')), str2float(getattr(row, 'prem_earned')),
str2float(getattr(row, 'comm_income')), str2float(getattr(row, 'n_commis_income')), str2float(getattr(row, 'n_oth_income')),
str2float(getattr(row, 'n_oth_b_income')), str2float(getattr(row, 'prem_income')), str2float(getattr(row, 'out_prem')),
str2float(getattr(row, 'une_prem_reser')), str2float(getattr(row, 'reins_income')), str2float(getattr(row, 'n_sec_tb_income')),
str2float(getattr(row, 'n_sec_uw_income')), str2float(getattr(row, 'n_asset_mg_income')), str2float(getattr(row, 'oth_b_income')),
str2float(getattr(row, 'fv_value_chg_gain')), str2float(getattr(row, 'invest_income')), str2float(getattr(row, 'ass_invest_income')),
str2float(getattr(row, 'forex_gain')), str2float(getattr(row, 'total_cogs')), str2float(getattr(row, 'oper_cost')),
str2float(getattr(row, 'int_exp')), str2float(getattr(row, 'comm_exp')), str2float(getattr(row, 'biz_tax_surchg')),
str2float(getattr(row, 'sell_exp')), str2float(getattr(row, 'admin_exp')), str2float(getattr(row, 'fin_exp')),
str2float(getattr(row, 'assets_impair_loss')), str2float(getattr(row, 'prem_refund')), str2float(getattr(row, 'compens_payout')),
str2float(getattr(row, 'reser_insur_liab')), str2float(getattr(row, 'div_payt')), str2float(getattr(row, 'reins_exp')),
str2float(getattr(row, 'oper_exp')), str2float(getattr(row, 'compens_payout_refu')), str2float(getattr(row, 'insur_reser_refu')),
str2float(getattr(row, 'reins_cost_refund')), str2float(getattr(row, 'other_bus_cost')), str2float(getattr(row, 'operate_profit')),
str2float(getattr(row, 'non_oper_income')), str2float(getattr(row, 'non_oper_exp')), str2float(getattr(row, 'nca_disploss')),
str2float(getattr(row, 'total_profit')), str2float(getattr(row, 'income_tax')), str2float(getattr(row, 'n_income')),
str2float(getattr(row, 'n_income_attr_p')), str2float(getattr(row, 'minority_gain')), str2float(getattr(row, 'oth_compr_income')),
str2float(getattr(row, 't_compr_income')), str2float(getattr(row, 'compr_inc_attr_p')), str2float(getattr(row, 'compr_inc_attr_m_s')),
str2float(getattr(row, 'ebit')), str2float(getattr(row, 'ebitda')), str2float(getattr(row, 'insurance_exp')),
str2float(getattr(row, 'undist_profit')), str2float(getattr(row, 'distable_profit')), str2float(getattr(row, 'rd_exp')),
str2float(getattr(row, 'fin_exp_int_exp')), str2float(getattr(row, 'fin_exp_int_inc')), str2float(getattr(row, 'transfer_surplus_rese')),
str2float(getattr(row, 'transfer_housing_imprest')), str2float(getattr(row, 'transfer_oth')), str2float(getattr(row, 'adj_lossgain')),
str2float(getattr(row, 'withdra_legal_surplus')), str2float(getattr(row, 'withdra_legal_pubfund')), str2float(getattr(row, 'withdra_biz_devfund')),
str2float(getattr(row, 'withdra_rese_fund')), str2float(getattr(row, 'withdra_oth_ersu')), str2float(getattr(row, 'workers_welfare')),
str2float(getattr(row, 'distr_profit_shrhder')), str2float(getattr(row, 'prfshare_payable_dvd')), str2float(getattr(row, 'comshare_payable_dvd')),
str2float(getattr(row, 'capit_comstock_div')), str2float(getattr(row, 'net_after_nr_lp_correct')), str2float(getattr(row, 'oth_income')),
str2float(getattr(row, 'asset_disp_income')), str2float(getattr(row, 'continued_net_profit')), str2float(getattr(row, 'end_net_profit')),
str2float(getattr(row, 'credit_impa_loss')), str2float(getattr(row, 'net_expo_hedging_benefits')), str2float(getattr(row, 'oth_impair_loss_assets')),
str2float(getattr(row, 'total_opcost')), str2float(getattr(row, 'amodcost_fin_assets')), getattr(row, 'update_flag'),
getattr(row, 'report_type'), getattr(row, 'comp_type'), getattr(row, 'end_type'),
str2float(getattr(row, 'basic_eps')), str2float(getattr(row, 'diluted_eps')), str2float(getattr(row, 'total_revenue')),
str2float(getattr(row, 'revenue')), str2float(getattr(row, 'int_income')), str2float(getattr(row, 'prem_earned')),
str2float(getattr(row, 'comm_income')), str2float(getattr(row, 'n_commis_income')), str2float(getattr(row, 'n_oth_income')),
str2float(getattr(row, 'n_oth_b_income')), str2float(getattr(row, 'prem_income')), str2float(getattr(row, 'out_prem')),
str2float(getattr(row, 'une_prem_reser')), str2float(getattr(row, 'reins_income')), str2float(getattr(row, 'n_sec_tb_income')),
str2float(getattr(row, 'n_sec_uw_income')), str2float(getattr(row, 'n_asset_mg_income')), str2float(getattr(row, 'oth_b_income')),
str2float(getattr(row, 'fv_value_chg_gain')), str2float(getattr(row, 'invest_income')), str2float(getattr(row, 'ass_invest_income')),
str2float(getattr(row, 'forex_gain')), str2float(getattr(row, 'total_cogs')), str2float(getattr(row, 'oper_cost')),
str2float(getattr(row, 'int_exp')), str2float(getattr(row, 'comm_exp')), str2float(getattr(row, 'biz_tax_surchg')),
str2float(getattr(row, 'sell_exp')), str2float(getattr(row, 'admin_exp')), str2float(getattr(row, 'fin_exp')),
str2float(getattr(row, 'assets_impair_loss')), str2float(getattr(row, 'prem_refund')), str2float(getattr(row, 'compens_payout')),
str2float(getattr(row, 'reser_insur_liab')), str2float(getattr(row, 'div_payt')), str2float(getattr(row, 'reins_exp')),
str2float(getattr(row, 'oper_exp')), str2float(getattr(row, 'compens_payout_refu')), str2float(getattr(row, 'insur_reser_refu')),
str2float(getattr(row, 'reins_cost_refund')), str2float(getattr(row, 'other_bus_cost')), str2float(getattr(row, 'operate_profit')),
str2float(getattr(row, 'non_oper_income')), str2float(getattr(row, 'non_oper_exp')), str2float(getattr(row, 'nca_disploss')),
str2float(getattr(row, 'total_profit')), str2float(getattr(row, 'income_tax')), str2float(getattr(row, 'n_income')),
str2float(getattr(row, 'n_income_attr_p')), str2float(getattr(row, 'minority_gain')), str2float(getattr(row, 'oth_compr_income')),
str2float(getattr(row, 't_compr_income')), str2float(getattr(row, 'compr_inc_attr_p')), str2float(getattr(row, 'compr_inc_attr_m_s')),
str2float(getattr(row, 'ebit')), str2float(getattr(row, 'ebitda')), str2float(getattr(row, 'insurance_exp')),
str2float(getattr(row, 'undist_profit')), str2float(getattr(row, 'distable_profit')), str2float(getattr(row, 'rd_exp')),
str2float(getattr(row, 'fin_exp_int_exp')), str2float(getattr(row, 'fin_exp_int_inc')), str2float(getattr(row, 'transfer_surplus_rese')),
str2float(getattr(row, 'transfer_housing_imprest')), str2float(getattr(row, 'transfer_oth')), str2float(getattr(row, 'adj_lossgain')),
str2float(getattr(row, 'withdra_legal_surplus')), str2float(getattr(row, 'withdra_legal_pubfund')), str2float(getattr(row, 'withdra_biz_devfund')),
str2float(getattr(row, 'withdra_rese_fund')), str2float(getattr(row, 'withdra_oth_ersu')), str2float(getattr(row, 'workers_welfare')),
str2float(getattr(row, 'distr_profit_shrhder')), str2float(getattr(row, 'prfshare_payable_dvd')), str2float(getattr(row, 'comshare_payable_dvd')),
str2float(getattr(row, 'capit_comstock_div')), str2float(getattr(row, 'net_after_nr_lp_correct')), str2float(getattr(row, 'oth_income')),
str2float(getattr(row, 'asset_disp_income')), str2float(getattr(row, 'continued_net_profit')), str2float(getattr(row, 'end_net_profit')),
str2float(getattr(row, 'credit_impa_loss')), str2float(getattr(row, 'net_expo_hedging_benefits')), str2float(getattr(row, 'oth_impair_loss_assets')),
str2float(getattr(row, 'total_opcost')), str2float(getattr(row, 'amodcost_fin_assets'))
)
return sqlstr
def process():
stock_list = []
cursor = db.cursor()
total_stocks = 0
total_rows = 0
fd = open("./income.log", 'w+')
# get stock list
sqlstr = "select ts_code from t_ods_hs_base_list where list_status = 'L' "
try:
cursor.execute(sqlstr)
results = cursor.fetchall()
for row in results :
stock_list.append(row[0])
total_stocks = total_stocks+1
except Exception as ex:
print (ex)
print ("get stock list error!")
db.close()
return
# get income data
for st_code in stock_list :
df = queryts(st_code)
loop = 0
for row in df.itertuples():
sql = getsqlstr(row)
try:
cursor.execute(sql)
db.commit()
loop = loop+1
except Exception as ex:
print (ex)
print ("get stock %s error!" % st_code )
db.rollback()
return
print("get %s income data succ! total rows: %d" % (st_code, loop))
fd.write("get %s income data succ! total rows: %d \n" % (st_code, loop))
fd.flush()
total_rows = total_rows+loop
time.sleep(0.5)
# get all data
print("All stock income data process succ! total stocks: %d, total rows: %d " % (total_stocks, total_rows))
fd.write("All stock income data process succ! total stocks: %d, total rows: %d \n" % (total_stocks, total_rows))
# close db and file
fd.close()
db.close()
process()

View File

@ -0,0 +1,386 @@
import tushare as ts
import MySQLdb
import math
import time
from config import CONFIG_DB
from config import CONFIG_TS
db = MySQLdb.connect(CONFIG_DB['host'], CONFIG_DB['user'], CONFIG_DB['password'], CONFIG_DB['database'], charset='utf8')
pro = ts.pro_api(CONFIG_TS['secret'])
def str2float( str ):
try:
val = float(str)
if math.isinf(val) or math.isnan(val) :
val = 0
return val
except Exception as e:
return 0.0
def queryts( code ) :
df = pro.fina_indicator(**{
"ts_code": code,
"ann_date": "",
"start_date": 20220630,
"end_date": 20230604,
"period": "",
"update_flag": "",
"limit": "",
"offset": ""
}, fields=[
"ts_code",
"ann_date",
"end_date",
"eps",
"dt_eps",
"total_revenue_ps",
"revenue_ps",
"capital_rese_ps",
"surplus_rese_ps",
"undist_profit_ps",
"extra_item",
"profit_dedt",
"gross_margin",
"current_ratio",
"quick_ratio",
"cash_ratio",
"invturn_days",
"arturn_days",
"inv_turn",
"ar_turn",
"ca_turn",
"fa_turn",
"assets_turn",
"op_income",
"valuechange_income",
"interst_income",
"daa",
"ebit",
"ebitda",
"fcff",
"fcfe",
"current_exint",
"noncurrent_exint",
"interestdebt",
"netdebt",
"tangible_asset",
"working_capital",
"networking_capital",
"invest_capital",
"retained_earnings",
"diluted2_eps",
"bps",
"ocfps",
"retainedps",
"cfps",
"ebit_ps",
"fcff_ps",
"fcfe_ps",
"netprofit_margin",
"grossprofit_margin",
"cogs_of_sales",
"expense_of_sales",
"profit_to_gr",
"saleexp_to_gr",
"adminexp_of_gr",
"finaexp_of_gr",
"impai_ttm",
"gc_of_gr",
"op_of_gr",
"ebit_of_gr",
"roe",
"roe_waa",
"roe_dt",
"roa",
"npta",
"roic",
"roe_yearly",
"roa2_yearly",
"roe_avg",
"opincome_of_ebt",
"investincome_of_ebt",
"n_op_profit_of_ebt",
"tax_to_ebt",
"dtprofit_to_profit",
"salescash_to_or",
"ocf_to_or",
"ocf_to_opincome",
"capitalized_to_da",
"debt_to_assets",
"assets_to_eqt",
"dp_assets_to_eqt",
"ca_to_assets",
"nca_to_assets",
"tbassets_to_totalassets",
"int_to_talcap",
"eqt_to_talcapital",
"currentdebt_to_debt",
"longdeb_to_debt",
"ocf_to_shortdebt",
"debt_to_eqt",
"eqt_to_debt",
"eqt_to_interestdebt",
"tangibleasset_to_debt",
"tangasset_to_intdebt",
"tangibleasset_to_netdebt",
"ocf_to_debt",
"ocf_to_interestdebt",
"ocf_to_netdebt",
"ebit_to_interest",
"longdebt_to_workingcapital",
"ebitda_to_debt",
"turn_days",
"roa_yearly",
"roa_dp",
"fixed_assets",
"profit_prefin_exp",
"non_op_profit",
"op_to_ebt",
"nop_to_ebt",
"ocf_to_profit",
"cash_to_liqdebt",
"cash_to_liqdebt_withinterest",
"op_to_liqdebt",
"op_to_debt",
"roic_yearly",
"total_fa_trun",
"profit_to_op",
"q_opincome",
"q_investincome",
"q_dtprofit",
"q_eps",
"q_netprofit_margin",
"q_gsprofit_margin",
"q_exp_to_sales",
"q_profit_to_gr",
"q_saleexp_to_gr",
"q_adminexp_to_gr",
"q_finaexp_to_gr",
"q_impair_to_gr_ttm",
"q_gc_to_gr",
"q_op_to_gr",
"q_roe",
"q_dt_roe",
"q_npta",
"q_opincome_to_ebt",
"q_investincome_to_ebt",
"q_dtprofit_to_profit",
"q_salescash_to_or",
"q_ocf_to_sales",
"q_ocf_to_or",
"basic_eps_yoy",
"dt_eps_yoy",
"cfps_yoy",
"op_yoy",
"ebt_yoy",
"netprofit_yoy",
"dt_netprofit_yoy",
"ocf_yoy",
"roe_yoy",
"bps_yoy",
"assets_yoy",
"eqt_yoy",
"tr_yoy",
"or_yoy",
"q_gr_yoy",
"q_gr_qoq",
"q_sales_yoy",
"q_sales_qoq",
"q_op_yoy",
"q_op_qoq",
"q_profit_yoy",
"q_profit_qoq",
"q_netprofit_yoy",
"q_netprofit_qoq",
"equity_yoy",
"rd_exp",
"update_flag"
])
return df
def getsqlstr(row):
sqlstr = "insert into t_ods_hs_finance_indicator(ts_code, ann_date, end_date, eps, dt_eps, total_revenue_ps, revenue_ps, capital_rese_ps, surplus_rese_ps, undist_profit_ps, \
extra_item, profit_dedt, gross_margin, current_ratio, quick_ratio, cash_ratio, invturn_days, arturn_days, inv_turn, ar_turn, ca_turn, fa_turn, assets_turn, op_income, \
valuechange_income, interst_income, daa, ebit, ebitda, fcff, fcfe, current_exint, noncurrent_exint, interestdebt, netdebt, tangible_asset, working_capital, \
networking_capital, invest_capital, retained_earnings, diluted2_eps, bps, ocfps, retainedps, cfps, ebit_ps, fcff_ps, fcfe_ps, netprofit_margin, grossprofit_margin, \
cogs_of_sales, expense_of_sales, profit_to_gr, saleexp_to_gr, adminexp_of_gr, finaexp_of_gr, impai_ttm, gc_of_gr, op_of_gr, ebit_of_gr, roe, roe_waa, roe_dt, roa, npta, \
roic, roe_yearly, roa2_yearly, roe_avg, opincome_of_ebt, investincome_of_ebt, n_op_profit_of_ebt, tax_to_ebt, dtprofit_to_profit, salescash_to_or, ocf_to_or, \
ocf_to_opincome, capitalized_to_da, debt_to_assets, assets_to_eqt, dp_assets_to_eqt, ca_to_assets, nca_to_assets, tbassets_to_totalassets, int_to_talcap, \
eqt_to_talcapital, currentdebt_to_debt, longdeb_to_debt, ocf_to_shortdebt, debt_to_eqt, eqt_to_debt, eqt_to_interestdebt, tangibleasset_to_debt, tangasset_to_intdebt, \
tangibleasset_to_netdebt, ocf_to_debt, ocf_to_interestdebt, ocf_to_netdebt, ebit_to_interest, longdebt_to_workingcapital, ebitda_to_debt, turn_days, roa_yearly, \
roa_dp, fixed_assets, profit_prefin_exp, non_op_profit, op_to_ebt, nop_to_ebt, ocf_to_profit, cash_to_liqdebt, cash_to_liqdebt_withinterest, op_to_liqdebt, op_to_debt, \
roic_yearly, total_fa_trun, profit_to_op, q_opincome, q_investincome, q_dtprofit, q_eps, q_netprofit_margin, q_gsprofit_margin, q_exp_to_sales, q_profit_to_gr, \
q_saleexp_to_gr, q_adminexp_to_gr, q_finaexp_to_gr, q_impair_to_gr_ttm, q_gc_to_gr, q_op_to_gr, q_roe, q_dt_roe, q_npta, q_opincome_to_ebt, q_investincome_to_ebt, \
q_dtprofit_to_profit, q_salescash_to_or, q_ocf_to_sales, q_ocf_to_or, basic_eps_yoy, dt_eps_yoy, cfps_yoy, op_yoy, ebt_yoy, netprofit_yoy, dt_netprofit_yoy, ocf_yoy, \
roe_yoy, bps_yoy, assets_yoy, eqt_yoy, tr_yoy, or_yoy, q_gr_yoy, q_gr_qoq, q_sales_yoy, q_sales_qoq, q_op_yoy, q_op_qoq, q_profit_yoy, q_profit_qoq, q_netprofit_yoy, \
q_netprofit_qoq, equity_yoy, rd_exp, update_flag) \
values('%s', '%s', '%s', \
%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, \
%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, \
%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, \
%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, \
%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, \
%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, \
%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, \
%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, \
%f, %f, %f, '%s') \
on duplicate key update \
eps=%f, dt_eps=%f, total_revenue_ps=%f, revenue_ps=%f, capital_rese_ps=%f, surplus_rese_ps=%f, undist_profit_ps=%f, extra_item=%f, profit_dedt=%f, gross_margin=%f, \
current_ratio=%f, quick_ratio=%f, cash_ratio=%f, invturn_days=%f, arturn_days=%f, inv_turn=%f, ar_turn=%f, ca_turn=%f, fa_turn=%f, assets_turn=%f, op_income=%f, \
valuechange_income=%f, interst_income=%f, daa=%f, ebit=%f, ebitda=%f, fcff=%f, fcfe=%f, current_exint=%f, noncurrent_exint=%f, interestdebt=%f, netdebt=%f, \
tangible_asset=%f, working_capital=%f, networking_capital=%f, invest_capital=%f, retained_earnings=%f, diluted2_eps=%f, bps=%f, ocfps=%f, retainedps=%f, cfps=%f, \
ebit_ps=%f, fcff_ps=%f, fcfe_ps=%f, netprofit_margin=%f, grossprofit_margin=%f, cogs_of_sales=%f, expense_of_sales=%f, profit_to_gr=%f, saleexp_to_gr=%f, \
adminexp_of_gr=%f, finaexp_of_gr=%f, impai_ttm=%f, gc_of_gr=%f, op_of_gr=%f, ebit_of_gr=%f, roe=%f, roe_waa=%f, roe_dt=%f, roa=%f, npta=%f, roic=%f, roe_yearly=%f, \
roa2_yearly=%f, roe_avg=%f, opincome_of_ebt=%f, investincome_of_ebt=%f, n_op_profit_of_ebt=%f, tax_to_ebt=%f, dtprofit_to_profit=%f, salescash_to_or=%f, ocf_to_or=%f, \
ocf_to_opincome=%f, capitalized_to_da=%f, debt_to_assets=%f, assets_to_eqt=%f, dp_assets_to_eqt=%f, ca_to_assets=%f, nca_to_assets=%f, tbassets_to_totalassets=%f, \
int_to_talcap=%f, eqt_to_talcapital=%f, currentdebt_to_debt=%f, longdeb_to_debt=%f, ocf_to_shortdebt=%f, debt_to_eqt=%f, eqt_to_debt=%f, eqt_to_interestdebt=%f, \
tangibleasset_to_debt=%f, tangasset_to_intdebt=%f, tangibleasset_to_netdebt=%f, ocf_to_debt=%f, ocf_to_interestdebt=%f, ocf_to_netdebt=%f, ebit_to_interest=%f, \
longdebt_to_workingcapital=%f, ebitda_to_debt=%f, turn_days=%f, roa_yearly=%f, roa_dp=%f, fixed_assets=%f, profit_prefin_exp=%f, non_op_profit=%f, op_to_ebt=%f, \
nop_to_ebt=%f, ocf_to_profit=%f, cash_to_liqdebt=%f, cash_to_liqdebt_withinterest=%f, op_to_liqdebt=%f, op_to_debt=%f, roic_yearly=%f, total_fa_trun=%f, profit_to_op=%f, \
q_opincome=%f, q_investincome=%f, q_dtprofit=%f, q_eps=%f, q_netprofit_margin=%f, q_gsprofit_margin=%f, q_exp_to_sales=%f, q_profit_to_gr=%f, q_saleexp_to_gr=%f, \
q_adminexp_to_gr=%f, q_finaexp_to_gr=%f, q_impair_to_gr_ttm=%f, q_gc_to_gr=%f, q_op_to_gr=%f, q_roe=%f, q_dt_roe=%f, q_npta=%f, q_opincome_to_ebt=%f, \
q_investincome_to_ebt=%f, q_dtprofit_to_profit=%f, q_salescash_to_or=%f, q_ocf_to_sales=%f, q_ocf_to_or=%f, basic_eps_yoy=%f, dt_eps_yoy=%f, cfps_yoy=%f, op_yoy=%f, \
ebt_yoy=%f, netprofit_yoy=%f, dt_netprofit_yoy=%f, ocf_yoy=%f, roe_yoy=%f, bps_yoy=%f, assets_yoy=%f, eqt_yoy=%f, tr_yoy=%f, or_yoy=%f, q_gr_yoy=%f, q_gr_qoq=%f, \
q_sales_yoy=%f, q_sales_qoq=%f, q_op_yoy=%f, q_op_qoq=%f, q_profit_yoy=%f, q_profit_qoq=%f, q_netprofit_yoy=%f, q_netprofit_qoq=%f, equity_yoy=%f, rd_exp=%f " % (
getattr(row, 'ts_code'), getattr(row, 'ann_date'), getattr(row, 'end_date'),
str2float(getattr(row, 'eps')), str2float(getattr(row, 'dt_eps')), str2float(getattr(row, 'total_revenue_ps')), str2float(getattr(row, 'revenue_ps')),
str2float(getattr(row, 'capital_rese_ps')), str2float(getattr(row, 'surplus_rese_ps')), str2float(getattr(row, 'undist_profit_ps')),
str2float(getattr(row, 'extra_item')), str2float(getattr(row, 'profit_dedt')), str2float(getattr(row, 'gross_margin')), str2float(getattr(row, 'current_ratio')),
str2float(getattr(row, 'quick_ratio')), str2float(getattr(row, 'cash_ratio')), str2float(getattr(row, 'invturn_days')), str2float(getattr(row, 'arturn_days')),
str2float(getattr(row, 'inv_turn')), str2float(getattr(row, 'ar_turn')), str2float(getattr(row, 'ca_turn')), str2float(getattr(row, 'fa_turn')),
str2float(getattr(row, 'assets_turn')), str2float(getattr(row, 'op_income')), str2float(getattr(row, 'valuechange_income')), str2float(getattr(row, 'interst_income')),
str2float(getattr(row, 'daa')), str2float(getattr(row, 'ebit')), str2float(getattr(row, 'ebitda')), str2float(getattr(row, 'fcff')), str2float(getattr(row, 'fcfe')),
str2float(getattr(row, 'current_exint')), str2float(getattr(row, 'noncurrent_exint')), str2float(getattr(row, 'interestdebt')), str2float(getattr(row, 'netdebt')),
str2float(getattr(row, 'tangible_asset')), str2float(getattr(row, 'working_capital')), str2float(getattr(row, 'networking_capital')),
str2float(getattr(row, 'invest_capital')), str2float(getattr(row, 'retained_earnings')), str2float(getattr(row, 'diluted2_eps')), str2float(getattr(row, 'bps')),
str2float(getattr(row, 'ocfps')), str2float(getattr(row, 'retainedps')), str2float(getattr(row, 'cfps')), str2float(getattr(row, 'ebit_ps')),
str2float(getattr(row, 'fcff_ps')), str2float(getattr(row, 'fcfe_ps')), str2float(getattr(row, 'netprofit_margin')), str2float(getattr(row, 'grossprofit_margin')),
str2float(getattr(row, 'cogs_of_sales')), str2float(getattr(row, 'expense_of_sales')), str2float(getattr(row, 'profit_to_gr')), str2float(getattr(row, 'saleexp_to_gr')),
str2float(getattr(row, 'adminexp_of_gr')), str2float(getattr(row, 'finaexp_of_gr')), str2float(getattr(row, 'impai_ttm')), str2float(getattr(row, 'gc_of_gr')),
str2float(getattr(row, 'op_of_gr')), str2float(getattr(row, 'ebit_of_gr')), str2float(getattr(row, 'roe')), str2float(getattr(row, 'roe_waa')),
str2float(getattr(row, 'roe_dt')), str2float(getattr(row, 'roa')), str2float(getattr(row, 'npta')), str2float(getattr(row, 'roic')), str2float(getattr(row, 'roe_yearly')),
str2float(getattr(row, 'roa2_yearly')), str2float(getattr(row, 'roe_avg')), str2float(getattr(row, 'opincome_of_ebt')), str2float(getattr(row, 'investincome_of_ebt')),
str2float(getattr(row, 'n_op_profit_of_ebt')), str2float(getattr(row, 'tax_to_ebt')), str2float(getattr(row, 'dtprofit_to_profit')),
str2float(getattr(row, 'salescash_to_or')), str2float(getattr(row, 'ocf_to_or')), str2float(getattr(row, 'ocf_to_opincome')), str2float(getattr(row, 'capitalized_to_da')),
str2float(getattr(row, 'debt_to_assets')), str2float(getattr(row, 'assets_to_eqt')), str2float(getattr(row, 'dp_assets_to_eqt')), str2float(getattr(row, 'ca_to_assets')),
str2float(getattr(row, 'nca_to_assets')), str2float(getattr(row, 'tbassets_to_totalassets')), str2float(getattr(row, 'int_to_talcap')),
str2float(getattr(row, 'eqt_to_talcapital')), str2float(getattr(row, 'currentdebt_to_debt')), str2float(getattr(row, 'longdeb_to_debt')),
str2float(getattr(row, 'ocf_to_shortdebt')), str2float(getattr(row, 'debt_to_eqt')), str2float(getattr(row, 'eqt_to_debt')), str2float(getattr(row, 'eqt_to_interestdebt')),
str2float(getattr(row, 'tangibleasset_to_debt')), str2float(getattr(row, 'tangasset_to_intdebt')), str2float(getattr(row, 'tangibleasset_to_netdebt')),
str2float(getattr(row, 'ocf_to_debt')), str2float(getattr(row, 'ocf_to_interestdebt')), str2float(getattr(row, 'ocf_to_netdebt')),
str2float(getattr(row, 'ebit_to_interest')), str2float(getattr(row, 'longdebt_to_workingcapital')), str2float(getattr(row, 'ebitda_to_debt')),
str2float(getattr(row, 'turn_days')), str2float(getattr(row, 'roa_yearly')), str2float(getattr(row, 'roa_dp')), str2float(getattr(row, 'fixed_assets')),
str2float(getattr(row, 'profit_prefin_exp')), str2float(getattr(row, 'non_op_profit')), str2float(getattr(row, 'op_to_ebt')), str2float(getattr(row, 'nop_to_ebt')),
str2float(getattr(row, 'ocf_to_profit')), str2float(getattr(row, 'cash_to_liqdebt')), str2float(getattr(row, 'cash_to_liqdebt_withinterest')),
str2float(getattr(row, 'op_to_liqdebt')), str2float(getattr(row, 'op_to_debt')), str2float(getattr(row, 'roic_yearly')), str2float(getattr(row, 'total_fa_trun')),
str2float(getattr(row, 'profit_to_op')), str2float(getattr(row, 'q_opincome')), str2float(getattr(row, 'q_investincome')), str2float(getattr(row, 'q_dtprofit')),
str2float(getattr(row, 'q_eps')), str2float(getattr(row, 'q_netprofit_margin')), str2float(getattr(row, 'q_gsprofit_margin')), str2float(getattr(row, 'q_exp_to_sales')),
str2float(getattr(row, 'q_profit_to_gr')), str2float(getattr(row, 'q_saleexp_to_gr')), str2float(getattr(row, 'q_adminexp_to_gr')), str2float(getattr(row, 'q_finaexp_to_gr')),
str2float(getattr(row, 'q_impair_to_gr_ttm')), str2float(getattr(row, 'q_gc_to_gr')), str2float(getattr(row, 'q_op_to_gr')), str2float(getattr(row, 'q_roe')),
str2float(getattr(row, 'q_dt_roe')), str2float(getattr(row, 'q_npta')), str2float(getattr(row, 'q_opincome_to_ebt')), str2float(getattr(row, 'q_investincome_to_ebt')),
str2float(getattr(row, 'q_dtprofit_to_profit')), str2float(getattr(row, 'q_salescash_to_or')), str2float(getattr(row, 'q_ocf_to_sales')),
str2float(getattr(row, 'q_ocf_to_or')), str2float(getattr(row, 'basic_eps_yoy')), str2float(getattr(row, 'dt_eps_yoy')), str2float(getattr(row, 'cfps_yoy')),
str2float(getattr(row, 'op_yoy')), str2float(getattr(row, 'ebt_yoy')), str2float(getattr(row, 'netprofit_yoy')), str2float(getattr(row, 'dt_netprofit_yoy')),
str2float(getattr(row, 'ocf_yoy')), str2float(getattr(row, 'roe_yoy')), str2float(getattr(row, 'bps_yoy')), str2float(getattr(row, 'assets_yoy')),
str2float(getattr(row, 'eqt_yoy')), str2float(getattr(row, 'tr_yoy')), str2float(getattr(row, 'or_yoy')), str2float(getattr(row, 'q_gr_yoy')),
str2float(getattr(row, 'q_gr_qoq')), str2float(getattr(row, 'q_sales_yoy')), str2float(getattr(row, 'q_sales_qoq')), str2float(getattr(row, 'q_op_yoy')),
str2float(getattr(row, 'q_op_qoq')), str2float(getattr(row, 'q_profit_yoy')), str2float(getattr(row, 'q_profit_qoq')), str2float(getattr(row, 'q_netprofit_yoy')),
str2float(getattr(row, 'q_netprofit_qoq')), str2float(getattr(row, 'equity_yoy')), str2float(getattr(row, 'rd_exp')),
getattr(row, 'update_flag'),
str2float(getattr(row, 'eps')), str2float(getattr(row, 'dt_eps')), str2float(getattr(row, 'total_revenue_ps')), str2float(getattr(row, 'revenue_ps')),
str2float(getattr(row, 'capital_rese_ps')), str2float(getattr(row, 'surplus_rese_ps')), str2float(getattr(row, 'undist_profit_ps')),
str2float(getattr(row, 'extra_item')), str2float(getattr(row, 'profit_dedt')), str2float(getattr(row, 'gross_margin')), str2float(getattr(row, 'current_ratio')),
str2float(getattr(row, 'quick_ratio')), str2float(getattr(row, 'cash_ratio')), str2float(getattr(row, 'invturn_days')), str2float(getattr(row, 'arturn_days')),
str2float(getattr(row, 'inv_turn')), str2float(getattr(row, 'ar_turn')), str2float(getattr(row, 'ca_turn')), str2float(getattr(row, 'fa_turn')),
str2float(getattr(row, 'assets_turn')), str2float(getattr(row, 'op_income')), str2float(getattr(row, 'valuechange_income')), str2float(getattr(row, 'interst_income')),
str2float(getattr(row, 'daa')), str2float(getattr(row, 'ebit')), str2float(getattr(row, 'ebitda')), str2float(getattr(row, 'fcff')), str2float(getattr(row, 'fcfe')),
str2float(getattr(row, 'current_exint')), str2float(getattr(row, 'noncurrent_exint')), str2float(getattr(row, 'interestdebt')), str2float(getattr(row, 'netdebt')),
str2float(getattr(row, 'tangible_asset')), str2float(getattr(row, 'working_capital')), str2float(getattr(row, 'networking_capital')),
str2float(getattr(row, 'invest_capital')), str2float(getattr(row, 'retained_earnings')), str2float(getattr(row, 'diluted2_eps')), str2float(getattr(row, 'bps')),
str2float(getattr(row, 'ocfps')), str2float(getattr(row, 'retainedps')), str2float(getattr(row, 'cfps')), str2float(getattr(row, 'ebit_ps')),
str2float(getattr(row, 'fcff_ps')), str2float(getattr(row, 'fcfe_ps')), str2float(getattr(row, 'netprofit_margin')), str2float(getattr(row, 'grossprofit_margin')),
str2float(getattr(row, 'cogs_of_sales')), str2float(getattr(row, 'expense_of_sales')), str2float(getattr(row, 'profit_to_gr')), str2float(getattr(row, 'saleexp_to_gr')),
str2float(getattr(row, 'adminexp_of_gr')), str2float(getattr(row, 'finaexp_of_gr')), str2float(getattr(row, 'impai_ttm')), str2float(getattr(row, 'gc_of_gr')),
str2float(getattr(row, 'op_of_gr')), str2float(getattr(row, 'ebit_of_gr')), str2float(getattr(row, 'roe')), str2float(getattr(row, 'roe_waa')),
str2float(getattr(row, 'roe_dt')), str2float(getattr(row, 'roa')), str2float(getattr(row, 'npta')), str2float(getattr(row, 'roic')), str2float(getattr(row, 'roe_yearly')),
str2float(getattr(row, 'roa2_yearly')), str2float(getattr(row, 'roe_avg')), str2float(getattr(row, 'opincome_of_ebt')), str2float(getattr(row, 'investincome_of_ebt')),
str2float(getattr(row, 'n_op_profit_of_ebt')), str2float(getattr(row, 'tax_to_ebt')), str2float(getattr(row, 'dtprofit_to_profit')),
str2float(getattr(row, 'salescash_to_or')), str2float(getattr(row, 'ocf_to_or')), str2float(getattr(row, 'ocf_to_opincome')), str2float(getattr(row, 'capitalized_to_da')),
str2float(getattr(row, 'debt_to_assets')), str2float(getattr(row, 'assets_to_eqt')), str2float(getattr(row, 'dp_assets_to_eqt')), str2float(getattr(row, 'ca_to_assets')),
str2float(getattr(row, 'nca_to_assets')), str2float(getattr(row, 'tbassets_to_totalassets')), str2float(getattr(row, 'int_to_talcap')),
str2float(getattr(row, 'eqt_to_talcapital')), str2float(getattr(row, 'currentdebt_to_debt')), str2float(getattr(row, 'longdeb_to_debt')),
str2float(getattr(row, 'ocf_to_shortdebt')), str2float(getattr(row, 'debt_to_eqt')), str2float(getattr(row, 'eqt_to_debt')), str2float(getattr(row, 'eqt_to_interestdebt')),
str2float(getattr(row, 'tangibleasset_to_debt')), str2float(getattr(row, 'tangasset_to_intdebt')), str2float(getattr(row, 'tangibleasset_to_netdebt')),
str2float(getattr(row, 'ocf_to_debt')), str2float(getattr(row, 'ocf_to_interestdebt')), str2float(getattr(row, 'ocf_to_netdebt')),
str2float(getattr(row, 'ebit_to_interest')), str2float(getattr(row, 'longdebt_to_workingcapital')), str2float(getattr(row, 'ebitda_to_debt')),
str2float(getattr(row, 'turn_days')), str2float(getattr(row, 'roa_yearly')), str2float(getattr(row, 'roa_dp')), str2float(getattr(row, 'fixed_assets')),
str2float(getattr(row, 'profit_prefin_exp')), str2float(getattr(row, 'non_op_profit')), str2float(getattr(row, 'op_to_ebt')), str2float(getattr(row, 'nop_to_ebt')),
str2float(getattr(row, 'ocf_to_profit')), str2float(getattr(row, 'cash_to_liqdebt')), str2float(getattr(row, 'cash_to_liqdebt_withinterest')),
str2float(getattr(row, 'op_to_liqdebt')), str2float(getattr(row, 'op_to_debt')), str2float(getattr(row, 'roic_yearly')), str2float(getattr(row, 'total_fa_trun')),
str2float(getattr(row, 'profit_to_op')), str2float(getattr(row, 'q_opincome')), str2float(getattr(row, 'q_investincome')), str2float(getattr(row, 'q_dtprofit')),
str2float(getattr(row, 'q_eps')), str2float(getattr(row, 'q_netprofit_margin')), str2float(getattr(row, 'q_gsprofit_margin')), str2float(getattr(row, 'q_exp_to_sales')),
str2float(getattr(row, 'q_profit_to_gr')), str2float(getattr(row, 'q_saleexp_to_gr')), str2float(getattr(row, 'q_adminexp_to_gr')), str2float(getattr(row, 'q_finaexp_to_gr')),
str2float(getattr(row, 'q_impair_to_gr_ttm')), str2float(getattr(row, 'q_gc_to_gr')), str2float(getattr(row, 'q_op_to_gr')), str2float(getattr(row, 'q_roe')),
str2float(getattr(row, 'q_dt_roe')), str2float(getattr(row, 'q_npta')), str2float(getattr(row, 'q_opincome_to_ebt')), str2float(getattr(row, 'q_investincome_to_ebt')),
str2float(getattr(row, 'q_dtprofit_to_profit')), str2float(getattr(row, 'q_salescash_to_or')), str2float(getattr(row, 'q_ocf_to_sales')),
str2float(getattr(row, 'q_ocf_to_or')), str2float(getattr(row, 'basic_eps_yoy')), str2float(getattr(row, 'dt_eps_yoy')), str2float(getattr(row, 'cfps_yoy')),
str2float(getattr(row, 'op_yoy')), str2float(getattr(row, 'ebt_yoy')), str2float(getattr(row, 'netprofit_yoy')), str2float(getattr(row, 'dt_netprofit_yoy')),
str2float(getattr(row, 'ocf_yoy')), str2float(getattr(row, 'roe_yoy')), str2float(getattr(row, 'bps_yoy')), str2float(getattr(row, 'assets_yoy')),
str2float(getattr(row, 'eqt_yoy')), str2float(getattr(row, 'tr_yoy')), str2float(getattr(row, 'or_yoy')), str2float(getattr(row, 'q_gr_yoy')),
str2float(getattr(row, 'q_gr_qoq')), str2float(getattr(row, 'q_sales_yoy')), str2float(getattr(row, 'q_sales_qoq')), str2float(getattr(row, 'q_op_yoy')),
str2float(getattr(row, 'q_op_qoq')), str2float(getattr(row, 'q_profit_yoy')), str2float(getattr(row, 'q_profit_qoq')), str2float(getattr(row, 'q_netprofit_yoy')),
str2float(getattr(row, 'q_netprofit_qoq')), str2float(getattr(row, 'equity_yoy')), str2float(getattr(row, 'rd_exp'))
)
return sqlstr
def process():
stock_list = []
cursor = db.cursor()
total_stocks = 0
total_rows = 0
fd = open("./indicator.log", 'w+')
# get stock list
sqlstr = "select ts_code from t_ods_hs_base_list where list_status = 'L' "
try:
cursor.execute(sqlstr)
results = cursor.fetchall()
for row in results :
stock_list.append(row[0])
total_stocks = total_stocks+1
except Exception as ex:
print (ex)
print ("get stock list error!")
db.close()
return
# get income data
for st_code in stock_list :
df = queryts(st_code)
loop = 0
for row in df.itertuples():
sql = getsqlstr(row)
try:
cursor.execute(sql)
db.commit()
loop = loop+1
except Exception as ex:
print (ex)
print ("get stock %s error!" % st_code )
db.rollback()
return
print("get %s indicator data succ! total rows: %d" % (st_code, loop))
fd.write("get %s indicator data succ! total rows: %d \n" % (st_code, loop))
fd.flush()
total_rows = total_rows+loop
time.sleep(0.5)
# get all data
print("All stock indicator data process succ! total stocks: %d, total rows: %d " % (total_stocks, total_rows))
fd.write("All stock indicator data process succ! total stocks: %d, total rows: %d \n" % (total_stocks, total_rows))
# close db and file
fd.close()
db.close()
process()

View File

@ -0,0 +1,73 @@
import tushare as ts
import MySQLdb
from config import CONFIG_DB
from config import CONFIG_TS
db = MySQLdb.connect(CONFIG_DB['host'], CONFIG_DB['user'], CONFIG_DB['password'], CONFIG_DB['database'], charset='utf8')
pro = ts.pro_api(CONFIG_TS['secret'])
def str2float( str ):
try:
val = float(str)
if math.isinf(val) or math.isnan(val) :
val = 0
return val
except Exception as e:
return 0.0
df = pro.index_basic(**{
"ts_code": "",
"market": "",
"publisher": "",
"category": "",
"name": "",
"limit": "",
"offset": ""
}, fields=[
"ts_code",
"name",
"fullname",
"market",
"publisher",
"index_type",
"category",
"base_date",
"base_point",
"list_date",
"weight_rule",
"desc",
"exp_date"
])
cursor = db.cursor()
for row in df.itertuples():
sql = "insert into t_ods_hs_indicator_list(ts_code, name, fullname, market, publisher, index_type, category, \
base_date, base_point, list_date, weight_rule, ts_desc, exp_date) \
values('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %f, '%s', '%s', '%s', '%s') \
on duplicate key update name= '%s', fullname= '%s', market='%s', publisher='%s', index_type='%s', \
category='%s', base_date='%s', base_point=%f, list_date='%s', weight_rule='%s', ts_desc='%s', \
exp_date='%s' " % \
(getattr(row, 'ts_code'), getattr(row, 'name'), getattr(row, 'fullname'), getattr(row, 'market'),
getattr(row, 'publisher'), getattr(row, 'index_type'), getattr(row, 'category'), getattr(row, 'base_date'),
str2float(getattr(row, 'base_point')), getattr(row, 'list_date'), getattr(row, 'weight_rule'),
getattr(row, 'desc'), getattr(row, 'exp_date'),
getattr(row, 'name'), getattr(row, 'fullname'), getattr(row, 'market'),
getattr(row, 'publisher'), getattr(row, 'index_type'), getattr(row, 'category'), getattr(row, 'base_date'),
str2float(getattr(row, 'base_point')), getattr(row, 'list_date'), getattr(row, 'weight_rule'),
getattr(row, 'desc'), getattr(row, 'exp_date'), )
try:
cursor.execute(sql)
db.commit()
except Exception as ex:
print (ex)
db.rollback()
break
db.close()

12
tushare/src/test.py Normal file
View File

@ -0,0 +1,12 @@
import tushare as ts
str = ""
flt = 0
try:
flt = float(str)
except Exception as e:
print(e)
flt = 0.0
print("val: %f" % flt)
print (float('452797773974.14'))

File diff suppressed because one or more lines are too long