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: Implemenation of the MEEPriceBoard class. |
39 | * See MEEPriceBoad.h for a description. |
40 | ******************************************************************************/ |
41 | |
42 | #include "main/MEEPriceBoard.h" |
43 | |
44 | using namespace TPCE; |
45 | |
46 | CMEEPriceBoard::CMEEPriceBoard(INT32 TradingTimeSoFar, CDateTime *pBaseTime, CDateTime *pCurrentTime, |
47 | const DataFileManager &dfm) |
48 | : m_fMeanInTheMoneySubmissionDelay(1.0), m_Security(), m_SecurityFile(dfm.SecurityFile()), |
49 | m_iNumberOfSecurities(0) { |
50 | // Number of securities is based on "active" customers, as per sub-committee |
51 | // decision to have a scaled-down database look as much as possible as the |
52 | // smaller database. |
53 | |
54 | // Note that this decision will ensure that some percentage of Trade-Order |
55 | // transactions will *not* be subject to lock contention when accessing the |
56 | // LAST_TRADE table, since they are "outside" of the active range that is |
57 | // updated by the MEE via the Market-Feed transaction. This may provide an |
58 | // incentive for sponsors to over-build and under-scale at run-time, to the |
59 | // detriment of the benchmark. If this is the case, then we should require |
60 | // the MEE to run using "configured" securities. |
61 | |
62 | m_iNumberOfSecurities = m_SecurityFile.GetActiveSecurityCount(); |
63 | m_Security.Init(TradingTimeSoFar, pBaseTime, pCurrentTime, m_fMeanInTheMoneySubmissionDelay); |
64 | m_SecurityFile.LoadSymbolToIdMap(); |
65 | } |
66 | |
67 | CMEEPriceBoard::~CMEEPriceBoard(void) { |
68 | } |
69 | |
70 | void CMEEPriceBoard::GetSymbol(TIdent SecurityIndex, |
71 | char *szOutput, // output buffer |
72 | size_t iOutputLen) // size of the output buffer (including null)); |
73 | { |
74 | return (m_SecurityFile.CreateSymbol(SecurityIndex, szOutput, iOutputLen)); |
75 | } |
76 | |
77 | CMoney CMEEPriceBoard::GetMinPrice() { |
78 | return (m_Security.GetMinPrice()); |
79 | } |
80 | |
81 | CMoney CMEEPriceBoard::GetMaxPrice() { |
82 | return (m_Security.GetMaxPrice()); |
83 | } |
84 | |
85 | CMoney CMEEPriceBoard::GetCurrentPrice(TIdent SecurityIndex) { |
86 | return (m_Security.GetCurrentPrice(SecurityIndex)); |
87 | } |
88 | |
89 | CMoney CMEEPriceBoard::GetCurrentPrice(char *pSecuritySymbol) { |
90 | return (m_Security.GetCurrentPrice(m_SecurityFile.GetIndex(pSecuritySymbol))); |
91 | } |
92 | |
93 | CMoney CMEEPriceBoard::CalculatePrice(char *pSecuritySymbol, double fTime) { |
94 | return (m_Security.CalculatePrice(m_SecurityFile.GetIndex(pSecuritySymbol), fTime)); |
95 | } |
96 | |
97 | double CMEEPriceBoard::GetSubmissionTime(char *pSecuritySymbol, double fPendingTime, CMoney fLimitPrice, |
98 | eTradeTypeID TradeType) { |
99 | return ( |
100 | m_Security.GetSubmissionTime(m_SecurityFile.GetIndex(pSecuritySymbol), fPendingTime, fLimitPrice, TradeType)); |
101 | } |
102 | |
103 | double CMEEPriceBoard::GetSubmissionTime(TIdent SecurityIndex, double fPendingTime, CMoney fLimitPrice, |
104 | eTradeTypeID TradeType) { |
105 | return (m_Security.GetSubmissionTime(SecurityIndex, fPendingTime, fLimitPrice, TradeType)); |
106 | } |
107 | |
108 | double CMEEPriceBoard::GetCompletionTime(TIdent SecurityIndex, double fSubmissionTime, |
109 | CMoney *pCompletionPrice // output parameter |
110 | ) { |
111 | return (m_Security.GetCompletionTime(SecurityIndex, fSubmissionTime, pCompletionPrice)); |
112 | } |
113 | |