【发布时间】:2014-10-31 00:46:22
【问题描述】:
所以我一直非常成功地使用 ystockquote,但是我遇到了一个小问题。
当我提取任何股票的历史数据时,它会生成一个包含正确信息的字典,但是字典日期的顺序是错误的吗?
这是我的代码:
import ystockquote
import matplotlib.pyplot as plt
ticker = "YHOO"
stock_exchange = ystockquote.get_stock_exchange(ticker)
change = ystockquote.get_change(ticker)
price = ystockquote.get_price(ticker)
market_cap = ystockquote.get_market_cap(ticker)
_52_week_high = ystockquote.get_52_week_high(ticker)
_52_week_low = ystockquote.get_52_week_low(ticker)
avg_volume = ystockquote.get_avg_daily_volume(ticker)
volume = ystockquote.get_volume(ticker)
print (ticker + " (" + change + ") ")
print (stock_exchange.strip('"'))
print ("Share Price: " + price)
print ("Market Cap: " + market_cap)
print ("52 Week High/Low: " + _52_week_high + "/" + _52_week_low)
print ("Trading Volume: " + volume)
print ("Average Trading Volume(3m): " + avg_volume)
historic_prices = ystockquote.get_historical_prices(ticker, '2014-10-01', '2014-10-15')
for x in historic_prices:
print(x)
这就是它产生的结果
YHOO (+0.20)
NasdaqNM
Share Price: 45.63
Market Cap: 44.672B
52 Week High/Low: 46.15/32.06
Trading Volume: 16209593
Average Trading Volume(3m): 34564400
2014-10-01
2014-10-14
2014-10-02
2014-10-13
2014-10-10
2014-10-09
2014-10-08
2014-10-15
2014-10-03
2014-10-07
2014-10-06
您可以看到历史价格字典中的日期顺序不正确?我知道差距是为了说明周末,但检索到的日期顺序错误?我究竟做错了什么?我在互联网上看到很多其他人以同样的方式使用它,并且日期的顺序正确!
我正在使用 Python 3.4!
感谢您的帮助!
【问题讨论】: