| 1 | /* |
| 2 | * Legal Notice |
| 3 | * |
| 4 | * This document and associated source code (the "Work") is a part of a |
| 5 | * benchmark specification maintained by the TPC. |
| 6 | * |
| 7 | * The TPC reserves all right, title, and interest to the Work as provided |
| 8 | * under U.S. and international laws, including without limitation all patent |
| 9 | * and trademark rights therein. |
| 10 | * |
| 11 | * No Warranty |
| 12 | * |
| 13 | * 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION |
| 14 | * CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE |
| 15 | * AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER |
| 16 | * WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY, |
| 17 | * INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES, |
| 18 | * DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR |
| 19 | * PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF |
| 20 | * WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE. |
| 21 | * ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT, |
| 22 | * QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT |
| 23 | * WITH REGARD TO THE WORK. |
| 24 | * 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO |
| 25 | * ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE |
| 26 | * COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS |
| 27 | * OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT, |
| 28 | * INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY, |
| 29 | * OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT |
| 30 | * RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD |
| 31 | * ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. |
| 32 | * |
| 33 | * Contributors |
| 34 | * - Doug Johnson |
| 35 | */ |
| 36 | |
| 37 | /****************************************************************************** |
| 38 | * Description: Class that implements the ticker tape functionality of |
| 39 | * the market. This class handles the batching up of |
| 40 | * individual ticker entries into a batch suitable for the |
| 41 | * Market-Feed transaction. For each "real" trade result |
| 42 | * that gets added to the ticker, a number of artificial |
| 43 | * entries are padded into the batch. |
| 44 | ******************************************************************************/ |
| 45 | |
| 46 | #ifndef MEE_TICKER_TAPE_H |
| 47 | #define MEE_TICKER_TAPE_H |
| 48 | |
| 49 | #include "utilities/EGenUtilities_stdafx.h" |
| 50 | #include "TxnHarnessStructs.h" |
| 51 | #include "TimerWheel.h" |
| 52 | #include "MEESUTInterface.h" |
| 53 | #include "MEEPriceBoard.h" |
| 54 | |
| 55 | #include "input/DataFileTypes.h" |
| 56 | |
| 57 | namespace TPCE { |
| 58 | |
| 59 | class CMEETickerTape { |
| 60 | private: |
| 61 | CMEESUTInterface *m_pSUT; |
| 62 | CMEEPriceBoard *m_pPriceBoard; |
| 63 | TMarketFeedTxnInput m_TxnInput; |
| 64 | INT32 m_BatchIndex; |
| 65 | INT32 m_BatchDuplicates; |
| 66 | CRandom m_rnd; |
| 67 | bool m_Enabled; |
| 68 | const StatusTypeDataFile_t &m_StatusType; |
| 69 | const TradeTypeDataFile_t &m_TradeType; |
| 70 | |
| 71 | static const int LIMIT_TRIGGER_TRADE_QTY; |
| 72 | static const int RANDOM_TRADE_QTY_1; |
| 73 | static const int RANDOM_TRADE_QTY_2; |
| 74 | |
| 75 | CTimerWheel<TTickerEntry, CMEETickerTape, 900, 1000> m_LimitOrderTimers; // Size wheel for 900 seconds with 1,000 |
| 76 | // millisecond resolution. |
| 77 | queue<PTickerEntry> m_InTheMoneyLimitOrderQ; |
| 78 | |
| 79 | CDateTime *m_pBaseTime; |
| 80 | CDateTime *m_pCurrentTime; |
| 81 | |
| 82 | void AddToBatch(PTickerEntry pTickerEntry); |
| 83 | void AddArtificialEntries(void); |
| 84 | void AddLimitTrigger(PTickerEntry pTickerEntry); |
| 85 | |
| 86 | // Performs initialization common to all constructors. |
| 87 | void Initialize(void); |
| 88 | |
| 89 | public: |
| 90 | // Constructor - use default RNG seed |
| 91 | CMEETickerTape(CMEESUTInterface *pSUT, CMEEPriceBoard *pPriceBoard, CDateTime *pBaseTime, CDateTime *pCurrentTime, |
| 92 | const DataFileManager &inputFiles); |
| 93 | |
| 94 | // Constructor - RNG seed provided |
| 95 | CMEETickerTape(CMEESUTInterface *pSUT, CMEEPriceBoard *pPriceBoard, CDateTime *pBaseTime, CDateTime *pCurrentTime, |
| 96 | RNGSEED RNGSeed, const DataFileManager &inputFiles); |
| 97 | |
| 98 | ~CMEETickerTape(void); |
| 99 | |
| 100 | void AddEntry(PTickerEntry pTickerEntry); |
| 101 | void PostLimitOrder(PTradeRequest pTradeRequest); |
| 102 | bool DisableTicker(void); |
| 103 | bool EnableTicker(void); |
| 104 | eTradeTypeID ConvertTradeTypeIdToEnum(char *pTradeType); |
| 105 | |
| 106 | RNGSEED GetRNGSeed(void); |
| 107 | void SetRNGSeed(RNGSEED RNGSeed); |
| 108 | }; |
| 109 | |
| 110 | } // namespace TPCE |
| 111 | |
| 112 | #endif // MEE_TICKER_TAPE_H |
| 113 | |