|
import math |
|
import choose |
|
import pandas as pd |
|
import os |
|
import datetime |
|
from pymongo import MongoClient |
|
client = MongoClient( |
|
"mongodb://wth000:wth000@43.159.47.250:27017/dbname?authSource=wth000") |
|
db = client["wth000"] |
|
collection=db[f"策略买入ST股票('000', '001', '002', '600', '601', '603', '605')"] |
|
collection.drop() |
|
moneyused = 0.9 |
|
|
|
file_path = os.path.abspath(__file__) |
|
|
|
dir_path = os.path.dirname(file_path) |
|
|
|
dir_path = os.path.dirname(os.path.dirname(dir_path)) |
|
path = os.path.join( |
|
dir_path, f"股票('000', '001', '002', '600', '601', '603', '605')指标周期30交易细节.csv") |
|
df = pd.read_csv(path) |
|
df = df[["代码", "日期"]] |
|
for idx, row in df.iterrows(): |
|
code = row['代码'] |
|
date = row['日期'] |
|
dfst = pd.DataFrame(list( |
|
db[f"聚宽ST股票('000', '001', '002', '600', '601', '603', '605')"].find({"代码": code, "日期": date}))) |
|
|
|
|
|
|
|
print(code, date, dfst) |
|
if not dfst.empty: |
|
collection.insert_many(dfst.to_dict("records")) |
|
|