本文整理汇总了Python中Base.Base.today_as_str方法的典型用法代码示例。如果您正苦于以下问题:Python Base.today_as_str方法的具体用法?Python Base.today_as_str怎么用?Python Base.today_as_str使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Base.Base
的用法示例。
在下文中一共展示了Base.today_as_str方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: StockInterfaceYH
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import today_as_str [as 别名]
class StockInterfaceYH(object):
def __init__(self):
self.ba=Base()
#某一个股票的一段时间的日线
#返回内容:vAdj_Close Close Date High Low Open Symbol Volum
def get_tradedata(self,ticker,start,end=''):
if len(end)==0:
end=self.ba.today_as_str()
ticker_obj = Share(ticker)
tradedata=ticker_obj.get_historical(start, end)
return pd.DataFrame(tradedata)
示例2: StockInterfaceWrap
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import today_as_str [as 别名]
#.........这里部分代码省略.........
# high : 最高价
# close : 收盘价
# low : 最低价
# volume : 成交量
# amount : 成交金额
#返回
#dataframe
def itfHDat_proc(self,code,start='',end='',field=[],
res_row_sel={},row_between_ops=[]):
api_itf=self.api.getHDat
api_itf_paras={'code':code,'start':start,'end':end}
res=self._itfdata_proc_trade(api_itf,api_itf_paras,field,res_row_sel,
row_between_ops)
return res
#指数复权日线数据
#返回
#dataframe
def itfHDatInd_proc(self,code,start='',end='',field=[],
res_row_sel={},row_between_ops=[],setindex='date'):
api_itf=self.api.getHDat
api_itf_paras={'code':code,'start':start,'end':end,'index':True}
res=self._itfdata_proc_trade(api_itf,api_itf_paras,field,res_row_sel,
row_between_ops)
return res
#股市交易数据不复权
def itfHisDatD_proc(self,code,start='',end='',field=[],
res_row_sel={},row_between_ops=[]):
if len(end)==0:
end=self.ba.today_as_str()
api_itf=self.api.getHisDat
api_itf_paras={'code':code,'start':start,'end':end,'ktype':'D'}
res=self._itfdata_proc_trade(api_itf,api_itf_paras,field,res_row_sel,
row_between_ops)
return res
#股市日分钟交易数据
def itfHisDat_proc(self,code,start='',end='',ktype='5',field=[],
res_row_sel={},row_between_ops=[]):
api_itf=self.api.getHisDat
api_itf_paras={'code':code,'start':start,'end':end,'ktype':ktype}
res=self._itfdata_proc(api_itf,api_itf_paras,field,res_row_sel,
row_between_ops)
return res
#股市日成交逐笔
def itfTikDat_proc(self,code,date='',field=[],
res_row_sel={},row_between_ops=[]):
api_itf=self.api.getTikDat
api_itf_paras={'code':code,'date':date}
res=self._itfdata_proc(api_itf,api_itf_paras,field,res_row_sel,
row_between_ops)
return res
#深市融资融券统计信息
def itfSzMar_proc(self,start,end='',field=[],
res_row_sel={},row_between_ops=[]):
api_itf=self.api.getSzMar
api_itf_paras={'start':start,'end':end}
res=self._itfdata_proc(api_itf,api_itf_paras,field,res_row_sel,
row_between_ops)
示例3: StockDataProc
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import today_as_str [as 别名]
#.........这里部分代码省略.........
# itfparas=[{'code':'000001','start':date,'end':date,'field': trade_field[0]},
# {'code':'000001','start':date,'end':date,'field': trade_field[1]}]
#
# mergeby='date'
#res=self.getdata_multisource(itfs,itfparas,mergeby)
date='2016-06-01'
tickers=['000001','000002','300133','000718','600547']
iternam='code'
trade_field=[['volume','amount'],['p_change']]
itfs='itfHDat_proc'
itfparas=[{'start':date,'end':date,'field': trade_field[0]},
{'start':date,'end':date,'field': trade_field[1]}]
mergebys='date'
print list(res)
# taskqueue=JoinableQueue()
# taskqueue.put(self.func_warp('itfHDat_proc',{'start':'2016-06-10'}))
#给起始和终止日期,返回期间的行
#colnam是date类型所在的列
def _sel_row_bydate(self,df,start,end=''):
#将输入日期转为datetime
if not end:
end=self.base.today_as_str()
start_dt=self.base.str_to_datetime(start)
end_dt=self.base.str_to_datetime(end)
date_col=pd.to_datetime(df.index)
mask = (date_col>= start_dt) & (date_col <= end_dt)
return df.ix[mask]
def getdata_multisource(self,itfs,itfparas,mergeby,itfiterparas={}):
logger.info('multi start')
if type(itfs)==dict:
itfparas.update(itfiterparas)
return itfs(**itfparas)
if len(itfs)!=len(itfparas):
print '函数列表和其参数列表长度不等!'
sys.exit()
#从所要求的接口抓取数据
data_iter=self.getdata_multithread(task_funcsiter=itfs,
task_funcsiterparas=itfparas,
task_funcsconstparas=itfiterparas)
#统一数据的合并字段
data_list=[data.set_index(mergeby) if not data.index.name==mergeby else data for data in data_iter]
print pd.concat(data_list,axis=1)
return pd.concat(data_list,axis=1)
示例4: StockDataProc
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import today_as_str [as 别名]
class StockDataProc(object):
def __init__(self,token=settings.token):
self.token=settings.token
self.base=Base()
self.wp=StockInterfaceWrap()
self.stat=StockDataStat()
self.db_proc=DatabaseProc()
self.func_dict={
'itfHDat_proc':self.wp.itfHDat_proc,
'itfHisDatD_proc':self.wp.itfHisDatD_proc
}
def deco_iterresult(func):
def _iterresult(self,isiterx,*args,**kargs):
if self.base.is_iter(isiterx):
return [func(self,x) for x in isiterx]
else:
return func(self,isiterx)
return _iterresult
#给起始和终止日期,返回期间的行
#colnam是date类型所在的列
def _sel_row_bydate(self,df,start,end=''):
#将输入日期转为datetime
if not end:
end=self.base.today_as_str()
start_dt=self.base.str_to_datetime(start)
end_dt=self.base.str_to_datetime(end)
date_col=pd.to_datetime(df.index)
mask = (date_col>= start_dt) & (date_col <= end_dt)
return df.ix[mask]
def getdata_multisource(self,itfs,itfparas,mergeby,itfiterparas={}):
logger.info('multi start')
if type(itfs)==dict:
itfparas.update(itfiterparas)
return itfs(**itfparas)
if len(itfs)!=len(itfparas):
print '函数列表和其参数列表长度不等!'
sys.exit()
#从所要求的接口抓取数据
data_iter=self.getdata_multithread(task_funcsiter=itfs,
task_funcsiterparas=itfparas,
task_funcsconstparas=itfiterparas)
#统一数据的合并字段
data_list=[data.set_index(mergeby) if not data.index.name==mergeby else data for data in data_iter]
print pd.concat(data_list,axis=1)
return pd.concat(data_list,axis=1)
def getdata_iter(self,iterkeys,iterkeynam,taskfuncs,
taskfuncs_paras,mergebys=None,handle_iter=0):
def dataiter_concat(dataiter):
return pd.concat(dataiter)
def dataiter_tocsv(dataiter):
pass
handle_itermethod=[dataiter_concat,dataiter_tocsv]
usemethod=handle_itermethod[handle_iter]
#参数处理
if not self.base.is_iter(taskfuncs):
task_funcsconst=taskfuncs
task_funcsiterparas=iter([{iterkeynam:t} for t in iterkeys])
task_funcsconstparas=taskfuncs_paras
else:
task_funcsconst=self.getdata_multisource
task_funcsiterparas=iter([{'itfiterparas':{iterkeynam:t}} for t in iterkeys])
task_funcsconstparas={'itfs':taskfuncs,'itfparas':taskfuncs_paras,
'mergeby':mergebys}
p=MultiProcessTask(funcdict=self.func_dict)
dataiter=p.getdata_multiprocess(task_funcsiterparas=task_funcsiterparas,
task_funcsconst=task_funcsconst,
task_funcsconstparas=task_funcsconstparas)
return usemethod(dataiter)
#获取所有深市股票代码
#返回迭代器
def get_tickersz(self,tickers):
issz=lambda x : self.is_tickersz(x) or self.is_tickercyb(x)
return itertools.ifilter(issz,tickers)
#获取所有深市股票代码(不包含创业板)
#tp---True返回包括停牌股票,False不反悔停牌股票
def get_tickerszmain(self,tickers):
#.........这里部分代码省略.........