Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

无法通过共享内存获取tick,order,trade数据 #138

Open
Ye980226 opened this issue Feb 20, 2024 · 0 comments
Open

无法通过共享内存获取tick,order,trade数据 #138

Ye980226 opened this issue Feb 20, 2024 · 0 comments

Comments

@Ye980226
Copy link

Ye980226 commented Feb 20, 2024

HFTStrategy,机器是centos7,wtpy版本是0.9.9.3,使用的是xtp的测试账号,在非交易时间段的回放行情

def on_tick(self, context: HftContext, stdCode: str, newTick: dict):
     order_slice=self.context.stra_get_order_detail(stdCode,1)
     trade_slice=self.context.stra_get_transaction(stdCode,1)
     tick_slice=context.stra_get_ticks(stdCode,1)
     if order_slice is not None and trade_slice is not None:
         print(order_slice.ndarray)
         print(trade_slice.ndarray)
     elif tick_slice is not None:
         print(tick_slice.ndarray)
     else:
         print(newTick)
     pass

dtcfg.yaml的配置文件如下

basefiles:
    commodity: ../common/stk_comms.json
    contract: ../common/stocks.json
    holiday: ../common/holidays.json
    session: ../common/stk_sessions.json
    utf-8: true
broadcaster:                    # UDP广播器配置项,如果要在局域网转发行情,可以使用该模块
    active: false
    bport: 3997                 # UDP查询端口,主要是用于查询最新的快照
    broadcast:                  # 广播配置
    -   host: 255.255.255.255   # 广播地址,255.255.255.255会向整个局域网广播,但是受限于路由器
        port: 9001              # 广播端口,接收端口要和广播端口一致
        type: 2                 # 数据类型,固定为2
shmcaster:                      # 共享内存转发,适合本机转发
    active: true
    path: ./exchange.membin     # memmap文件路径
parsers: mdparsers.yaml
statemonitor: statemonitor.yaml
writer:
    module: WtDataStorage   #数据存储模块
    async: true             #同步落地还是异步落地,期货推荐同步,股票推荐异步
    groupsize: 20           #日志分组大小,主要用于控制日志输出,当订阅合约较多时,推荐1000以上,当订阅的合约数较少时,推荐100以内
    path: ../storage        #数据存储的路径
    savelog: false          #是否保存tick到csv
    disabletick: false      #不保存tick数据,默认false
    disablemin1: true      #不保存min1数据,默认false
    disablemin5: true      #不保存min5数据,默认false
    disableday: true       #不保存day数据,默认false
    disabletrans: false     #不保存股票l2逐笔成交数据,默认false
    disableordque: true    #不保存股票l2委托队列数据,默认false
    disableorddtl: false    #不保存股票l2逐笔委托数据,默认false

tdparser.yaml配置文件如下

parsers:
-   active: false
    id: parser1
    module: ParserUDP
    host: 127.0.0.1
    bport: 9001       # 广播端口
    sport: 3997       # 查询端口
    filter: ''
    
-   active: true    
    id: parser0
    module: ParserShm                     # 基于Sharememory的行情解析模块
    path: ../datakit_stk/exchange.membin  # memmap文件路径,需要和datakit匹配
    gpsize: 1000                          # 分组大小,主要用于控制日志的显示频率
    check_span: 2                         # 检查时间间隔,单位微秒,如果没有新的数据,则休眠若干时间

不知道是不是我哪里弄错了,麻烦大佬看一下~


稍微打印了一下回调函数好像并没有打印信息
VV5TVH89CSI17OF6CE~E$ O

1S}3Z82G%8F)HL0GAU958

I_NX `H1JD8D18_~B9V)ET1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant