diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2bc76e9..dc844a1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,7 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] python-version: - ["3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] + ["3.7", "3.12"] runs-on: ${{ matrix.os }} name: ${{ matrix.os }} - ${{ github.event_name }} steps: @@ -19,8 +19,25 @@ jobs: pipenv install --dev - name: Run tests run: pipenv run coverage run --source=twstock -m unittest + create-reports: + runs-on: ubuntu-latest + needs: build + strategy: + matrix: + os: [ubuntu-latest] + python-version: ["3.12"] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup + run: | + pip install pipenv + pipenv install --dev + - name: Run tests + run: pipenv run coverage run --source=twstock -m unittest - name: Create reports - run: - | - pipenv run coveralls - pipenv run codecov + run: | + pipenv run coveralls + pipenv run codecov + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/LICENSE b/LICENSE index dacee4f..c16ad9c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2017-2019 Louie Lu +Copyright (c) 2017-2024 Louie Lu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 9f0c35e..9a369ee 100644 --- a/README.md +++ b/README.md @@ -109,11 +109,11 @@ ma_p_cont = stock.continuous(ma_p) # 計算五日均價持續天 ma_br = stock.ma_bias_ratio(5, 10) # 計算五日、十日乖離值 ``` -擷取自 2015 年 1 月至今之資料 +擷取自 2024 年 3 月至今之資料 ```python stock = Stock('2330') -stock.fetch_from(2015, 1) +stock.fetch_from(2024, 3) ``` 基本資料之使用 diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index b4cd2cd..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,28 +0,0 @@ -environment: - global: - FLIT_ROOT: C:\projects\flit - matrix: - - PYTHON: 'C:\Python34' - - PYTHON: 'C:\Python35' - - PYTHON: 'C:\Python36' - - PYTHON: 'C:\Python36-x64' - PYTHON_VERSION: '3.6.2' - PYTHON_ARCH: '64' - -branches: - only: - - master - -init: - - echo %PYTHON% %PYTHON_VERSION% %PYTHON_ARCH% - -install: - - 'set PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%' - - 'python -m pip install -U pip' - - 'python -m pip install pipenv' - -build_script: - - 'python -m pipenv install --dev' - -test_script: - - 'python -m pipenv run coverage run --source=twstock -m unittest' diff --git a/docs/conf.py b/docs/conf.py index 1484d4f..77cb16c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -47,7 +47,7 @@ # General information about the project. project = "twstock" -copyright = "2017, Louie Lu" +copyright = "2017-2024, Louie Lu" author = "Louie Lu" # The version info for the project you're documenting, acts as replacement for diff --git a/docs/license.rst b/docs/license.rst index 4107d06..13c2a48 100644 --- a/docs/license.rst +++ b/docs/license.rst @@ -1,7 +1,7 @@ LICENSE --------------------- -Copyright (c) 2017-2019 Louie Lu +Copyright (c) 2017-2024 Louie Lu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/test/test_mock.py b/test/test_mock.py index 9f12ffa..f944ef8 100644 --- a/test/test_mock.py +++ b/test/test_mock.py @@ -9,7 +9,16 @@ def test_mock_get_stock_info_will_work(self): def test_mock_get_stock_info_raw_data(self): self.assertCountEqual( mock.get_stock_info("2330").keys(), - ["msgArray", "userDelay", "rtmessage", "referer", "queryTime", "rtcode"], + [ + "msgArray", + "userDelay", + "rtmessage", + "referer", + "queryTime", + "rtcode", + "exKey", + "cachedAlive", + ], ) def test_mock_get_stock_info_msgarray(self): diff --git a/test/test_realtime.py b/test/test_realtime.py index 1c84254..2f23702 100644 --- a/test/test_realtime.py +++ b/test/test_realtime.py @@ -55,10 +55,10 @@ def test_mock_one_stock_id(self): self.assertTrue(s["success"]) self.assertEqual(s["info"]["code"], "2330") - self.assertEqual(s["realtime"]["latest_trade_price"], "214.50") + self.assertEqual(s["realtime"]["latest_trade_price"], "-") self.assertEqual( s["realtime"]["best_bid_price"], - ["214.00", "213.50", "213.00", "212.50", "212.00"], + ["848.0000", "847.0000", "846.0000", "845.0000", "844.0000"], ) @unittest.skip("Dont want to fix this, is about the code in realtime") diff --git a/twstock/mock/__init__.py b/twstock/mock/__init__.py index 87dbce1..fda0990 100644 --- a/twstock/mock/__init__.py +++ b/twstock/mock/__init__.py @@ -4,57 +4,9 @@ TSE_2330_TW = [ - """ -{"msgArray": [{"ts": "0", "tk0": "2330.tw_tse_20170724_B_9999778918", "tk1": -"2330.tw_tse_20170724_B_9999777950", "tlong": "1500860849000", "f": -"853_1193_972_1209_817_", "ex": "tse", "g": "1221_1530_817_1038_1193_", "d": -"20170724", "it": "12", "b": "214.00_213.50_213.00_212.50_212.00_", "c": -"2330", "mt": "264564", "a": "214.50_215.00_215.50_216.00_216.50_", "n": -"\u53f0\u7a4d\u96fb", "o": "213.50", "l": "213.00", "h": "214.50", "ip": "0", -"i": "24", "w": "193.00", "v": "5094", "u": "235.00", "t": "09:47:29", "s": -"1", "pz": "213.50", "tv": "1", "p": "0", "nf": -"\u53f0\u7063\u7a4d\u9ad4\u96fb\u8def\u88fd\u9020\u80a1\u4efd\u6709\u9650\u516c\u53f8", -"ch": "2330.tw", -"z": "214.50", "y": "214.00", "ps": "1323"}], "userDelay": 5000, "rtmessage": -"OK", "referer": "", "queryTime": {"sysTime": "09:47:30", "sessionLatestTime": --1, "sysDate": "20170724", "sessionKey": "tse_2330.tw_20170724|", -"sessionFromTime": -1, "stockInfoItem": 2065, "showChart": false, -"sessionStr": "UserSession", "stockInfo": 204322}, "rtcode": "0000"} -""", - """ -{"msgArray": [{"ts": "0", "tk0": "2330.tw_tse_20170724_B_9999766224", "tk1": -"2330.tw_tse_20170724_B_9999765954", "tlong": "1500861105000", "f": -"1059_1079_1014_1229_907_", "ex": "tse", "g": "1455_1598_797_1019_1134_", "d": -"20170724", "it": "12", "b": "214.00_213.50_213.00_212.50_212.00_", "c": -"2330", "mt": "778472", "a": "214.50_215.00_215.50_216.00_216.50_", "n": -"\u53f0\u7a4d\u96fb", "o": "213.50", "l": "213.00", "h": "214.50", "ip": "0", -"i": "24", "w": "193.00", "v": "5217", "u": "235.00", "t": "09:51:45", "s": -"0", "pz": "213.50", "tv": "1", "p": "0", "nf": -"\u53f0\u7063\u7a4d\u9ad4\u96fb\u8def\u88fd\u9020\u80a1\u4efd\u6709\u9650\u516c\u53f8", -"ch": "2330.tw", -"z": "214.50", "y": "214.00", "ps": "1323"}], "userDelay": 5000, "rtmessage": -"OK", "referer": "", "queryTime": {"sysTime": "09:51:48", "sessionLatestTime": --1, "sysDate": "20170724", "sessionKey": "tse_2330.tw_20170724|", -"sessionFromTime": -1, "stockInfoItem": 2055, "showChart": false, -"sessionStr": "UserSession", "stockInfo": 130895}, "rtcode": "0000"} -""", - """ -{"msgArray": [{"ts": "0", "tk0": "2330.tw_tse_20170724_B_9999760446", "tk1": -"2330.tw_tse_20170724_B_9999759382", "tlong": "1500861243000", "f": -"1034_1028_1009_1253_933_", "ex": "tse", "g": "1466_1625_798_987_1117_", "d": -"20170724", "it": "12", "b": "214.00_213.50_213.00_212.50_212.00_", "c": -"2330", "mt": "962863", "a": "214.50_215.00_215.50_216.00_216.50_", "n": -"\u53f0\u7a4d\u96fb", "o": "213.50", "l": "213.00", "h": "214.50", "ip": "0", -"i": "24", "w": "193.00", "v": "5268", "u": "235.00", "t": "09:54:03", "s": -"0", "pz": "213.50", "tv": "3", "p": "0", "nf": -"\u53f0\u7063\u7a4d\u9ad4\u96fb\u8def\u88fd\u9020\u80a1\u4efd\u6709\u9650\u516c\u53f8", -"ch": "2330.tw", -"z": "214.00", "y": "214.00", "ps": "1323"}], "userDelay": 5000, "rtmessage": -"OK", "referer": "", "queryTime": {"sysTime": "09:54:10", "sessionLatestTime": --1, "sysDate": "20170724", "sessionKey": "tse_2330.tw_20170724|", -"sessionFromTime": -1, "stockInfoItem": 1602, "showChart": false, -"sessionStr": "UserSession", "stockInfo": 119518}, "rtcode": "0000"} -""", + """{"msgArray": [{"tv": "-", "ps": "-", "pz": "-", "bp": "0", "a": "849.0000_850.0000_851.0000_852.0000_853.0000_", "b": "848.0000_847.0000_846.0000_845.0000_844.0000_", "c": "2330", "d": "20240516", "ch": "2330.tw", "tlong": "1715827494000", "f": "170_372_260_647_514_", "ip": "0", "g": "6_50_126_107_255_", "mt": "692836", "h": "856.0000", "i": "24", "it": "12", "l": "844.0000", "n": "\\u53f0\\u7a4d\\u96fb", "o": "852.0000", "p": "0", "ex": "tse", "s": "-", "t": "10:44:54", "u": "922.0000", "v": "23350", "w": "756.0000", "nf": "\\u53f0\\u7063\\u7a4d\\u9ad4\\u96fb\\u8def\\u88fd\\u9020\\u80a1\\u4efd\\u6709\\u9650\\u516c\\u53f8", "y": "839.0000", "z": "-", "ts": "0"}], "referer": "", "userDelay": 5000, "rtcode": "0000", "queryTime": {"sysDate": "20240516", "stockInfoItem": 2300, "stockInfo": 1107969, "sessionStr": "UserSession", "sysTime": "10:45:02", "showChart": false, "sessionFromTime": 1715827477731, "sessionLatestTime": 1715827477731}, "rtmessage": "OK", "exKey": "if_tse_2330.tw_zh-tw.null", "cachedAlive": 41360}""", + """{"msgArray": [{"tv": "-", "ps": "-", "pz": "-", "bp": "0", "a": "848.0000_849.0000_850.0000_851.0000_852.0000_", "b": "847.0000_846.0000_845.0000_844.0000_843.0000_", "c": "2330", "d": "20240516", "ch": "2330.tw", "tlong": "1715827560000", "f": "53_157_370_261_945_", "ip": "0", "g": "42_124_116_271_187_", "mt": "826330", "h": "856.0000", "i": "24", "it": "12", "l": "844.0000", "n": "\\u53f0\\u7a4d\\u96fb", "o": "852.0000", "p": "0", "ex": "tse", "s": "-", "t": "10:46:00", "u": "922.0000", "v": "23384", "w": "756.0000", "nf": "\\u53f0\\u7063\\u7a4d\\u9ad4\\u96fb\\u8def\\u88fd\\u9020\\u80a1\\u4efd\\u6709\\u9650\\u516c\\u53f8", "y": "839.0000", "z": "-", "ts": "0"}], "referer": "", "userDelay": 5000, "rtcode": "0000", "queryTime": {"sysDate": "20240516", "stockInfoItem": 762, "stockInfo": 270448, "sessionStr": "UserSession", "sysTime": "10:46:02", "showChart": false, "sessionFromTime": 1715827446503, "sessionLatestTime": 1715827446503}, "rtmessage": "OK", "exKey": "if_tse_2330.tw_zh-tw.null", "cachedAlive": 17846}""", + """{"msgArray": [{"tv": "-", "ps": "-", "pz": "-", "bp": "0", "a": "848.0000_849.0000_850.0000_851.0000_852.0000_", "b": "847.0000_846.0000_845.0000_844.0000_843.0000_", "c": "2330", "d": "20240516", "ch": "2330.tw", "tlong": "1715827579000", "f": "64_157_371_261_947_", "ip": "0", "g": "40_124_118_270_185_", "mt": "655374", "h": "856.0000", "i": "24", "it": "12", "l": "844.0000", "n": "\\u53f0\\u7a4d\\u96fb", "o": "852.0000", "p": "0", "ex": "tse", "s": "-", "t": "10:46:19", "u": "922.0000", "v": "23388", "w": "756.0000", "nf": "\\u53f0\\u7063\\u7a4d\\u9ad4\\u96fb\\u8def\\u88fd\\u9020\\u80a1\\u4efd\\u6709\\u9650\\u516c\\u53f8", "y": "839.0000", "z": "-", "ts": "0"}], "referer": "", "userDelay": 5000, "rtcode": "0000", "queryTime": {"sysDate": "20240516", "stockInfoItem": 2216, "stockInfo": 506844, "sessionStr": "UserSession", "sysTime": "10:46:25", "showChart": false, "sessionFromTime": -1, "sessionLatestTime": -1}, "rtmessage": "OK", "exKey": "if_tse_2330.tw_zh-tw.null", "cachedAlive": 21231}""", ]