mirror of
http://47.116.20.24:3389/stock-study/pull-minute-k.git
synced 2026-03-02 04:27:39 +00:00
first commit, it can work
This commit is contained in:
30
get_min_data.py
Normal file
30
get_min_data.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from Ashare import *
|
||||
|
||||
import os
|
||||
import time
|
||||
import csv
|
||||
|
||||
stock_codes = {}
|
||||
with open('table-r.txt', 'r', encoding='utf-8') as file:
|
||||
csv_reader = csv.DictReader(file)
|
||||
for row in csv_reader:
|
||||
code = row["code"]
|
||||
if code.startswith("sh") or code.startswith("sz"):
|
||||
stock_codes[code] = row["name"]
|
||||
|
||||
for c, n in stock_codes.items():
|
||||
print(f"getting stock:{c} name:{n}")
|
||||
file_name = str(c) + "-" + str(n) + ".txt"
|
||||
file_name = file_name.replace("*", "#")
|
||||
if os.path.exists(file_name):
|
||||
print(f"file:{file_name} already exist, skip")
|
||||
continue
|
||||
try:
|
||||
df = get_price(c, frequency='1m', count=240)
|
||||
ctx = df.to_string()
|
||||
except:
|
||||
print("get price error")
|
||||
ctx = ""
|
||||
with open(file_name, "w", encoding="utf-8") as outfile:
|
||||
outfile.write(ctx)
|
||||
# time.sleep(0.01)
|
||||
Reference in New Issue
Block a user