Giter Club home page Giter Club logo

twstock's Introduction

Travis Build Status Appveyor Build Status Coverage Status PyPI version Documentation Status

有任何問題歡迎透過 Gitter.im 詢問。

twstock 台灣股市股票價格擷取

擷取台灣證券交易所之股價資料 重新製作 toomore/grs 之功能

資料來源:

(請注意,TWSE 有 request limit, 每 5 秒鐘 3 個 request,超過的話會被 ban 掉,請自行注意)

Documentation

Requirements

  • Python 3
  • lxml
  • requests

Install

By PyPi

$ python -m pip install --user twstock

By Source

$ git clone https://github.com/mlouielu/twstock
$ cd twstock
$ pipenv install

By Source & install

$ git clone https://github.com/mlouielu/twstock
$ cd twstock
$ python -m pip install --user flit
$ flit install

CLI Tools

$ twstock -b 2330 6223
四大買賣點判斷 Best Four Point
------------------------------
2330: Buy   量大收紅
6223: Sell  量縮價跌, 三日均價小於六日均價
$ twstock -s 2330 6223
-------------- 2330 ----------------
high : 215.0 214.0 210.0 210.5 208.5
low  : 212.0 211.0 208.0 208.5 206.5
price: 215.0 211.5 208.5 210.0 208.5
-------------- 2337 ----------------
high :  16.2  16.8  16.4 16.75 16.75
low  :  15.8  16.1 15.15  16.3 16.25
price: 15.95 16.25 16.25  16.6  16.7

Update Codes

當你第一次使用 twstock 時,你可以更新 TPEX 跟 TWSE 的列表,可以使用兩種方式更新:

  • By CLI
$ twstock -U
Start to update codes
Done!
  • By Python
>>> import twstock
>>> twstock.__update_codes()

Quick Start

分析計算

from twstock import Stock

stock = Stock('2330')                             # 擷取台積電股價
ma_p = stock.moving_average(stock.price, 5)       # 計算五日均價
ma_c = stock.moving_average(stock.capacity, 5)    # 計算五日均量
ma_p_cont = stock.continuous(ma_p)                # 計算五日均價持續天數
ma_br = stock.ma_bias_ratio(5, 10)                # 計算五日、十日乖離值

擷取自 2015 年 1 月至今之資料

stock = Stock('2330')
stock.fetch_from(2015, 1)

基本資料之使用

>>> stock = Stock('2330')
>>> stock.price
[203.5, 203.0, 205.0, 205.0, 205.5, 207.0, 207.0, 203.0, 207.0, 209.0, 209.0, 212.0, 210.5, 211.5, 213.0, 212.0, 207.5, 208.0, 207.0, 208.0, 211.5, 213.0, 216.5, 215.5, 218.0, 217.0, 215.0, 211.5, 208.5, 210.0, 208.5]
>>> stock.capacity
[22490217, 17163108, 17419705, 23028298, 18307715, 26088748, 32976727, 67935145, 29623649, 23265323, 1535230, 22545164, 15382025, 34729326, 21654488, 35190159, 63111746, 49983303, 39083899, 19486457, 32856536, 17489571, 28784100, 45384482, 26094649, 39686091, 60140797, 44504785, 52273921, 27049234, 31709978]
>>> stock.data[0]
Data(date=datetime.datetime(2017, 5, 18, 0, 0), capacity=22490217, turnover=4559780051, open=202.5, high=204.0, low=201.5, close=203.5, change=-0.5, transaction=6983)

台股證券編碼

>>> import twstock
>>> print(twstock.codes)                # 列印台股全部證券編碼資料
>>> print(twstock.codes['2330'])        # 列印 2330 證券編碼資料
StockCodeInfo(type='股票', code='2330', name='台積電', ISIN='TW0002330008', start='1994/09/05', market='上市', group='半導體業', CFI='ESVUFR')
>>> print(twstock.codes['2330'].name)   # 列印 2330 證券名稱
'台積電'
>>> print(twstock.codes['2330'].start)  # 列印 2330 證券上市日期
'1994/09/05'

使用 Proxy (基於 requests proxies)

# 單一 Proxy
>>> from twstock.proxy import SingleProxyProvider
>>> spr = SingleProxyProvider({'http': 'http://localhost:8080'})
>>> twstock.proxy.configure_proxy_provider(spr)

# 多個 Proxy
>>> from twstock.proxy import RoundRobinProxiesProvider
>>> proxies = [{'http': 'http://localhost:5000'}, {'http': 'http://localhost:5001'}]
>>> rrpr = RoundRobinProxiesProvider(proxies)
>>> twstock.proxy.configure_proxy_provider(rrpr)

# 變更 Proxy 表
>>> another_proxies = [{'http': 'http://localhost:8000'}, {'https': 'https://localhost:8001'}]
>>> rrpr.proxies = another_proxies

四大買賣點分析

from twstock import Stock
from twstock import BestFourPoint

stock = Stock('2330')
bfp = BestFourPoint(stock)

bfp.best_four_point_to_buy()    # 判斷是否為四大買點
bfp.best_four_point_to_sell()   # 判斷是否為四大賣點
bfp.best_four_point()           # 綜合判斷

即時股票資訊查詢

import twstock

twstock.realtime.get('2330')    # 擷取當前台積電股票資訊
twstock.realtime.get(['2330', '2337', '2409'])  # 擷取當前三檔資訊

使用範例

Contributing

twstock was created by Louie Lu <[email protected]>.

Contributing were welcome, please use GitHub issue and Pull Request to contribute!

歡迎協作,請使用 GitHub issue 以及 Pull Request 功能來協作。

twstock's People

Contributors

bluewings1211 avatar ianlini avatar imidya avatar jimwayneyeh avatar lefthaha avatar mlouielu avatar qrtt1 avatar tccintaiwan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

twstock's Issues

stockcode 00757/00762讀不到

Python 3.4/3.6都一樣的錯誤
Python 3.4.9 (default, Feb 5 2019, 14:36:09)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.

import twstock
print(twstock.codes['00757'])
Traceback (most recent call last):
File "", line 1, in
KeyError: '00757'
print(twstock.codes['00762'])
Traceback (most recent call last):
File "", line 1, in
KeyError: '00762'

獲取股票代號6699返回false

{'msgArray': [], 'userDelay': 5000, 'rtmessage': 'Empty Query.', 'referer': '', 'queryTime': {'sysTime': '16:39:33', 'sessionLatestTime': -1, 'sysDate': '20190710', 'sessionFromTime': -1, 'stockInfoItem': 2657, 'showChart': False, 'sessionStr': 'UserSession', 'stockInfo': 556329}, 'rtcode': '5001', 'success': False}

一次抓取多筆代號股票之31日交易資料?

有沒有一次抓取的方法?
ex. restock.Stock(['2330','6515'])

try with list got en error back:

stock = twstock.Stock(stocknum)
2
stock

TypeError Traceback (most recent call last)
in ()
----> 1 stock = twstock.Stock(stocknum)
2 stock

~/Library/Python/3.6/lib/python/site-packages/twstock/stock.py in init(self, sid, initial_fetch)
133 def init(self, sid: str, initial_fetch: bool=True):
134 self.sid = sid
--> 135 self.fetcher = TWSEFetcher() if codes[sid].market == '上市' else TPEXFetcher()
136 self.raw_data = []
137 self.data = []

TypeError: unhashable type: 'list'

How can I convert each item in stock.price list to float type variable?

Hi mlouielu,

 I would like to convert each item in stock.price list to float type variable. Could you kindly to tell me how to do it?

stock = Stock('2330')

stock.price
[203.5, 203.0, 205.0, 205.0, 205.5, 207.0, 207.0, 203.0, 207.0, 209.0, 209.0, 212.0, 210.5, 211.5, 213.0, 212.0, 207.5, 208.0, 207.0, 208.0, 211.5, 213.0, 216.5, 215.5, 218.0, 217.0, 215.0, 211.5, 208.5, 210.0, 208.5]

snowuyl

Quickstart: 認識 codes 的上櫃股票部份有誤

"認識Codes " 裡面的簡介有些問題

上櫃公司那邊

import twstock
'2330' in twstock.twse
True
'6223' in twstock.twse
False
=========應該改為=======
import twstock
'2330' in twstock.tpex
True
'6223' in twstock.tpex
False

歷史資料問題

歷史資料是否可以提供array的格式,一次餵入多筆資料。
減少多次向twse請求,造成ip被鎖的問題。

Raise error when stat is not 'OK' in Stock.fetch()

In TWSEFetcher.fetch(), we currently catch the JSONDecodeError (or ValueError in Python 2) and let the return value to be:

{
    'stat': '',
    'data': []
}

stat may also be other values return by TWSE / TPEX, and we don't check the stat in Stock.fetch().

This is bad because when using Stock, users won't know what happens unless they look into the Stock.raw_data.

I propose 2 solutions:

  1. raise error when 'stat' is not 'OK' in Stock.fetch()
  2. Stock.fetch() gives a better return value to let users know what happens

