first commit, it can work

This commit is contained in:
admin
2025-05-03 23:06:31 +08:00
commit 9a18337326
3 changed files with 5504 additions and 0 deletions

30
get_min_data.py Normal file
View 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)