我试图在Python中复制我在Java中的MarketDataRequest,但是找不到任何代码示例.有没有任何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))
解决方法:
呜!解决了我自己的问题
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)