Skip to content

Commit

Permalink
Merge branch 'v0.4.2rc'
Browse files Browse the repository at this point in the history
  • Loading branch information
toomore committed Jan 10, 2014
2 parents 237a7ad + 3ddfcf2 commit b44f06c
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 12 deletions.
29 changes: 18 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ grs 台灣上市股票價格擷取
-----------------------------

:Authors: Toomore Chiang
:Version: 0.4.1 of 2014/01/02
:Version: 0.4.2 of 2014/01/11
:Python Version: Python 2.7, PyPy

-----------------------------
Expand Down Expand Up @@ -56,7 +56,7 @@ Quick Start

from grs import Stock

stock = Stock(2618) # 擷取長榮航股價
stock = Stock('2618') # 擷取長榮航股價
print stock.moving_average(5) # 計算五日均價與持續天數
print stock.moving_average_value(5) # 計算五日均量與持續天數
print stock.moving_average_bias_ratio(5,10) # 計算五日、十日乖離值與持續天數
Expand All @@ -66,7 +66,7 @@ Quick Start

::

stock = Stock(2618, 12)
stock = Stock('2618', 12)


輸出 CSV 檔
Expand All @@ -89,8 +89,8 @@ Quick Start
from grs import TWTime

what_time = TWTime()
what_time.now() # 顯示台灣此刻時間
what_time.localtime() # 顯示當地此刻時間
what_time.now() # 顯示台灣此刻時間
what_time.localtime() # 顯示當地此刻時間


判斷台灣股市是否開市:TWSEOpen
Expand All @@ -115,9 +115,9 @@ Quick Start

from grs import RealtimeStock

realtime_stock = RealtimeStock(2618) # 擷取長榮航即時股價
realtime_stock.raw # 原始資料
realtime_stock.real # 回傳 type: dict(如下表)
realtime_stock = RealtimeStock('2618') # 擷取長榮航即時股價
realtime_stock.raw # 原始資料
realtime_stock.real # 回傳 type: dict(如下表)


:name: 股票名稱 Unicode
Expand Down Expand Up @@ -209,7 +209,7 @@ Quick Start

from grs import Stock

stock = Stock(2618)
stock = Stock('2618')
data = stock.moving_average_bias_ratio(3,6)[0] # 取得 3-6 乖離值 type: list

# 計算五個區間負乖離轉折點
Expand All @@ -228,7 +228,7 @@ Quick Start
from grs import BestFourPoint
from grs import Stock

stock = Stock(2618)
stock = Stock('2618')
result = BestFourPoint(stock)
result.best_four_point_to_buy() # 判斷是否為四大買點
result.best_four_point_to_sell() # 判斷是否為四大賣點
Expand Down Expand Up @@ -264,7 +264,7 @@ Quick Start

from grs import Stock

stock = Stock(2618) # 預設為抓取3個月份資料
stock = Stock('2618') # 預設為抓取3個月份資料
stock.moving_average(60)
IndexError: list index out of range # 資料不足
len(stock.raw) # 回傳 51 個值
Expand All @@ -277,6 +277,13 @@ Quick Start
Change Logs
-----------------------------


0.4.2 2014/01/11
====================================

- 修正:Stock ``stock_no``, RealtimeStock ``no`` 必須為 *string*.
`Issues #9 <https://github.com/toomore/grs/issues/9>`_

0.4.1 2014/01/02
====================================

Expand Down
2 changes: 1 addition & 1 deletion grs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# THE SOFTWARE.

__title__ = 'grs'
__version__ = '0.4.1'
__version__ = '0.4.2'
__author__ = 'Toomore Chiang'
__license__ = 'MIT'
__copyright__ = 'Copyright (C) 2012, 2013, 2014 Toomore Chiang'
Expand Down
1 change: 1 addition & 0 deletions grs/fetch_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(self, stock_no, mons=3):
:stock_no : 股價代碼
:mons : 擷取近 n 個月的資料
"""
assert isinstance(stock_no, str), '`stock_no` must be a string'
self.__get_mons = 0
self.__get_no = 0
self.__info = ()
Expand Down
1 change: 1 addition & 0 deletions grs/realtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class RealtimeStock(object):
crosspic: K線圖 by Google Chart
"""
def __init__(self, no):
assert isinstance(no, str), '`no` must be a string'
self.__raw = ''
page = urllib2.urlopen(
'http://mis.tse.com.tw/data/{0}.csv?r={1}'.format(
Expand Down
15 changes: 15 additions & 0 deletions test_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,26 @@ def test_realtime():
assert real_time.real['no'] == '2618'
real_time = grs.RealtimeWeight()
assert real_time.real['no'] == '1'
real_time = grs.RealtimeStock('0050')
assert real_time.real['no'] == '0050'
try:
real_time = grs.RealtimeStock(0050)
except AssertionError:
pass

@staticmethod
def test_countdown():
result = grs.Countdown().countdown
assert isinstance(result, int)

@staticmethod
def test_taiwan_50():
stock = grs.Stock('0050')
assert u'台灣50' == stock.info[1]
try:
stock = grs.Stock(0050)
except AssertionError:
pass

if __name__ == '__main__':
unittest.main()

0 comments on commit b44f06c

Please sign in to comment.