2行代码获取股票历史交易数据

#-------------------------------------------------------------------------------
# Name:        module1
# Purpose:
#
# Author:      bruce.lin.chn
#
# Created:     23/09/2011
# Copyright:   (c) bruce.lin.chn 2011
# Licence:     <your licence>
#-------------------------------------------------------------------------------
#!/usr/bin/env python

import ystockquote

print ystockquote.get_historical_prices('002500.sz', "20110919","20110923")


运行结果:
*** Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32. ***
>>>
21.20
{'stock_exchange': '"Shenzhen"', 'market_cap': 'N/A', '200day_moving_avg': '31.6461', '52_week_high': '42.30', 'price_earnings_growth_ratio': 'N/A', 'price_sales_ratio': 'N/A', 'price': '21.20', 'earnings_per_share': '0.00', '50day_moving_avg': '26.1162', 'avg_daily_volume': '1022660', 'volume': '1067959', '52_week_low': '20.57', 'short_ratio': 'N/A', 'price_earnings_ratio': 'N/A', 'dividend_yield': '0.93', 'dividend_per_share': '0.20', 'price_book_ratio': 'N/A', 'ebitda': '0', 'change': '-0.41', 'book_value': '0.00'}
>>>
[['Date', 'Open', 'High', 'Low', 'Close', 'Volume', 'Adj Clos'], ['2011-09-22', '22.05', '22.77', '21.60', '21.61', '836000', '21.6'], ['2011-09-21', '21.47', '22.17', '21.17', '22.11', '1505400', '22.1'], ['2011-09-20', '21.33', '22.09', '21.22', '21.70', '1206900', '21.7'], ['2011-09-19', '21.62', '21.90', '21.43', '21.52', '508600', '21.5']]
>>>

详细用法参考:

print ystockquote.get_price('002250.sz')
print ystockquote.get_all('002250.sz')

http://www.goldb.org/ystockquote.html
https://github.com/diehl/Stock-Price-Time-Series-Analysis

感谢 Corey Goldberg! 002500.sz今天涨了 ^_^

你可能感兴趣的:(代码)