|
@@ -1,41 +0,0 @@
|
|
-# -*- encoding: utf-8 -*-
|
|
|
|
-import csv
|
|
|
|
-import os
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-_workdir = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
-_filename = os.path.join(_workdir, 'code.csv')
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-def _download_data():
|
|
|
|
- """
|
|
|
|
- tushare doesnt support py2
|
|
|
|
- using py3(/root/.pyvenv/wzb_ts/bin/python3) to exec it
|
|
|
|
- """
|
|
|
|
- import tushare as ts
|
|
|
|
- ts.set_token('99800760dfbbdf7d0b4124f6d4be39ebac6a093628f0bd19a7432486')
|
|
|
|
- pro = ts.pro_api()
|
|
|
|
-
|
|
|
|
- df = pro.stock_basic(exchange='', list_status='L', fields='ts_code,symbol,name,area,industry,list_date')
|
|
|
|
- df.to_csv(_filename)
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-def get_stock_list():
|
|
|
|
- """
|
|
|
|
- no duplicate names
|
|
|
|
- """
|
|
|
|
- names = set()
|
|
|
|
- ret = []
|
|
|
|
- with open(_filename, 'r') as f:
|
|
|
|
- rows = csv.reader(f)
|
|
|
|
- for i in rows:
|
|
|
|
- code, name = i[2: 4]
|
|
|
|
- if name not in names:
|
|
|
|
- ret.append((code, name))
|
|
|
|
- names.add(name)
|
|
|
|
- return ret
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-if __name__ == '__main__':
|
|
|
|
- _download_data()
|
|
|
|
-
|
|
|