我正在股票和外匯市場工作。我有這樣的情況:我需要從日誌中取出一個字符串,並將其轉換爲「消息」類型的對象。按照this link我嘗試使用JAVA中的「MessageUtils」類的所有三種方法。但我的字符串被剝離到具有唯一標記的Message類型對象。但是因爲我的字符串是「MarketDataIncrementalRefresh」類型,我希望每個標籤都出現在消息中。如何在Java的QUICKFIX中將字符串轉換爲MarketDataIncrementalRefresh?
例如:我將以下字符串提供給「MessageUtils.parse()」方法。
8 = FIX.4.2 | 9 = 00795 | 35 = W | 49 = TT_PRICE | 56 = SAP0094X | 34 = 2392 | 52 = 20170623-04:41:33.375 | 55 = CL | 48 = 00A0HR00CLZ | 10455 = CLQ7 | 167 = FUT | 207 = CME | 15 = USD | 262 = MDRQ-751 | 200 = 201708 | 18210 = 1 | 387 = 12292 | 268 = 24 | 269 = 0 | 290 = 1 | 270 = 4290 | 271 = 33 | 269 = 0 | 290 = 2 | 270 = 4289 | 271 = 34 | 269 = 0 | 290 = 3 | 270 = 4288 | 271 = 40 | 269 = 0 | 290 = 4 | 270 = 4287 | 271 = 38 | 269 = 0 | 290 = 5 | 270 = 4286 | 271 = 46 | 269 = 0 | 290 = 6 | 270 = 4285 | 271 = 53 | 269 = 0 | 290 = 7 | 270 = 4284 | 271 = 46 | 269 = 0 | 290 = 8 | 270 = 4283 | 271 = 66 | 269 = 0 | 290 = 9 | 270 = 4282 | 271 = 48 | 269 = 0 | 290 = 10 | 270 = 4281 | 271 = 64 | 269 = 1 | 290 = 1 | 270 = 4291 | 271 = 21 | 269 = 1 | 290 = 2 | 270 = 4292 | 271 = 40 | 269 = 1 | 290 = 3 | 270 = 4293 | 271 = 48 | 269 = 1 | 290 = 4 | 270 = 4294 | 271 = 83 | 269 = 1 | 290 = 5 | 270 = 4295 | 271 = 62 | 269 = 1 | 290 = 6 | 270 = 4296 | 271 = 46 | 269 = 1 | 290 = 7 | 270 = 4297 | 271 = 34 | 269 = 1 | 290 = 8 | 270 = 4298 | 271 = 55 | 269 = 1 | 290 = 9 | 270 = 4299 | 271 = 31 | 269 = 1 | 290 = 10 | 270 = 4300 | 271 = 128 | 269 = 2 | 270 = 4291 | 271 = 1 | 269 = 4 | = 270 4280 | 269 = 7 | 270 = 4292 | 269 = 8 | 270 = 4277 | 10 = 044 |
但是我得到是這樣的:
8 = FIX.4.2 | 9 = 192 | 35 = W | 34 = 2 | 49 = TT_PRICE | 52 = 20170622-14:16: 23.685 | 56 = SAP0094X | 15 = USD | 48 = 00A0HR00GCZ | 55 = GC | 167 = FUT | 200 = 201708 | 207 = CME | 262 = MDRQ-21 | 268 = 25 | 269 = 0 | 270 = 12510 | 271 = 24 | 290 = 1 | 387 = 121890 | 10455 = GCQ7 | 18210 = 1 | 10 = 036 |
正如您所看到的,只有字符串中存在唯一標籤。但是我想要每一個標籤,不管它在提供的字符串中存在多少次。
請任何人都可以幫助我在JAVA中做到這一點。這將是非常可觀的。
下面是我使用的轉換代碼:
MessageUtils mu = new MessageUtils();
Session session = Session.lookupSession(sessionID);
Message msg = MessageUtils.parse(new DefaultMessageFactory(), null, str);
// Message msg = new Message(str, false); //This can also be used for converting
System.out.println(msg.toString());
你可以發佈帶有'SOH'字符的管道符號('|')替換的FIX消息嗎?因爲現在這個信息太難讀取和解釋了(字段分隔符是不可見的)。 –
謝謝。肯定更新。 –