Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Assume that every order is successfully executed. Complete the following function in the code editor to determine the profit and / or loss for the
Assume that every order is successfully executed. Complete the following function in the code editor to determine the profit andor loss for the Komodo Dragon Tradin each stock that it either bought or sold over the course of the trading day.
I Cparam initialprice The price of all stocks at the beginning of the day, before any price updates are published.
eparam orders The sequence of buy and sell orders to be executed.
I eparam feed The exchange feed of price updates to various stocks.
epre ep initialprice
I epre ep orders is not empty, and is sorted in ascending order by timestamp.
I epre ep feed is not empty, and is sorted in ascending order by timestamp.
I epre ep The set of all timestamps among orders in ep orders and price updates in ep feed contains no duplicates.
I ereturns A collection see below with the endofday profits and losses of each stock for which at least one order
II was executed. Stocks for which a price update was published but no orders were executed should be excluded from the
III return value.
auto profitsAndLosses int initialPrice, const std: :vectorrder &orders, const std:vectorapnl
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started