1 package org.oxerr.okcoin.fix;
2
3 import quickfix.field.MDEntryType;
4 import quickfix.field.MDReqID;
5 import quickfix.field.MDUpdateType;
6 import quickfix.field.MarketDepth;
7 import quickfix.field.SubscriptionRequestType;
8 import quickfix.field.Symbol;
9 import quickfix.fix44.MarketDataRequest;
10 import quickfix.fix44.MarketDataRequest.NoMDEntryTypes;
11 import quickfix.fix44.MarketDataRequest.NoRelatedSym;
12
13
14
15
16 public class MarketDataRequestCreator {
17
18 public MarketDataRequestCreator() {
19 }
20
21 public MarketDataRequest createMarketDataRequest(
22 String mdReqId,
23 String symbol,
24 char subscriptionRequestType,
25 int marketDepth,
26 int mdUpdateType,
27 char... mdEntryTypes) {
28 MarketDataRequest message = new MarketDataRequest();
29
30 NoRelatedSym symGroup = new NoRelatedSym();
31 symGroup.set(new Symbol(symbol));
32 message.addGroup(symGroup);
33
34 message.set(new MDReqID(mdReqId));
35 message.set(new SubscriptionRequestType(subscriptionRequestType));
36 message.set(new MarketDepth(marketDepth));
37 message.set(new MDUpdateType(mdUpdateType));
38
39 for (char mdEntryType : mdEntryTypes) {
40 NoMDEntryTypes entryTypesGroup = new NoMDEntryTypes();
41 entryTypesGroup.set(new MDEntryType(mdEntryType));
42 message.addGroup(entryTypesGroup);
43 }
44
45 return message;
46 }
47
48 public MarketDataRequest createOrderBookRequest(
49 String mdReqId,
50 String symbol,
51 char subscriptionRequestType,
52 int marketDepth,
53 int mdUpdateType) {
54 return createMarketDataRequest(
55 mdReqId,
56 symbol,
57 subscriptionRequestType,
58 marketDepth,
59 mdUpdateType,
60 new char[] { MDEntryType.BID, MDEntryType.OFFER, });
61 }
62
63 public MarketDataRequest createLiveTradesRequest(
64 String mdReqId,
65 String symbol) {
66 return createMarketDataRequest(
67 mdReqId,
68 symbol,
69 SubscriptionRequestType.SNAPSHOT,
70 0,
71 MDUpdateType.INCREMENTAL_REFRESH,
72 new char[] { MDEntryType.TRADE, });
73 }
74
75 public MarketDataRequest create24HTickerRequest(
76 String mdReqId,
77 String symbol) {
78 return createMarketDataRequest(
79 mdReqId,
80 symbol,
81 SubscriptionRequestType.SNAPSHOT,
82 0,
83 MDUpdateType.FULL_REFRESH,
84 new char[] {
85 MDEntryType.OPENING_PRICE,
86 MDEntryType.CLOSING_PRICE,
87 MDEntryType.TRADING_SESSION_HIGH_PRICE,
88 MDEntryType.TRADING_SESSION_LOW_PRICE,
89 MDEntryType.TRADING_SESSION_VWAP_PRICE,
90 MDEntryType.TRADE_VOLUME,
91 });
92
93 }
94
95 }