Answered step by step
Verified Expert Solution
Link Copied!

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 and/or 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 1.
/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 end-of-day 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: :vector0rder> &orders, const std:vector=[a,b]==apnl=b
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design For Mere Mortals

Authors: Michael J Hernandez

4th Edition

978-0136788041

More Books

Students also viewed these Databases questions