Skip to content

Commit

Permalink
Merge pull request shidenggui#80 from zhangpf/fix-update-stock-codes-bug
Browse files Browse the repository at this point in the history
改变从shdjt更新股票代码的方式
  • Loading branch information
shidenggui authored May 22, 2020
2 parents 7e800d1 + 572e73e commit 75f3ff0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions easyquotation/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
def update_stock_codes():
"""获取所有股票 ID 到 all_stock_code 目录下"""
response = requests.get("http://www.shdjt.com/js/lib/astock.js")
stock_codes = re.findall(r"~(\d+)`", response.text)
stock_codes = re.findall(r"~([a-z0-9]*)`", response.text)
with open(STOCK_CODE_PATH, "w") as f:
f.write(json.dumps(dict(stock=stock_codes)))
return stock_codes
Expand All @@ -35,7 +35,7 @@ def get_stock_type(stock_code):
assert type(stock_code) is str, "stock code need str type"
sh_head = ("50", "51", "60", "90", "110", "113",
"132", "204", "5", "6", "9", "7")
if stock_code.startswith(("sh", "sz")):
if stock_code.startswith(("sh", "sz", "zz")):
return stock_code[:2]
else:
return "sh" if stock_code.startswith(sh_head) else "sz"
Loading

0 comments on commit 75f3ff0

Please sign in to comment.