Commit 2353e349 authored by 李煜's avatar 李煜

modify per share

parent 757bc40e
......@@ -504,7 +504,7 @@ def get_basic_earning(trade_date):
if __name__ == '__main__':
session1 = str('156099868869460811')
session2 = str('156099868869460812')
# session3 = str('156099868869460813')
session3 = str('156099868869460813')
session4 = str('156099868869460814')
session5 = str('156099868869460815')
session6 = str('156099868869460816')
......@@ -525,9 +525,9 @@ if __name__ == '__main__':
history_value = historical_value.HistoricalValue('factor_historical_value')
history_value.create_dest_tables()
# scale
# scale = factor_per_share_indicators.PerShareIndicators('factor_scale')
# scale.create_dest_tables()
# per shapre
per_share = factor_per_share_indicators.PerShareIndicators('factor_per_share')
per_share.create_dest_tables()
# cash flow
cash_flow = factor_cash_flow.FactorCashFlow('factor_cash_flow')
......@@ -538,8 +538,8 @@ if __name__ == '__main__':
constrain.create_dest_tables()
# earning
earning = factor_earning.FactorEarning('factor_earning')
earning.create_dest_tables()
# earning = factor_earning.FactorEarning('factor_earning')
# earning.create_dest_tables()
for date_index in trade_date_sets:
# factor_growth
......@@ -561,14 +561,16 @@ if __name__ == '__main__':
time2 = time.time()
print('history_cal_time:{}'.format(time2 - time1))
# # scale
# valuation_sets, ttm_factor_sets, cash_flow_sets, income_sets, balance_sets = get_basic_scale_data(date_index)
# valuation_sets = pd.merge(valuation_sets, income_sets, on='symbol')
# valuation_sets = pd.merge(valuation_sets, ttm_factor_sets, on='symbol')
# valuation_sets = pd.merge(valuation_sets, cash_flow_sets, on='symbol')
# valuation_sets = pd.merge(valuation_sets, balance_sets, on='symbol')
# cache_data.set_cache(session3, date_index, valuation_sets.to_json(orient='records'))
# factor_per_share_indicators.factor_calculate(date_index=date_index, session=session3)
# per share indicators
valuation_sets, ttm_factor_sets, cash_flow_sets, income_sets, balance_sets = get_basic_scale_data(date_index)
valuation_sets = pd.merge(valuation_sets, income_sets, on='symbol')
valuation_sets = pd.merge(valuation_sets, ttm_factor_sets, on='symbol')
valuation_sets = pd.merge(valuation_sets, cash_flow_sets, on='symbol')
valuation_sets = pd.merge(valuation_sets, balance_sets, on='symbol')
cache_data.set_cache(session3, date_index, valuation_sets.to_json(orient='records'))
factor_per_share_indicators.factor_calculate(date_index=date_index, session=session3)
time3 = time.time()
print('per_share_cal_time:{}'.format(time3 - time2))
# cash flow
tp_cash_flow, ttm_factor_sets = get_basic_cash_flow(date_index)
......@@ -576,7 +578,7 @@ if __name__ == '__main__':
cache_data.set_cache(session4 + "2", date_index, ttm_factor_sets.to_json(orient='records'))
factor_cash_flow.factor_calculate(date_index=date_index, session=session4)
time4 = time.time()
print('cash_flow_cal_time:{}'.format(time4 - time2))
print('cash_flow_cal_time:{}'.format(time4 - time3))
# constrain
balance_sets, ttm_factors_sets = get_basic_constrain(date_index)
......@@ -587,11 +589,11 @@ if __name__ == '__main__':
print('constrain_cal_time:{}'.format(time5 - time4))
# earning
tp_earning, ttm_earning_5y, ttm_earning = get_basic_earning(date_index)
cache_data.set_cache(session6 + "1", date_index, tp_earning.to_json(orient='records'))
cache_data.set_cache(session6 + "2", date_index, ttm_earning_5y.to_json(orient='records'))
cache_data.set_cache(session6 + "3", date_index, ttm_earning.to_json(orient='records'))
factor_earning.factor_calculate(date_index=date_index, session=session6)
time6 = time.time()
print('earning_cal_time:{}'.format(time6 - time5))
# tp_earning, ttm_earning_5y, ttm_earning = get_basic_earning(date_index)
# cache_data.set_cache(session6 + "1", date_index, tp_earning.to_json(orient='records'))
# cache_data.set_cache(session6 + "2", date_index, ttm_earning_5y.to_json(orient='records'))
# cache_data.set_cache(session6 + "3", date_index, ttm_earning.to_json(orient='records'))
# factor_earning.factor_calculate(date_index=date_index, session=session6)
# time6 = time.time()
# print('earning_cal_time:{}'.format(time6 - time5))
print('---------------------->')
......@@ -38,26 +38,26 @@ class PerShareIndicators(FactorBase):
`id` varchar(32) NOT NULL,
`symbol` varchar(24) NOT NULL,
`trade_date` date NOT NULL,
`eps_latest` decimal(19,4),
`diluted_eps_ttm` decimal(19,4),
`cash_equivalent_ps_latest` decimal(19,4),
`dividend_ps_latest` decimal(19,4),
`eps_ttm` decimal(19,4),
`net_asset_ps_latest` decimal(19,4),
`tor_ps_latest` decimal(19,4),
`tor_ps_ttm` decimal(19,4),
`operating_revenue_ps_ttm` decimal(19,4),
`operating_revenue_ps_latest` decimal(19,4),
`operating_profit_ps_ttm` decimal(19,4),
`operating_profit_ps_latest` decimal(19,4),
`capital_surplus_fund_ps_latest` decimal(19,4),
`surplus_reserve_fund_ps_latest` decimal(19,4),
`undivided_pro_fit_ps_latest` decimal(19,4),
`retained_earnings_ps_latest` decimal(19,4),
`oper_cash_flow_ps_ttm` decimal(19,4),
`cash_flow_ps_ttm` decimal(19,4),
`enterprise_fcfps_latest` decimal(19,4),
`shareholder_fcfps_latest` decimal(19,4),
`EPS` decimal(19,4),
`DilutedEPSTTM` decimal(19,4),
`CashEquPS` decimal(19,4),
`DivPS` decimal(19,4),
`EPSTTM` decimal(19,4),
`NetAssetPS` decimal(19,4),
`TotalRevPS` decimal(19,4),
`TotalRevPSTTM` decimal(19,4),
`OptRevPSTTM` decimal(19,4),
`OptRevPS` decimal(19,4),
`OptProfitPSTTM` decimal(19,4),
`OptProfitPS` decimal(19,4),
`CapticalSurplusPS` decimal(19,4),
`SurplusReservePS` decimal(19,4),
`UndividedProfitPS` decimal(19,4),
`RetainedEarningsPS` decimal(19,4),
`OptCFPSTTM` decimal(19,4),
`CFPSTTM` decimal(19,4),
`EnterpriseFCFPS` decimal(19,4),
`ShareholderFCFPS` decimal(19,4),
PRIMARY KEY(`id`,`trade_date`,`symbol`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;""".format(self._name)
super(PerShareIndicators, self)._create_tables(create_sql, drop_sql)
......@@ -71,9 +71,9 @@ class PerShareIndicators(FactorBase):
"""
columns_lists = ['symbol', 'basic_eps']
share_indicators = tp_share_indicators.loc[:, columns_lists]
share_indicators['eps_latest'] = share_indicators['basic_eps']
share_indicators['EPS'] = share_indicators['basic_eps']
# share_indicators = share_indicators.drop(columns=['basic_eps'], axis=1)
share_indicators = share_indicators[['symbol', 'eps_latest']]
share_indicators = share_indicators[['symbol', 'EPS']]
factor_share_indicators = pd.merge(factor_share_indicators, share_indicators, on='symbol')
return factor_share_indicators
......@@ -86,9 +86,9 @@ class PerShareIndicators(FactorBase):
"""
columns_lists = ['symbol', 'diluted_eps']
share_indicators = tp_share_indicators.loc[:, columns_lists]
share_indicators['diluted_eps_ttm'] = share_indicators['diluted_eps']
share_indicators['DilutedEPSTTM'] = share_indicators['diluted_eps']
# share_indicators = share_indicators.drop(columns=['diluted_eps'], axis=1)
share_indicators = share_indicators[['symbol', 'diluted_eps_ttm']]
share_indicators = share_indicators[['symbol', 'DilutedEPSTTM']]
factor_share_indicators = pd.merge(factor_share_indicators, share_indicators, on='symbol')
return factor_share_indicators
......@@ -103,11 +103,11 @@ class PerShareIndicators(FactorBase):
columns_lists = ['symbol', 'capitalization', 'cash_and_equivalents_at_end']
share_indicators = tp_share_indicators.loc[:, columns_lists]
fun = lambda x: (x[1] / x[0] if x[0] and x[0] != 0 else None)
share_indicators['cash_equivalent_ps_latest'] = share_indicators[
share_indicators['CashEquPS'] = share_indicators[
['capitalization', 'cash_and_equivalents_at_end']].apply(fun, axis=1)
# share_indicators = share_indicators.drop(columns=['cash_and_equivalents_at_end'], axis=1)
share_indicators = share_indicators[['symbol', 'cash_equivalent_ps_latest']]
share_indicators = share_indicators[['symbol', 'CashEquPS']]
factor_share_indicators = pd.merge(factor_share_indicators, share_indicators, on='symbol')
return factor_share_indicators
......@@ -121,9 +121,9 @@ class PerShareIndicators(FactorBase):
"""
columns_lists = ['symbol', 'dividend_receivable']
share_indicators = tp_share_indicators.loc[:, columns_lists]
share_indicators['dividend_ps_latest'] = share_indicators['dividend_receivable']
share_indicators['DivPS'] = share_indicators['dividend_receivable']
# share_indicators = share_indicators.drop(columns=['dividend_receivable'], axis=1)
share_indicators = share_indicators[['symbol', 'dividend_ps_latest']]
share_indicators = share_indicators[['symbol', 'DivPS']]
factor_share_indicators = pd.merge(factor_share_indicators, share_indicators, on='symbol')
return factor_share_indicators
......@@ -138,11 +138,11 @@ class PerShareIndicators(FactorBase):
columns_lists = ['symbol', 'np_parent_company_owners_ttm', 'capitalization']
share_indicators = tp_share_indicators.loc[:, columns_lists]
fun = lambda x: (x[0] / x[1] if x[1] and x[1] != 0 else 0)
share_indicators['eps_ttm'] = share_indicators[['np_parent_company_owners_ttm', 'capitalization']].apply(fun,
share_indicators['EPSTTM'] = share_indicators[['np_parent_company_owners_ttm', 'capitalization']].apply(fun,
axis=1)
# share_indicators = share_indicators.drop(columns=['np_parent_company_owners_ttm'], axis=1)
share_indicators = share_indicators[['symbol', 'eps_ttm']]
share_indicators = share_indicators[['symbol', 'EPSTTM']]
factor_share_indicators = pd.merge(factor_share_indicators, share_indicators, on='symbol')
return factor_share_indicators
......@@ -157,11 +157,11 @@ class PerShareIndicators(FactorBase):
columns_lists = ['symbol', 'total_owner_equities', 'capitalization']
share_indicators = tp_share_indicators.loc[:, columns_lists]
fun = lambda x: (x[0] / x[1] if x[1] and x[1] != 0 else None)
share_indicators['net_asset_ps_latest'] = share_indicators[['total_owner_equities', 'capitalization']].apply(fun,
share_indicators['NetAssetPS'] = share_indicators[['total_owner_equities', 'capitalization']].apply(fun,
axis=1)
# share_indicators = share_indicators.drop(columns=['total_owner_equities'], axis=1)
share_indicators = share_indicators[['symbol', 'net_asset_ps_latest']]
share_indicators = share_indicators[['symbol', 'NetAssetPS']]
factor_share_indicators = pd.merge(factor_share_indicators, share_indicators, on='symbol')
return factor_share_indicators
......@@ -175,11 +175,11 @@ class PerShareIndicators(FactorBase):
columns_lists = ['symbol', 'total_operating_revenue_ttm', 'capitalization']
share_indicators = tp_share_indicators.loc[:, columns_lists]
fun = lambda x: (x[0] / x[1] if x[1] and x[1] != 0 else None)
share_indicators['tor_ps_ttm'] = share_indicators[
share_indicators['TotalRevPSTTM'] = share_indicators[
['total_operating_revenue_ttm', 'capitalization']].apply(fun, axis=1)
# share_indicators = share_indicators.drop(columns=['total_operating_revenue_ttm'], axis=1)
share_indicators = share_indicators[['symbol', 'tor_ps_ttm']]
share_indicators = share_indicators[['symbol', 'TotalRevPSTTM']]
factor_share_indicators = pd.merge(factor_share_indicators, share_indicators, on='symbol')
return factor_share_indicators
......@@ -194,10 +194,10 @@ class PerShareIndicators(FactorBase):
columns_lists = ['symbol', 'total_operating_revenue', 'capitalization']
share_indicators = tp_share_indicators.loc[:, columns_lists]
fun = lambda x: (x[0] / x[1] if x[1] and x[1] != 0 else None)
share_indicators['tor_ps_latest'] = share_indicators[['total_operating_revenue', 'capitalization']].apply(fun, axis=1)
share_indicators['TotalRevPS'] = share_indicators[['total_operating_revenue', 'capitalization']].apply(fun, axis=1)
# share_indicators = share_indicators.drop(columns=['total_operating_revenue'], axis=1)
share_indicators = share_indicators[['symbol', 'tor_ps_latest']]
share_indicators = share_indicators[['symbol', 'TotalRevPS']]
factor_share_indicators = pd.merge(factor_share_indicators, share_indicators, on='symbol')
return factor_share_indicators
......@@ -212,13 +212,13 @@ class PerShareIndicators(FactorBase):
columns_lists = ['symbol', 'operating_revenue_ttm', 'capitalization']
share_indicators = tp_share_indicators.loc[:, columns_lists]
fun = lambda x: (x[0] / x[1] if x[1] and x[1] != 0 else None)
share_indicators['operating_revenue_ps_ttm'] = share_indicators[
share_indicators['OptRevPSTTM'] = share_indicators[
['operating_revenue_ttm', 'capitalization']].apply(
fun,
axis=1)
# share_indicators = share_indicators.drop(columns=['operating_revenue_ttm'], axis=1)
share_indicators = share_indicators[['symbol', 'operating_revenue_ps_ttm']]
share_indicators = share_indicators[['symbol', 'OptRevPSTTM']]
factor_share_indicators = pd.merge(factor_share_indicators, share_indicators, on='symbol')
return factor_share_indicators
......@@ -232,13 +232,13 @@ class PerShareIndicators(FactorBase):
columns_lists = ['symbol', 'operating_revenue', 'capitalization']
share_indicators = tp_share_indicators.loc[:, columns_lists]
fun = lambda x: (x[0] / x[1] if x[1] and x[1] != 0 else None)
share_indicators['operating_revenue_ps_latest'] = share_indicators[
share_indicators['OptRevPS'] = share_indicators[
['operating_revenue', 'capitalization']].apply(
fun,
axis=1)
# share_indicators = share_indicators.drop(columns=['operating_revenue'], axis=1)
share_indicators = share_indicators[['symbol', 'operating_revenue_ps_latest']]
share_indicators = share_indicators[['symbol', 'OptRevPS']]
factor_share_indicators = pd.merge(factor_share_indicators, share_indicators, on='symbol')
return factor_share_indicators
......@@ -253,13 +253,13 @@ class PerShareIndicators(FactorBase):
columns_lists = ['symbol', 'operating_profit_ttm', 'capitalization']
share_indicators = tp_share_indicators.loc[:, columns_lists]
fun = lambda x: (x[0] / x[1] if x[1] and x[1] != 0 else None)
share_indicators['operating_profit_ps_ttm'] = share_indicators[
share_indicators['OptProfitPSTTM'] = share_indicators[
['operating_profit_ttm', 'capitalization']].apply(
fun,
axis=1)
# share_indicators = share_indicators.drop(columns=['operating_profit_ttm'], axis=1)
share_indicators = share_indicators[['symbol', 'operating_profit_ps_ttm']]
share_indicators = share_indicators[['symbol', 'OptProfitPSTTM']]
factor_share_indicators = pd.merge(factor_share_indicators, share_indicators, on='symbol')
return factor_share_indicators
......@@ -274,13 +274,10 @@ class PerShareIndicators(FactorBase):
columns_lists = ['symbol', 'operating_profit', 'capitalization']
share_indicators = tp_share_indicators.loc[:, columns_lists]
fun = lambda x: (x[0] / x[1] if x[1] and x[1] != 0 else None)
share_indicators['operating_profit_ps_latest'] = share_indicators[
['operating_profit', 'capitalization']].apply(
fun,
axis=1)
share_indicators['OptProfitPS'] = share_indicators[['operating_profit', 'capitalization']].apply(fun, axis=1)
# share_indicators = share_indicators.drop(columns=['operating_profit'], axis=1)
share_indicators = share_indicators[['symbol', 'operating_profit_ps_latest']]
share_indicators = share_indicators[['symbol', 'OptProfitPS']]
factor_share_indicators = pd.merge(factor_share_indicators, share_indicators, on='symbol')
return factor_share_indicators
......@@ -294,13 +291,13 @@ class PerShareIndicators(FactorBase):
columns_lists = ['symbol', 'capital_reserve_fund', 'capitalization']
share_indicators = tp_share_indicators.loc[:, columns_lists]
fun = lambda x: (x[0] / x[1] if x[1] and x[1] != 0 else None)
share_indicators['capital_surplus_fund_ps_latest'] = share_indicators[
share_indicators['CapticalSurplusPS'] = share_indicators[
['capital_reserve_fund', 'capitalization']].apply(
fun,
axis=1)
# share_indicators = share_indicators.drop(columns=['capital_reserve_fund'], axis=1)
share_indicators = share_indicators[['symbol', 'capital_surplus_fund_ps_latest']]
share_indicators = share_indicators[['symbol', 'CapticalSurplusPS']]
factor_share_indicators = pd.merge(factor_share_indicators, share_indicators, on='symbol')
return factor_share_indicators
......@@ -314,10 +311,10 @@ class PerShareIndicators(FactorBase):
columns_lists = ['symbol', 'surplus_reserve_fund', 'capitalization']
share_indicators = tp_share_indicators.loc[:, columns_lists]
fun = lambda x: (x[0] / x[1] if x[1] and x[1] != 0 else None)
share_indicators['surplus_reserve_fund_ps_latest'] = share_indicators[['surplus_reserve_fund', 'capitalization']].apply(fun, axis=1)
share_indicators['SurplusReservePS'] = share_indicators[['surplus_reserve_fund', 'capitalization']].apply(fun, axis=1)
# share_indicators = share_indicators.drop(columns=['surplus_reserve_fund'], axis=1)
share_indicators = share_indicators[['symbol', 'surplus_reserve_fund_ps_latest']]
share_indicators = share_indicators[['symbol', 'SurplusReservePS']]
factor_share_indicators = pd.merge(factor_share_indicators, share_indicators, on='symbol')
return factor_share_indicators
......@@ -332,13 +329,13 @@ class PerShareIndicators(FactorBase):
columns_lists = ['symbol', 'retained_profit', 'capitalization']
share_indicators = tp_share_indicators.loc[:, columns_lists]
fun = lambda x: (x[0] / x[1] if x[1] and x[1] != 0 else None)
share_indicators['undivided_pro_fit_ps_latest'] = share_indicators[
share_indicators['UndividedProfitPS'] = share_indicators[
['retained_profit', 'capitalization']].apply(
fun,
axis=1)
# share_indicators = share_indicators.drop(columns=['retained_profit'], axis=1)
share_indicators = share_indicators[['symbol', 'undivided_pro_fit_ps_latest']]
share_indicators = share_indicators[['symbol', 'UndividedProfitPS']]
factor_share_indicators = pd.merge(factor_share_indicators, share_indicators, on='symbol')
return factor_share_indicators
......@@ -349,13 +346,12 @@ class PerShareIndicators(FactorBase):
:param factor_share_indicators:
:return:
"""
columns_lists = ['symbol', 'surplus_reserve_fund_ps_latest', 'undivided_pro_fit_ps_latest']
columns_lists = ['symbol', 'SurplusReservePS', 'UndividedProfitPS']
share_indicators = tp_share_indicators.loc[:, columns_lists]
share_indicators['retained_earnings_ps_latest'] = share_indicators['undivided_pro_fit_ps_latest'] + \
share_indicators['surplus_reserve_fund_ps_latest']
share_indicators['RetainedEarningsPS'] = share_indicators['UndividedProfitPS'] + share_indicators['SurplusReservePS']
# share_indicators = share_indicators.drop(columns=['undivided_pro_fit_ps_latest', 'surplus_reserve_fund_ps_latest'], axis=1)
share_indicators = share_indicators[['symbol', 'retained_earnings_ps_latest']]
# share_indicators = share_indicators.drop(columns=['UndividedProfitPS', 'SurplusReservePS'], axis=1)
share_indicators = share_indicators[['symbol', 'RetainedEarningsPS']]
factor_share_indicators = pd.merge(factor_share_indicators, share_indicators, on='symbol')
return factor_share_indicators
......@@ -369,13 +365,13 @@ class PerShareIndicators(FactorBase):
columns_lists = ['symbol', 'net_operate_cash_flow_ttm', 'capitalization']
share_indicators = tp_share_indicators.loc[:, columns_lists]
fun = lambda x: (x[0] / x[1] if x[1] and x[1] != 0 else None)
share_indicators['oper_cash_flow_ps_ttm'] = share_indicators[
share_indicators['OptCFPSTTM'] = share_indicators[
['net_operate_cash_flow_ttm', 'capitalization']].apply(
fun,
axis=1)
# share_indicators = share_indicators.drop(columns=['net_operate_cash_flow_ttm'], axis=1)
share_indicators = share_indicators[['symbol', 'oper_cash_flow_ps_ttm']]
share_indicators = share_indicators[['symbol', 'OptCFPSTTM']]
factor_share_indicators = pd.merge(factor_share_indicators, share_indicators, on='symbol')
return factor_share_indicators
......@@ -390,10 +386,10 @@ class PerShareIndicators(FactorBase):
columns_lists = ['symbol', 'n_change_in_cash_ttm', 'capitalization']
share_indicators = tp_share_indicators.loc[:, columns_lists]
fun = lambda x: (x[0] / x[1] if x[1] and x[1] != 0 else None)
share_indicators['cash_flow_ps_ttm'] = share_indicators[['n_change_in_cash_ttm', 'capitalization']].apply(fun, axis=1)
share_indicators['CFPSTTM'] = share_indicators[['n_change_in_cash_ttm', 'capitalization']].apply(fun, axis=1)
# share_indicators = share_indicators.drop(columns=['n_change_in_cash_ttm'], axis=1)
share_indicators = share_indicators[['symbol', 'cash_flow_ps_ttm']]
share_indicators = share_indicators[['symbol', 'CFPSTTM']]
factor_share_indicators = pd.merge(factor_share_indicators, share_indicators, on='symbol')
return factor_share_indicators
......@@ -408,9 +404,9 @@ class PerShareIndicators(FactorBase):
"""
columns_lists = ['symbol', 'enterprise_fcfps']
share_indicators = tp_share_indicators.loc[:, columns_lists]
share_indicators['enterprise_fcfps_latest'] = share_indicators['enterprise_fcfps']
share_indicators['EnterpriseFCFPS'] = share_indicators['enterprise_fcfps']
# share_indicators = share_indicators.drop(columns=['enterprise_fcfps'], axis=1)
share_indicators = share_indicators[['symbol', 'enterprise_fcfps_latest']]
share_indicators = share_indicators[['symbol', 'EnterpriseFCFPS']]
factor_share_indicators = pd.merge(factor_share_indicators, share_indicators, on='symbol')
return factor_share_indicators
......@@ -424,17 +420,17 @@ class PerShareIndicators(FactorBase):
"""
columns_lists = ['symbol', 'shareholder_fcfps']
share_indicators = tp_share_indicators.loc[:, columns_lists]
share_indicators['shareholder_fcfps_latest'] = share_indicators['shareholder_fcfps']
share_indicators['ShareholderFCFPS'] = share_indicators['shareholder_fcfps']
# share_indicators = share_indicators.drop(columns=['shareholder_fcfps'], axis=1)
share_indicators = share_indicators[['symbol', 'shareholder_fcfps_latest']]
share_indicators = share_indicators[['symbol', 'ShareholderFCFPS']]
factor_share_indicators = pd.merge(factor_share_indicators, share_indicators, on='symbol')
return factor_share_indicators
def calculate(trade_date, valuation_sets, scale):
def calculate(trade_date, valuation_sets, per_share):
"""
规模
:param scale: 规模类
:param per_share: 规模类
:param valuation_sets: 基础数据
:param trade_date: 交易日
:return:
......@@ -444,24 +440,24 @@ def calculate(trade_date, valuation_sets, scale):
return
# psindu
factor_share_indicators = scale.eps(valuation_sets, valuation_sets)
factor_share_indicators = scale.diluted_eps(valuation_sets, factor_share_indicators)
factor_share_indicators = scale.cash_equivalent_ps(valuation_sets, factor_share_indicators)
factor_share_indicators = scale.dividend_ps(valuation_sets, factor_share_indicators)
factor_share_indicators = scale.eps_ttm(valuation_sets, factor_share_indicators)
factor_share_indicators = scale.net_asset_ps(valuation_sets, factor_share_indicators)
factor_share_indicators = scale.tor_ps(valuation_sets, factor_share_indicators)
factor_share_indicators = scale.tor_ps_latest(factor_share_indicators, factor_share_indicators) # memorydrror
factor_share_indicators = scale.operating_revenue_ps(factor_share_indicators, factor_share_indicators) # memoryerror
factor_share_indicators = scale.operating_revenue_ps_latest(valuation_sets, factor_share_indicators)
factor_share_indicators = scale.operating_profit_ps(valuation_sets, factor_share_indicators)
factor_share_indicators = scale.operating_profit_ps_latest(valuation_sets, factor_share_indicators)
factor_share_indicators = scale.capital_surplus_fund_ps(factor_share_indicators, factor_share_indicators) # memoryerror
factor_share_indicators = scale.surplus_reserve_fund_ps(factor_share_indicators, factor_share_indicators) # memorydrror
factor_share_indicators = scale.undivided_pro_fit_ps(factor_share_indicators, factor_share_indicators) # memorydrror
factor_share_indicators = scale.retained_earnings_ps(factor_share_indicators, factor_share_indicators) # memorydrror
factor_share_indicators = scale.oper_cash_flow_ps(factor_share_indicators, factor_share_indicators) # memorydrror
factor_share_indicators = scale.cash_flow_ps(factor_share_indicators, factor_share_indicators) # memorydrror
factor_share_indicators = per_share.eps(valuation_sets, valuation_sets)
factor_share_indicators = per_share.diluted_eps(valuation_sets, factor_share_indicators)
factor_share_indicators = per_share.cash_equivalent_ps(valuation_sets, factor_share_indicators)
factor_share_indicators = per_share.dividend_ps(valuation_sets, factor_share_indicators)
factor_share_indicators = per_share.eps_ttm(valuation_sets, factor_share_indicators)
factor_share_indicators = per_share.net_asset_ps(valuation_sets, factor_share_indicators)
factor_share_indicators = per_share.tor_ps(valuation_sets, factor_share_indicators)
factor_share_indicators = per_share.tor_ps_latest(factor_share_indicators, factor_share_indicators) # memorydrror
factor_share_indicators = per_share.operating_revenue_ps(factor_share_indicators, factor_share_indicators) # memoryerror
factor_share_indicators = per_share.operating_revenue_ps_latest(valuation_sets, factor_share_indicators)
factor_share_indicators = per_share.operating_profit_ps(valuation_sets, factor_share_indicators)
factor_share_indicators = per_share.operating_profit_ps_latest(valuation_sets, factor_share_indicators)
factor_share_indicators = per_share.capital_surplus_fund_ps(factor_share_indicators, factor_share_indicators) # memoryerror
factor_share_indicators = per_share.surplus_reserve_fund_ps(factor_share_indicators, factor_share_indicators) # memorydrror
factor_share_indicators = per_share.undivided_pro_fit_ps(factor_share_indicators, factor_share_indicators) # memorydrror
factor_share_indicators = per_share.retained_earnings_ps(factor_share_indicators, factor_share_indicators) # memorydrror
factor_share_indicators = per_share.oper_cash_flow_ps(factor_share_indicators, factor_share_indicators) # memorydrror
factor_share_indicators = per_share.cash_flow_ps(factor_share_indicators, factor_share_indicators) # memorydrror
# factor_historical_value = factor_historical_value.drop(columns=['pb', 'pe', 'ps', 'pcf', 'market_cap',
# 'circulating_market_cap', 'isymbol',
......@@ -472,50 +468,50 @@ def calculate(trade_date, valuation_sets, scale):
# 'goods_sale_and_service_render_cash'])
# factor_share_indicators = factor_share_indicators[['symbol',
# 'eps_latest',
# 'diluted_eps_ttm',
# 'cash_equivalent_ps_latest',
# 'dividend_ps_latest',
# 'eps_ttm',
# 'net_asset_ps_latest',
# 'tor_ps_latest',
# 'tor_ps_ttm',
# 'operating_revenue_ps_ttm',
# 'operating_revenue_ps_latest',
# 'operating_profit_ps_ttm',
# 'operating_profit_ps_latest',
# 'capital_surplus_fund_ps_latest',
# 'surplus_reserve_fund_ps_latest',
# 'undivided_pro_fit_ps_latest',
# 'retained_earnings_ps_latest',
# 'oper_cash_flow_ps_ttm',
# 'cash_flow_ps_ttm',
# 'enterprise_fcfps_latest',
# 'shareholder_fcfps_latest']]
# 'EPS',
# 'DilutedEPSTTM',
# 'CashEquPS',
# 'DivPS',
# 'EPSTTM',
# 'NetAssetPS',
# 'TotalRevPS',
# 'TotalRevPSTTM',
# 'OptRevPSTTM',
# 'OptRevPS',
# 'OptProfitPSTTM',
# 'OptProfitPS',
# 'CapticalSurplusPS',
# 'SurplusReservePS',
# 'UndividedProfitPS',
# 'RetainedEarningsPS',
# 'OptCFPSTTM',
# 'CFPSTTM',
# 'EnterpriseFCFPS',
# 'ShareholderFCFPS']]
factor_share_indicators = factor_share_indicators[['symbol',
'eps_latest',
'diluted_eps_ttm',
'cash_equivalent_ps_latest',
'dividend_ps_latest',
'eps_ttm',
'net_asset_ps_latest',
'tor_ps_latest',
'tor_ps_ttm',
'operating_revenue_ps_ttm',
'operating_revenue_ps_latest',
'operating_profit_ps_ttm',
'operating_profit_ps_latest',
'capital_surplus_fund_ps_latest',
'surplus_reserve_fund_ps_latest',
'undivided_pro_fit_ps_latest',
'retained_earnings_ps_latest',
'oper_cash_flow_ps_ttm',
'cash_flow_ps_ttm']]
'EPS',
'DilutedEPSTTM',
'CashEquPS',
'DivPS',
'EPSTTM',
'NetAssetPS',
'TotalRevPS',
'TotalRevPSTTM',
'OptRevPSTTM',
'OptRevPS',
'OptProfitPSTTM',
'OptProfitPS',
'CapticalSurplusPS',
'SurplusReservePS',
'UndividedProfitPS',
'RetainedEarningsPS',
'OptCFPSTTM',
'CFPSTTM']]
factor_share_indicators['id'] = factor_share_indicators['symbol'] + str(trade_date)
factor_share_indicators['trade_date'] = str(trade_date)
scale._storage_data(factor_share_indicators, trade_date)
per_share._storage_data(factor_share_indicators, trade_date)
def do_update(self, start_date, end_date, count):
......@@ -529,11 +525,11 @@ def do_update(self, start_date, end_date, count):
# @app.task()
def factor_calculate(**kwargs):
print("scale_kwargs: {}".format(kwargs))
print("per_share_kwargs: {}".format(kwargs))
date_index = kwargs['date_index']
session = kwargs['session']
scale = PerShareIndicators('factor_scale') # 注意, 这里的name要与client中新建table时的name一致, 不然回报错
per_share = PerShareIndicators('factor_per_share') # 注意, 这里的name要与client中新建table时的name一致, 不然回报错
content = cache_data.get_cache(session, date_index)
total_growth_data = json_normalize(json.loads(str(content, encoding='utf8')))
print("len_total_growth_data {}".format(len(total_growth_data)))
calculate(date_index, total_growth_data, scale)
print("len_total_per_share_data {}".format(len(total_growth_data)))
calculate(date_index, total_growth_data, per_share)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment