Skip to content

[工具问题] dsb 的读取与写入 #79

Answered by ZzzzHeJ
ZzzzHeJ asked this question in Q&A
Discussion options

You must be logged in to vote

dsb写入

使用pandas读取csv为dataFrame后,写入代码如下:

导入代码

from wtpy.WtCoreDefs import WTSBarStruct, WTSTickStruct
from wtpy.wrapper import WtDataHelper

dthelper = WtDataHelper()

bar 的写入

count = len(df)
BUFFER = WTSBarStruct * count
buffer = BUFFER()
for index, row in tqdm(df.iterrows()):
    curBar = buffer[index]
    curBar.date = int(row["date"])
    curBar.open = float(row["open"])
    curBar.high = float(row["high"])
    curBar.low = float(row["low"])
    curBar.close = float(row["close"])
    curBar.vol = float(row["vol"])
    curBar.money = float(row["money"])
    curBar.hold = float(row["hold"])

# dsb_file 是写入文件名,period是周期,可选取值为d(日线)m(分钟线)
dthelper.store_bars(barFile=dsb_file,firstBar=buffer,c…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ZzzzHeJ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant