请 [注册] 或 [登录]  | 返回主站

量化交易吧 /  量化平台 帖子:3364737 新帖:1

20170509更正:多日换手率的累加和(菜鸟练手)

我是游客发表于:7 月 14 日 14:14回复(1)
import jqdata
import pandas as pd
stock_list = ['000001.XSHE', '000002.XSHE']
q = query(valuation.code, valuation.turnover_ratio).filter(
            valuation.code.in_(stock_list)
        )
#只需要更改count 就可以随心所欲的求取 多日累加换手率了!
trade_days = jqdata.get_trade_days(count = 21)


lt=[0]*len(stock_list)

turnover_ratio_20_df = pd.DataFrame(lt, index=stock_list, columns = ['turnover_ratio_20'])
for trade in trade_days[:-1]:
    print(trade)
    df= get_fundamentals(q, trade)
    new_df = pd.DataFrame(list(df['turnover_ratio']), index=stock_list, columns = ['turnover_ratio'])
    turnover_ratio_20_df['turnover_ratio_20'] += new_df['turnover_ratio']
print(turnover_ratio_20_df)
2017-04-10
2017-04-11
2017-04-12
2017-04-13
2017-04-14
2017-04-17
2017-04-18
2017-04-19
2017-04-20
2017-04-21
2017-04-24
2017-04-25
2017-04-26
2017-04-27
2017-04-28
2017-05-02
2017-05-03
2017-05-04
2017-05-05
2017-05-08
             turnover_ratio_20
000001.XSHE               5.35
000002.XSHE               5.34
 

全部回复

0/140

量化课程

    移动端课程