{"_id": 0},
batch_size=10000
)
if format in ["dict", "json"]:
return [data for data in cursor]
// for item in cursor:
_data = pd.DataFrame([item for item in cursor])
_data = _data.assign(datetime=pd.to_datetime(_data["datetime"]))
// _data.append([str(item["code"]), float(item["open"]),
// float(item["high"]), float(
// item["low"]), float(item["close"]), int(item["up_count"]),
// int(item["down_count"]), float(item["vol"]), float(item["amount"]),
// item["datetime"], item["time_stamp"], item["date"], item["type"]])
// _data = DataFrame(_data, columns=[
// "code", "open", "high", "low", "close", "up_count", "down_count",
// "volume", "amount", "datetime", "time_stamp", "date", "type"])
// _data["datetime"] = pd.to_datetime(_data["datetime"])
_data = _data.set_index("datetime", drop=False)
if format in ["numpy", "np", "n"]:
return numpy.asarray(_data)
elif format in ["list", "l", "L"]:
return numpy.asarray(_data).tolist()
elif format in ["P", "p", "pandas", "pd"]:
return _data
def QA_fetch_future_day(
code,
After Change
res = pd.DataFrame([item for item in cursor])
try:
res = res.assign(
volume=res.vol,
datetime=pd.to_datetime(res.datetime)
).query("volume>1").drop_duplicates(["datetime",
"code"]).set_index(
"datetime",
drop=False
)
// return res
except:
res = None
// 多种数据格式
if format in ["P", "p", "pandas", "pd"]:
return res
elif format in ["json", "dict"]:
return QA_util_to_json_from_pandas(res)
elif format in ["n", "N", "numpy"]: