subject

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

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:00
Ihave an iphone 8plus should i get another phone like samsung note 9 or s9 ? ?
Answers: 2
question
Computers and Technology, 22.06.2019 22:00
What is the name of the option in most presentation applications with which you can modify slide elements? 1. the option enables you to modify a slide element in most presentation applications.
Answers: 3
question
Computers and Technology, 24.06.2019 00:10
Read each statement below. if the statement describes a peer-to-peer network, put a p next to it. if the statement describes a server-based network, put an s next to it. p - peer-to-peer s - server-based
Answers: 1
question
Computers and Technology, 25.06.2019 01:00
When a new name is registered on the internet, the process can take two hours to four hours four hours to three days two hours to two days one hour to eight hours
Answers: 1
You know the right answer?
Divergence Monitor Many automated trading systems continuously consume market data, then react when...
Questions
question
Computers and Technology, 19.10.2019 05:30
Questions on the website: 13722360