def test_bond(): df = bond.run_query(query(bond.BOND_BASIC_INFO).limit(10)) print(df) assert len(df) == 10 df = df.set_index("code").drop("id", axis=1) item = df.loc["131801"] assert item.short_name == u"花呗01A1" and str( item.maturity_date) == "2017-06-15" item = df.loc["131811"] assert item.short_name == "R-002" and item.maturity_date is None
pe = pd.read_csv('/Users/caichaohong/Desktop/Zenki/financials/pe_ratio.csv', index_col='Unnamed: 0', date_parser=dateparse) # 2924个 net_profit = pd.read_csv( '/Users/caichaohong/Desktop/Zenki/financials/net_profit_yearly.csv', index_col='statDate') # 2924个 market_cap = market_cap[close.columns] pe = pe[close.columns] #股息率 df_bank = finance.run_query( query(finance.SW1_DAILY_VALUATION).filter( finance.SW1_DAILY_VALUATION.code == '801780')) # 回购 df_bond = bond.run_query( query(bond.REPO_DAILY_PRICE).filter( bond.REPO_DAILY_PRICE.name == 'GC182').limit(2000)) df_t1 = pd.merge(df_bond, df_bank, on='date') df_t1 = df_t1[['date', 'close', 'dividend_ratio']] df_t1.index = pd.to_datetime(df_t1['date']) # 当风险偏好<0不持股 df_t1['licha'] = (df_t1['close'].rolling(60).mean() - df_t1['dividend_ratio'].rolling(60).mean()).diff(1) df_t1['licha'] = df_t1['licha'].fillna(method='ffill') df_t1['hs300'] = hs300['net_value'] # 回购和价格行情日期不同 df_repo = pd.DataFrame(columns=['licha'], index=close.index) datelist = list(set(df_t1.index).intersection(set(df_repo.index))) df_repo['licha'].loc[datelist] = df_t1['licha'].loc[datelist] df_repo = df_repo.fillna(method='ffill')
# encoding=utf-8 """ 本脚本对可转债数据进行研究 """ from DataSource.auth_info import jq_login from jqdatasdk import bond, query if __name__ == '__main__': jq_login() df = bond.run_query( query(bond.CONBOND_BASIC_INFO).filter( bond.CONBOND_BASIC_INFO.bond_form_id == '703011')) end = 0