代码之家  ›  专栏  ›  技术社区  ›  Christian

quickfix python市场数据请求

  •  4
  • Christian  · 技术社区  · 9 年前

    我试图复制Python中的MarketDataRequest,我在Java中有,但找不到任何代码示例。有人有Python和Quickfix的经验吗

    Java代码如下所示:

    MarketDataRequest mdr = new MarketDataRequest();
    
    if (subscribed)
    {
        mdr.set(new SubscriptionRequestType(SubscriptionRequestType.DISABLE_PREVIOUS_SNAPSHOT_PLUS_UPDATE_REQUEST));
        Session.sendToTarget(mdr, sessionId);
    }
    
    mdr.set(new MDReqID("1"));
    mdr.set(new SubscriptionRequestType(SubscriptionRequestType.SNAPSHOT_PLUS_UPDATES));
    mdr.set(new MarketDepth(0));
    mdr.set(new MDUpdateType(MDUpdateType.INCREMENTAL_REFRESH));
    
    mdr.set(new NoMDEntryTypes(2));
    
    MarketDataRequest.NoMDEntryTypes entries = new MarketDataRequest.NoMDEntryTypes();
    entries.set(new MDEntryType(MDEntryType.BID));
    mdr.addGroup(entries);
    entries.set(new MDEntryType(MDEntryType.OFFER));
    mdr.addGroup(entries);
    
    mdr.set(new NoRelatedSym(pairs.size()));
    
    MarketDataRequest.NoRelatedSym symbols = new MarketDataRequest.NoRelatedSym();
    
    for (String pair : pairs)
    {
        symbols.set(new Instrument(new Symbol(pair)));
        mdr.addGroup(symbols);
    }
    
    Session.sendToTarget(mdr, sessionId);
    

    到目前为止,在Python中我有这样一个:

    mdr = fix.Message()
    mdr.getHeader().setField(fix.BeginString(fix.BeginString_FIX44))
    mdr.getHeader().setField(fix.MsgType(fix.MsgType_MarketDataRequest))
    
    mdr.setField(fix.MDReqID('1'))
    mdr.setField(fix.SubscriptionRequestType(fix.SubscriptionRequestType_SNAPSHOT_PLUS_UPDATES))
    mdr.setField(fix.MarketDepth(0))
    mdr.setField(fix.NoMDEntryTypes(2))
    mdr.setField(fix.MDUpdateType(fix.MDUpdateType_INCREMENTAL_REFRESH))
    
    1 回复  |  直到 9 年前
        1
  •  4
  •   Christian    9 年前

    求爱解决了我自己的问题

    mdr = fix.Message()
    mdr.getHeader().setField(fix.BeginString(fix.BeginString_FIX44))
    mdr.getHeader().setField(fix.MsgType(fix.MsgType_MarketDataRequest))
    
    mdr.setField(fix.MDReqID('1'))
    mdr.setField(fix.SubscriptionRequestType(fix.SubscriptionRequestType_SNAPSHOT_PLUS_UPDATES))
    mdr.setField(fix.MarketDepth(0))
    mdr.setField(fix.NoMDEntryTypes(2))
    mdr.setField(fix.MDUpdateType(fix.MDUpdateType_INCREMENTAL_REFRESH))
    
    group = fixnn.MarketDataRequest().NoMDEntryTypes()
    group.setField(fix.MDEntryType(fix.MDEntryType_BID))
    mdr.addGroup(group)
    group.setField(fix.MDEntryType(fix.MDEntryType_OFFER))
    mdr.addGroup(group)
    
    mdr.setField(fix.NoRelatedSym(len(new_pairs)))
    
    symbol = fixnn.MarketDataRequest().NoRelatedSym()
    for pair in new_pairs:
        symbol.setField(fix.Symbol(pair))
        mdr.addGroup(symbol)
    
    fix.Session.sendToTarget(mdr, sessionID)