MCPcopy Index your code
hub / github.com/mpquant/Ashare / get_price

Function get_price

Ashare.py:49–60  ·  view source on GitHub ↗
(code, end_date='',count=10, frequency='1d', fields=[])

Source from the content-addressed store, hash-verified

47 return df
48
49def get_price(code, end_date='',count=10, frequency='1d', fields=[]): #对外暴露只有唯一函数,这样对用户才是最友好的
50 xcode= code.replace('.XSHG','').replace('.XSHE','') #证券代码编码兼容处理
51 xcode='sh'+xcode if ('XSHG' in code) else 'sz'+xcode if ('XSHE' in code) else code
52
53 if frequency in ['1d','1w','1M']: #1d日线 1w周线 1M月线
54 try: return get_price_sina( xcode, end_date=end_date,count=count,frequency=frequency) #主力
55 except: return get_price_day_tx(xcode,end_date=end_date,count=count,frequency=frequency) #备用
56
57 if frequency in ['1m','5m','15m','30m','60m']: #分钟线 ,1m只有腾讯接口 5分钟5m 60分钟60m
58 if frequency in '1m': return get_price_min_tx(xcode,end_date=end_date,count=count,frequency=frequency)
59 try: return get_price_sina( xcode,end_date=end_date,count=count,frequency=frequency) #主力
60 except: return get_price_min_tx(xcode,end_date=end_date,count=count,frequency=frequency) #备用
61
62if __name__ == '__main__':
63 df=get_price('sh000001',frequency='1d',count=10) #支持'1d'日, '1w'周, '1M'月

Callers 3

Demo2.pyFile · 0.85
Demo1.pyFile · 0.85
Ashare.pyFile · 0.85

Calls 3

get_price_sinaFunction · 0.85
get_price_day_txFunction · 0.85
get_price_min_txFunction · 0.85

Tested by

no test coverage detected