Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
chingwen823 opened this issue Apr 20, 2018 · 8 comments
Open

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

chingwen823 opened this issue Apr 20, 2018 · 8 comments

Comments

@chingwen823
Copy link

有沒有一次抓取的方法?
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'

@ianlini
Copy link
Contributor

ianlini commented Apr 20, 2018

You can try this:

stocks = [Stock(symbol) for symbol in ['2330', '6515']]

I don't think it's a good idea to allow Stock(['2330', '6515']).
Maybe you can elaborate more on your use case?

@chingwen823
Copy link
Author

thanks you are right
what I trying to do is to compare a group of stocks with another

I will maintain a local dataset instead

by the way , the time limitation of connections of twes seems to be 3times/5sec

@ianlini
Copy link
Contributor

ianlini commented Apr 20, 2018

Yeah, it's very easy to be banned by TWSE. I always add a 1~5s random sleep between each request.

@chingwen823
Copy link
Author

我很好奇 一般限制是單位時間裡的連線數
如果不重建connection,連線的sesssion沒斷 應該可以一直無限去下查詢??(就不會被ban是嗎?)

@ianlini
Copy link
Contributor

ianlini commented Apr 20, 2018

我有想過這個問題,不過沒有測試過
另外 user agent 可能也有影響
不知道有沒有人測試過?

@twmht
Copy link

twmht commented Mar 7, 2019

@chingwen823

要如何作到不重建 connection 但是可以換查詢?

@chingwen823
Copy link
Author

chingwen823 commented Mar 7, 2019 via email

@TimLai666
Copy link

我不知道 我後來自已寫了一套

Ming-Hsuan-Tu notifications@github.com 於 2019年3月7日 下午8:48 寫道:

@chingwen823 https://github.com/chingwen823
要如何作到不重建 connection 但是可以換查詢?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub #41 (comment), or mute the thread https://github.com/notifications/unsubscribe-auth/APCdodOuldHZqYfXBEZ2g3M_2Ek2T3NOks5vUQqPgaJpZM4Tc3cG.

那真的不重建連線就能一直查下去不被封嗎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants