Computers and Technology

Divergence Monitor Many automated trading systems continuously consume market data, then react when certain specific conditions are met. One such interesting condition occurs when the prices of two highly- correlated stocks diverge. In this exercise, you will implement part of a system that monitors for instances where the prices of two such stocks drift apart. You are provided with a skeleton implementation of the Price Divergence Monitor class. • The constructor takes in a threshold. • The method RegisterPair will be called by the owner of this class each time it wants your class to start monitoring a new pair of correlated stocks. o Multiple pairs can (and will be registered -- you need to continue to monitor all registered pairs. • The method UpdatePrice will be called by the owner of this class whenever the price of a stock changes. o When the price of a stock that is part of a registered pair changes, you should check whether that new price differs from the price of the other stock in the pair by more than the threshold. If it does, you should call the Report Divergence method of your class, which has already been implemented for you. Clarifications: • Differences of exactly the threshold should not be reported. • If you have not yet received a price for a product, you should not report a divergence. • If the same pair is registered multiple times, ignore the duplicates. Tip: Use print statements to view input for test cases, and use custom input to test your code! 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 12 13 using namespace std; 14 15 16 int timestamp = 0; 17 vector eventOutput; 18 19 20 class PriceDivergenceMonitor 21 { 22 public: 23 PriceDivergence Monitor (int threshold); 24 void Register Pair(const string& stockOne, const string& stockTwo); 25 void UpdatePrice (const string& stockName, int newPrice); 26 private: 27 void ReportDivergence (const string& updatedStockName, int updatedStockPrice, const string& otherStockName, int other StockPrice); 28 // todo: add member variables, if needed 29 30 }; 31 32 33 PriceDivergenceMonitor::PriceDiverg enceMonitor(int threshold) 34 { 35 // todo: complete this constructor as needed 36 } 37 38 39 40 /* The method Register Pair will be called by the owner of this class each time it wants your class to start monitoring a new pair of correlated stocks. */ void PriceDivergenceMonitor:: Register Pair(const string& stockOne, const string& stockTwo) { // todo: complete this method } 41 42 43 44 45 46 47 48 49 The method UpdatePrice will be called by the owner of this class whenever the price of a stock changes. When the price of a stock that is part of a registered pair changes, you should check whether that new price differs from the price of the other stock in the pair by more than the threshold. If it does, call the ReportDivergence method with the appropriate parameters. */ void PriceDivergenceMonitor:: UpdatePrice (const string& stockName, int newPrice) { // todo: complete this method } void PriceDivergence Monitor::ReportDivergence (const string& updatedStockName, int updatedStockPrice, const string& > otherStockName, int otherStockPrice)... 50 51 52 53

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 07:00, bskyeb14579
Why is investing in a mutual fund less risky than investing in a particular company's stock? a. mutual funds only invest in blue-chip stocks. b. investments in mutual funds are more liquid. c. mutual funds hold a diversified portfolio of stocks. d. investments in mutual funds offer a higher rate of return.
Answers: 2
image
Computers and Technology, 23.06.2019 23:00, Maya629277
Lucas put a lot of thought into the design for his company's new white paper. he made sure to include repeating design elements such as color schemes and decorative images. his goal was to a. add symmetry b. create a unified publication c. provide consistency d. save money
Answers: 1
image
Computers and Technology, 24.06.2019 00:50, JakeCline
Which of the following is not a key player in the sale of travel products?
Answers: 2
image
Computers and Technology, 24.06.2019 08:10, anthonysutton82
Where are american poets found in the dewey decimal system
Answers: 1
Do you know the correct answer?
Divergence Monitor Many automated trading systems continuously consume market data, then react when...

Questions in other subjects:

Konu
Mathematics, 30.03.2020 16:23
Konu
Mathematics, 30.03.2020 16:26