Skip to content

Commit f0d46f0

Browse files
authored
Update Ashare.py
修正提示错误
1 parent 360a13a commit f0d46f0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Ashare.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@ def get_price_sina(code, end_date='', count=10, frequency='60m'): #新浪全
3838
#print(code,end_date,count)
3939
URL=f'http://money.finance.sina.com.cn/quotes_service/api/json_v2.php/CN_MarketData.getKLineData?symbol={code}&scale={ts}&ma=5&datalen={count}'
4040
dstr= json.loads(requests.get(URL).content);
41-
df=pd.DataFrame(dstr,columns=['day','open','high','low','close','volume'],dtype='float')
42-
df.day=pd.to_datetime(df.day); df.set_index(['day'], inplace=True); df.index.name='' #处理索引
41+
#df=pd.DataFrame(dstr,columns=['day','open','high','low','close','volume'],dtype='float')
42+
df= pd.DataFrame(dstr,columns=['day','open','high','low','close','volume'])
43+
df['open'] = df['open'].astype(float); df['high'] = df['high'].astype(float); #转换数据类型
44+
df['low'] = df['low'].astype(float); df['close'] = df['close'].astype(float); df['volume'] = df['volume'].astype(float)
45+
df.day=pd.to_datetime(df.day); df.set_index(['day'], inplace=True); df.index.name='' #处理索引
4346
if (end_date!='') & (frequency in ['240m','1200m','7200m']): return df[df.index<=end_date][-mcount:] #日线带结束时间先返回
4447
return df
4548

0 commit comments

Comments
 (0)