本文整理汇总了Python中Base.Base.lists_add方法的典型用法代码示例。如果您正苦于以下问题:Python Base.lists_add方法的具体用法?Python Base.lists_add怎么用?Python Base.lists_add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Base.Base
的用法示例。
在下文中一共展示了Base.lists_add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: StockDataProc
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import lists_add [as 别名]
#.........这里部分代码省略.........
#输入股票代码返回其通联二级行业分类df
def get_tl_industry(self,tickers='',field=['ticker','industryName2']):
res_row_sel={'code':tickers}
data=self.wp.itfEquInd_proc(field=field,res_row_sel=res_row_sel)
data_dict=self.base.pdgrp_to_dic(data['industryName2'].groupby(data['ticker']))
data_df=pd.DataFrame({'code':data_dict.keys(),'industryName2':data_dict.values()})
return data_df
#获取某个股指的交易日线
#所有trade类必须有date项
def get_index_trade_day(self,code,start,end='',field=['date','volume'],pct=True,
pct_fields=[]):
data=self.wp.itfHDatInd_proc(code,start,end,field)
data_rev=data.iloc[::-1]
data_rev.set_index(datenam,inplace=True)
if pct:
if not pct_fields:
pct_fields=data_rev.columns
data_rev.loc[:,pct_fields]=data_rev[pct_fields].pct_change(1)*100
return data_rev
def get_tradedate_indexs(self,code,date,field=['p_change']):
return self.wp.itfHisDatD_proc(code,date,date,field)
#获取沪深融资融券汇总交易数据
#所有trade类必须有opDate项
def get_rzrq_trade_day(self,start,end='',field=['opDate','rzye','rzmre','rqyl','rqmcl'],
pct=True,pct_fields=[]):
datenam='opDate'
if field:
field=self.base.lists_add(field,datenam)
data=self.wp.itfShMar_proc(start,end,field)
data_rev=data.iloc[::-1]
data_rev.set_index(datenam,inplace=True)
if pct:
if not pct_fields:
pct_fields=data_rev.columns
data_rev.loc[:,pct_fields]=data_rev[pct_fields].pct_change(1)*100
return data_rev
#获取雅虎交易数据
def get_YH_trade_day(self,ticker,start='',end='',field=['Date','Close','Volume'],
pct=True,pct_fields=[]):
datenam='Date'
if field:
field=self.base.lists_add(field,datenam)
print field
data=self.wp.itfYHtradat_proc(ticker,start,end,field)
data_rev=data.iloc[::-1]
data_rev.set_index(datenam,inplace=True)
data_rev=data_rev.convert_objects(convert_numeric=True)
if pct:
if not pct_fields:
pct_fields=data_rev.columns
data_rev.loc[:,pct_fields]=data_rev[pct_fields].pct_change(1)*100
return data_rev
示例2: StockDataProc
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import lists_add [as 别名]
#.........这里部分代码省略.........
#输入股票代码返回其通联二级行业分类df
def get_tl_industry(self,tickers='',field=['ticker','industryName2']):
res_row_sel={'code':tickers}
data=self.wp.itfEquInd_proc(field=field,res_row_sel=res_row_sel)
data_dict=self.base.pdgrp_to_dic(data['industryName2'].groupby(data['ticker']))
data_df=pd.DataFrame({'code':data_dict.keys(),'industryName2':data_dict.values()})
return data_df
#获取某个股指的交易日线
#所有trade类必须有date项
def get_index_trade_day(self,code,start,end='',field=['date','volume'],pct=True,
pct_fields=[]):
data=self.wp.itfHDatInd_proc(code,start,end,field)
data_rev=data.iloc[::-1]
data_rev.set_index(datenam,inplace=True)
if pct:
if not pct_fields:
pct_fields=data_rev.columns
data_rev.loc[:,pct_fields]=data_rev[pct_fields].pct_change(1)*100
return data_rev
def get_tradedate_indexs(self,code,date,field=['p_change']):
return self.wp.itfHisDatD_proc(code,date,date,field)
#获取沪深融资融券汇总交易数据
#所有trade类必须有opDate项
def get_rzrq_trade_day(self,start,end='',field=['opDate','rzye','rzmre','rqyl','rqmcl'],
pct=True,pct_fields=[]):
datenam='opDate'
if field:
field=self.base.lists_add(field,datenam)
data=self.wp.itfShMar_proc(start,end,field)
data_rev=data.iloc[::-1]
data_rev.set_index(datenam,inplace=True)
if pct:
if not pct_fields:
pct_fields=data_rev.columns
data_rev.loc[:,pct_fields]=data_rev[pct_fields].pct_change(1)*100
return data_rev
#获取雅虎交易数据
def get_YH_trade_day(self,ticker,start='',end='',field=['Date','Close','Volume'],
pct=True,pct_fields=[]):
datenam='Date'
if field:
field=self.base.lists_add(field,datenam)
print field
data=self.wp.itfYHtradat_proc(ticker,start,end,field)
data_rev=data.iloc[::-1]
data_rev.set_index(datenam,inplace=True)
data_rev=data_rev.convert_objects(convert_numeric=True)
if pct:
if not pct_fields:
pct_fields=data_rev.columns
data_rev.loc[:,pct_fields]=data_rev[pct_fields].pct_change(1)*100
return data_rev