Create a new function called classifyTrades
which takes a table that has columns price
,
side
, bid
and ask
(like tradeContext
for example) and returns that table with a new column
called exQuality
. The exQuality
column stores either good (1b
) or bad (0b
) (as boolean values)
depending on the price
, side
, bid
and ask
prices.
Help me with this.
Hi @Shreya_Deshpande,
Within section 3 of the capstone project, there is an explanation of Quality of Execution - what makes a “good” or “bad” trade:
A common area of focus when trading is ensuring “best execution” was received on all trades. This involves checking to see if you got the best possible price on the market for each of the trades.
The nbbo table contains the best bid and best offer quotes available on all the exchanges for every option. This is the data we will use to check our trade price.
In the case of a purchase (side = B), our price should be less than or equal to the best ask
price in the market, otherwise we could have bought it at a lower price on the market. Similarly, If we are selling (side = S), our price should be greater than or equal to the best bid on the market, or else we could have sold it for more on the market at that time.
Examples:
We make a buy trade for 50$ at 10am, when the market best ask was 55$ - Good Trade
We make a buy trade for 60$ at 10am, when the market best ask was 55$ - Bad Trade
We make a sell trade for 50$ at 10am, when the market best bid was 45$ - Good Trade
We make a sell trade for 40$ at 10am, when the market best bid was 45$ - Bad Trade
So exercise 3.2 is asking you to create a function that will determine if the trade is good or bad and add it to the table as a 1b or 0b respectively.
Let me know if you need any more help,
Laura