Skip to content

Commit

Permalink
Merge branch 'v0.4.1rc'
Browse files Browse the repository at this point in the history
  • Loading branch information
toomore committed Jan 1, 2014
2 parents 030ce87 + c904146 commit 55600f6
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 129 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
*.pyc
*.pylint
build/
dist/
grs.egg-info/
5 changes: 0 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
language: python
python:
- 2.6
- 2.7
- pypy
install: python setup.py install
script:
- python grsTestAll.py
- python testopen.py
- python testtwseno.py
- python test_realtime.py
- python test_unittest.py
11 changes: 9 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ grs 台灣上市股票價格擷取
-----------------------------

:Authors: Toomore Chiang
:Version: 0.4.0 of 2013/12/30
:Python Version: Python 2.6-2.7, PyPy
:Version: 0.4.1 of 2014/01/02
:Python Version: Python 2.7, PyPy

-----------------------------
Requires
Expand Down Expand Up @@ -277,6 +277,13 @@ Quick Start
Change Logs
-----------------------------

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

- 修正:Countdown().countdown 秒數問題
- 新增:twse_no, twse_open, twse_realtime, countdown into unittest
- 移除:Support Python 2.6

0.4.0 2013/12/30
====================================

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.0'
__version__ = '0.4.1'
__author__ = 'Toomore Chiang'
__license__ = 'MIT'
__copyright__ = 'Copyright (C) 2012, 2013, 2014 Toomore Chiang'
Expand Down
6 changes: 5 additions & 1 deletion grs/tw_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,14 @@ class Countdown(object):
'''
def __init__(self, hour=14, minutes=30):
self.__back = timedelta(hours=hour - 8, minutes=minutes)
self.__zero = datetime.utcnow() - self.__back
self.__hour = hour
self.__minutes = minutes

@property
def __zero(self):
''' 取得現在時間(秒) '''
return datetime.utcnow() - self.__back

@property
def nextday(self):
''' nextday: 下一個日期 '''
Expand Down
6 changes: 0 additions & 6 deletions grsTestAll.py

This file was deleted.

1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
'License :: OSI Approved :: MIT License',
'Natural Language :: Chinese (Traditional)',
'Programming Language :: Python',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Topic :: Office/Business :: Financial :: Investment',
],
Expand Down
32 changes: 0 additions & 32 deletions test2.py

This file was deleted.

15 changes: 0 additions & 15 deletions testB4P.py

This file was deleted.

17 changes: 0 additions & 17 deletions test_prof.py

This file was deleted.

19 changes: 0 additions & 19 deletions test_realtime.py

This file was deleted.

38 changes: 37 additions & 1 deletion test_unittest.py
Original file line number Diff line number Diff line change
@@ -1,48 +1,84 @@
# -*- coding: utf-8 -*-
''' Unittest '''
from datetime import datetime
from types import BooleanType
from types import NoneType
import grs
import unittest


class TestGrs(unittest.TestCase):
def setUp(self):
def get_data(self):
self.stock_no = '2618'
self.data = grs.Stock(self.stock_no)

def test_stock(self):
self.get_data()
assert self.data.info[0] == self.stock_no

def test_best_buy_or_sell(self):
self.get_data()
assert isinstance(grs.BestFourPoint(self.data).best_four_point(),
(tuple, NoneType))

def test_moving_average(self):
self.get_data()
result = self.data.moving_average(3)
assert isinstance(result[0], list)
assert isinstance(result[1], int)

def test_moving_average_value(self):
self.get_data()
result = self.data.moving_average_value(3)
assert isinstance(result[0], list)
assert isinstance(result[1], int)

def test_moving_average_bias_ratio(self):
self.get_data()
result = self.data.moving_average_bias_ratio(6, 3)
assert isinstance(result[0], list)
assert isinstance(result[1], int)

def test_check_moving_average_bias_ratio(self):
self.get_data()
result = self.data.check_moving_average_bias_ratio(
self.data.moving_average_bias_ratio(3, 6)[0],
positive_or_negative=True)[0]
assert isinstance(result, BooleanType)

def test_stock_value(self):
self.get_data()
assert isinstance(self.data.price, list)
assert isinstance(self.data.openprice, list)
assert isinstance(self.data.value, list)

@staticmethod
def test_twse_no():
twse_no = grs.TWSENo()
assert isinstance(twse_no.all_stock, dict)
result = twse_no.search(u'中')
# 1701 中化
assert 1701 in result
result = twse_no.searchbyno(17)
assert 1701 in result

@staticmethod
def test_twse_open():
is_open = grs.TWSEOpen()
result = is_open.d_day(datetime(2014, 1, 1))
assert result is False

@staticmethod
def test_realtime():
real_time = grs.RealtimeStock('2618')
assert real_time.real['no'] == '2618'
real_time = grs.RealtimeWeight()
assert real_time.real['no'] == '1'

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

if __name__ == '__main__':
unittest.main()
9 changes: 0 additions & 9 deletions testopen.py

This file was deleted.

20 changes: 0 additions & 20 deletions testtwseno.py

This file was deleted.

0 comments on commit 55600f6

Please sign in to comment.