I prefer 1. because Stock.fetch() should be a high-level function that is always successful, so users should always deal with the non-OK stat.

How to get stock's change?

I want to know how to get realtime stock's change in twstock API?
請問如何運用twstock來得到即時股票的當日漲跌呢?

Thanks.
謝謝。

RSV , K , D

an issue about caculate RSV , K . D value

thanks

Get OTC stock fail.

Hello,
I can't get OTC stock price now. Maybe OTC changed website information so getting fail.
Could you help to check it? Thank you.

    stock = Stock('5498')
    print(stock.price)

fetch_from (y, m) ERROR : simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

我實在對證交所公開歷史價格的網站很感冒
每次訪問伺服器只能訪問某一個月
如果我一次要10年的資料,我是不是要訪問120次?
如果要100檔股票10年,是不是要1200次?
訪問頻率是4秒一次,高了會被鎖
然後,我需要690多家公司從2000年到今天的歷史資料,算了一下要7天
現在用這個庫,fetch_from是不能用的,除了這個報錯外,你們的數據有時後會含有'--'的資料,也就是當日沒開盤,這個沒辦法轉float

這個我在自己的爬蟲程式就遇到過了,麻煩發表一個開源的庫能不能專業一點?

RUN出現問題?

/Library/Frameworks/Python.framework/Versions/3.7/bin/python3 /Users/yangjunyu/PycharmProjects/untitled4/nre.py
Traceback (most recent call last):
File "/Users/yangjunyu/PycharmProjects/untitled4/nre.py", line 1, in
import twstock
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/twstock/init.py", line 3, in
from twstock import stock
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/twstock/stock.py", line 22, in
raise e
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/twstock/stock.py", line 18, in
from .codes import codes
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/twstock/codes/init.py", line 1, in
from .fetch import __update_codes
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/twstock/codes/fetch.py", line 14, in
from lxml import etree
ModuleNotFoundError: No module named 'lxml'

程式被twse擋ip

請問可否修正因為過於頻繁抓取資料
導致被twse拒絕連線

http.client.RemoteDisconnected: Remote end closed connection without response

Hi,

When running the twstock to get the stock information, it shows this information:

Traceback (most recent call last):
File "C:\Users\goyo\PycharmProjects\pythonProject1\venv\lib\site-packages\urllib3\connectionpool.py", line 670, in urlopen
httplib_response = self._make_request(
File "C:\Users\goyo\PycharmProjects\pythonProject1\venv\lib\site-packages\urllib3\connectionpool.py", line 426, in _make_request
six.raise_from(e, None)
File "", line 3, in raise_from
File "C:\Users\goyo\PycharmProjects\pythonProject1\venv\lib\site-packages\urllib3\connectionpool.py", line 421, in _make_request
httplib_response = conn.getresponse()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2288.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 1347, in getresponse
response.begin()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2288.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 307, in begin
version, status, reason = self._read_status()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2288.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 276, in _read_status
raise RemoteDisconnected("Remote end closed connection without"

Is there anyone know how to fix this issue?

Thank you very much.

'*' suffix of the date is not handled

symbol: 00694B
date: 106/06/08
eror message:

...
  File ".../python3.6/site-packages/twstock/stock.py", line 152, in fetch
    self.raw_data = [self.fetcher.fetch(year, month, self.sid)]
  File ".../python3.6/site-packages/twstock/stock.py", line 108, in fetch
    data['data'] = self.purify(data)
  File ".../python3.6/site-packages/twstock/stock.py", line 128, in purify
    return [self._make_datatuple(d) for d in original_data['aaData']]
  File ".../python3.6/site-packages/twstock/stock.py", line 128, in <listcomp>
    return [self._make_datatuple(d) for d in original_data['aaData']]
  File ".../python3.6/site-packages/twstock/stock.py", line 116, in _make_datatuple
    data[0] = datetime.datetime.strptime(self._convert_date(data[0]), '%Y/%m/%d')
  File "/usr/local/lib/python3.6/_strptime.py", line 565, in _strptime_datetime
    tt, fraction = _strptime(data_string, format)
  File "/usr/local/lib/python3.6/_strptime.py", line 365, in _strptime
    data_string[found.end():])
ValueError: unconverted data remains: *

The reason why there is :

「*」表示該日為該股票上櫃掛牌首日,其掛牌首日之漲跌係以當日收盤價減承銷價計算而得。

We should ignore this suffix.

Can't fetch historical data before 2010

Here is a simple example :

stock = Stock('2330')
stock.fetch(2008, 4)
for index in range(len(stock.data)):
    print(stock.data[index])

print(len(stock.data))

The result shows that stock.data is empty.
By the way, if fetch date after 2010, it will be workable.
Does anyone meet the same problem?

2017 12/18 大樹(6469) Error

2017 12/18 大樹(6469) ,當天無交易量,證交所的資料為 '--'
程式會出現 Error。

希望能自動拿前一天的收盤價取代表示。

realtime.get() function issue

sometime i got the issue message as below

{'userDelay': 500, 'rtmessage': ' ', 'rtcode': '0000', 'success': False}

My code:

from twstock import realtime

for stockid in stockidList:
for i in range(10):
rl = realtime.get(stockid)
if rl['success'] == True:
latest_trade_price = float(rl['realtime']['latest_trade_price'])
break
else:
latest_trade_price = 0
print(rl)
time.sleep(0.5)

ImportError not clear when causing by import lxml failed

Hi

I already installed package as below
pip install twstock
pip install analytics

But when I start coding via import twstock

Traceback (most recent call last):
File "d:/Project/A00 Test/stock.py", line 1, in
import twstock
File "C:\Users\10802304\AppData\Roaming\Python\Python37\site-packages\twstock_init_.py", line 3, in
from twstock import stock
File "C:\Users\10802304\AppData\Roaming\Python\Python37\site-packages\twstock\stock.py", line 20, in
import analytics
File "C:\Users\10802304\AppData\Local\Continuum\anaconda3\lib\site-packages\analytics_init_.py", line 23
except Exception, e:
^
SyntaxError: invalid syntax

It seems analytics is incompatible with twstock due to using python2 older version.
Any idea?

Requirement for Python3

Great work, guy!

Just a little reminder. It should only work in Python3.

File "twstock/stock.py", line 30
   def fetch(self, year: int, month: int, sid: str, retry=5):

Maybe you could put this requirement into README. : )

