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

不好意思,今天剛看到這個東西,感覺很方便 #131

Open
cloudfender opened this issue Nov 14, 2024 · 4 comments
Open

不好意思,今天剛看到這個東西,感覺很方便 #131

cloudfender opened this issue Nov 14, 2024 · 4 comments

Comments

@cloudfender
Copy link

Dear Sir,

不好意思,今天剛看到這個東西,感覺很方便,但是它好像撈不到上櫃每日的股價資料
還是我那弄錯了?

@z29960879
Copy link

z29960879 commented Dec 3, 2024

櫃買的網站更新了,在作者還沒更新前,如果您知道如何修改,可以依照以下步驟。
前往安裝Python目錄下Site-Packages的twStock套件,打開裡面的stock.py檔案。
更新 TPEX_BASE_URL = "https://www.tpex.org.tw/"


更新 Class TPEXFetcher():下的
REPORT_URL = urllib.parse.urljoin(
TPEX_BASE_URL, "www/zh-tw/afterTrading/tradingStock"
)
...
params = {"date": "%d/%02d/01" % (year,month), "code": sid}
...
Fail in all retries
data = {"tables": [{"data":[]}]}
...

if data["tables"][0]["data"]:
data["data"] = self.purify(data)
...
def _make_datatuple(self, data):
data[0] = datetime.datetime.strptime(
self._convert_date(data[0].replace("*", "")), "%Y/%m/%d"
)
...
def purify(self, original_data):
return [self._make_datatuple(d) for d in original_data["tables"][0]["data"]]

@mlouielu
Copy link
Owner

mlouielu commented Dec 3, 2024

why params = {"date": "%d/%02d/01" % (year,month), "code": sid} with day = 01?

@z29960879
Copy link

z29960879 commented Dec 4, 2024

why params = {"date": "%d/%02d/01" % (year,month), "code": sid} with day = 01?

like the TWSE, I think it mean startdate.
Ok, I have same result that I use the vaild date in same month. It doesn't matter,just use the vaild date.
01 is always safe.

@Lilyo
Copy link

Lilyo commented Dec 25, 2024

Hi @z29960879 ,
Your answer solved my problem, thank you!

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