My IP seems be blocked by www.twse.com.tw after I test my code....

After I tried to test my program with your twstock module several times, I got below Error message and
also, cannot access ww.twse.com by web-browser which is terrible to me.
At the same time. I used my mobile phone to access www.twse.com.tw is OK.
So, I think my IP is already blocked.

Is there any network policy of TWSE?
Please Help!!!

stock = twstock.Stock('2330')
............
............
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))

程式執行有時會發生錯誤

我在執行以下程式時
xstock=twstock.realtime.get('1101')
realtime=xstock.get('realtime')
xopen=realtime.get('open')
xprice=realtime.get('latest_trade_price')
xvolume=realtime.get('accumulate_trade_volume')
有時候會出現以下問題
xopen=realtime.get('open')
AttributeError: 'NoneType' object has no attribute 'get'

不知道是哪裡的問題呢?

stockcode 1760讀不到

import twstock
twstock.realtime.get('1760');
{'queryTime': {'stockInfo': 1190971, 'sessionFromTime': -1, 'stockInfoItem': 4289, 'sessionLatestTime': -1, 'sysTime': '13:25:20', 'sessionStr': 'UserSession', 'showChart': False, 'sysDate': '20181122'}, 'rtmessage': 'Empty Query.', 'userDelay': 5000, 'rtcode': '5001', 'msgArray': [], 'referer': '', 'success': False}
from twstock import Stock
from twstock import BestFourPoint
stock = Stock('1760');
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python3.4/site-packages/twstock/stock.py", line 135, in init
self.fetcher = TWSEFetcher() if codes[sid].market == '上市' else TPEXFetcher()
KeyError: '1760'
print(twstock.codes['1760'])
Traceback (most recent call last):
File "", line 1, in
KeyError: '1760'

有些日期會標註星號, 造成錯誤

您好,
我在抓資料的時候發現有些日期會標註星號, 會造成錯誤, 如果可以的話需修改以下部分:

image

須加上 data[0] = data[0].replace('*','') # 注意 星號是全形的

Unable to extract historical data on certain stocks

I was unable to extract data for the following stocks. Just taking a random guess that it could be the reason ? .. Attaching the date for 停止交易 for your reference.

2311 日月光 2016/5/26
2317 鴻海 2016/3/30
1101 台泥/ 2017/4/19
1216 統一/ 2017/7/27
2354 鴻準 2016/3/30
2454 聯發科 2016/5/13
2912 統一超 2017/7/27

I got ban from TWSE after running the unit test twice

I got ban from TWSE after running the unit test twice.
I am very sure that I am not running other crawler at the same time.
The unit test is very dangerous. Maybe we should add some delay between requests, or mock almost all the requests.

Got banned after 4 requests (3 sec gap)

每次測試都在4次請求後被禁, 請求與請求之間有三秒間隔, 以下為代碼

`import twstock
import time

// Create a Stock array
stock = []

// stock[i] is stock which sid = i
for i in range(0, 10000):
sid = str(i)
# check if stock i exist
if sid in twstock.twse or sid in twstock.tpex:
stock.append(twstock.Stock(sid))
# print(stock[i].data)
print('sid' + stock[i].sid + 'get!')
time.sleep(3)
# if not, its NaN
else:
stock.append('NaN')
print('stock' + sid + 'does not exist')`

以下為輸出結果:

stock0does not exist
stock1does not exist
stock2does not exist
stock3does not exist
.
.
.
stock1097does not exist
stock1098does not exist
stock1099does not exist
stock1100does not exist
sid1101get!
sid1102get!
sid1103get!
sid1104get!
stock1105does not exist
stock1106does not exist
stock1107does not exist
Traceback (most recent call last):
File "C:\Users\USER\PycharmProjects\StockTrade\venv\lib\site-packages\urllib3\connectionpool.py", line 670, in urlopen
httplib_response = self._make_request(
File "C:\Users\USER\PycharmProjects\StockTrade\venv\lib\site-packages\urllib3\connectionpool.py", line 426, in _make_request
six.raise_from(e, None)
File "", line 3, in raise_from
File "C:\Users\USER\PycharmProjects\StockTrade\venv\lib\site-packages\urllib3\connectionpool.py", line 421, in _make_request
httplib_response = conn.getresponse()
File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 1332, in getresponse
response.begin()
File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 303, in begin
version, status, reason = self._read_status()
File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 272, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\USER\PycharmProjects\StockTrade\venv\lib\site-packages\requests\adapters.py", line 439, in send
resp = conn.urlopen(
File "C:\Users\USER\PycharmProjects\StockTrade\venv\lib\site-packages\urllib3\connectionpool.py", line 724, in urlopen
retries = retries.increment(
File "C:\Users\USER\PycharmProjects\StockTrade\venv\lib\site-packages\urllib3\util\retry.py", line 403, in increment
raise six.reraise(type(error), error, _stacktrace)
File "C:\Users\USER\PycharmProjects\StockTrade\venv\lib\site-packages\urllib3\packages\six.py", line 734, in reraise
raise value.with_traceback(tb)
File "C:\Users\USER\PycharmProjects\StockTrade\venv\lib\site-packages\urllib3\connectionpool.py", line 670, in urlopen
httplib_response = self._make_request(
File "C:\Users\USER\PycharmProjects\StockTrade\venv\lib\site-packages\urllib3\connectionpool.py", line 426, in _make_request
six.raise_from(e, None)
File "", line 3, in raise_from
File "C:\Users\USER\PycharmProjects\StockTrade\venv\lib\site-packages\urllib3\connectionpool.py", line 421, in _make_request
httplib_response = conn.getresponse()
File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 1332, in getresponse
response.begin()
File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 303, in begin
version, status, reason = self._read_status()
File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 272, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/USER/PycharmProjects/StockTrade/app.py", line 11, in
stock.append(twstock.Stock(sid))
File "C:\Users\USER\PycharmProjects\StockTrade\venv\lib\site-packages\twstock\stock.py", line 154, in init
self.fetch_31()
File "C:\Users\USER\PycharmProjects\StockTrade\venv\lib\site-packages\twstock\stock.py", line 183, in fetch_31
self.fetch_from(before.year, before.month)
File "C:\Users\USER\PycharmProjects\StockTrade\venv\lib\site-packages\twstock\stock.py", line 175, in fetch_from
self.raw_data.append(self.fetcher.fetch(year, month, self.sid))
File "C:\Users\USER\PycharmProjects\StockTrade\venv\lib\site-packages\twstock\stock.py", line 58, in fetch
r = requests.get(self.REPORT_URL, params=params,
File "C:\Users\USER\PycharmProjects\StockTrade\venv\lib\site-packages\requests\api.py", line 76, in get
return request('get', url, params=params, **kwargs)
File "C:\Users\USER\PycharmProjects\StockTrade\venv\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\USER\PycharmProjects\StockTrade\venv\lib\site-packages\requests\sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\USER\PycharmProjects\StockTrade\venv\lib\site-packages\requests\sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "C:\Users\USER\PycharmProjects\StockTrade\venv\lib\site-packages\requests\adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

Process finished with exit code 1

有試過用更長時間 (10 sec) 為間隔 依然被禁

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.