Trade Blotter Summary by Ticker
Updated
Problem statement
A trading desk keeps a blotter of the day's stock trades in the trades table. Each row is one trade: the stock's ticker, its direction ('B' for a buy, 'S' for a sell), the number of shares in quantity and the price per share in price.
Return one row for every ticker in the table, with these columns:
tickerbuy_trades: the number of buy trades in that ticker.sell_trades: the number of sell trades in that ticker.total_shares: the total number of shares traded in that ticker, buys and sells together.buy_value: the total market value of the buys, which is the sum ofquantity * priceover the buy trades. It is0when the ticker has no buys.buy_vwap: the volume-weighted average price of the buys, which isbuy_valuedivided by the number of shares bought. It isNULL(Nonein Pandas) when the ticker has no buys.
Return the rows in any order. A decimal answer is accepted when it is within 0.0001 of the exact value.
Table schema
MySQLPostgreSQLPandas
Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.
trades
One row per trade on the desk's blotter.
| Column | Type | Nullable | Description |
|---|---|---|---|
| trade_idPK | Integer | No | Unique trade ID. |
| ticker | Text | No | Stock ticker, for example 'MSFT US'. |
| direction | Text | No | 'B' for a buy, 'S' for a sell. |
| quantity | Integer | No | Number of shares traded. |
| price | Decimal | No | Price per share. |
Expected result
Your query or function must return these columns.
| Column | Type | Nullable | Description |
|---|---|---|---|
| ticker | Text | No | — |
| buy_trades | Integer | No | — |
| sell_trades | Integer | No | — |
| total_shares | Integer | No | — |
| buy_value | Decimal | No | — |
| buy_vwap | Decimal | Yes | — |
Row order: any order is accepted. Numeric tolerance: 0.0001.
Constraints
- The
tradestable has between1and1000rows. trade_idvalues are unique.tickerhas 1 to 10 characters: uppercase English letters, digits and spaces.directionis'B'or'S'.1 <= quantity <= 100000 < price <= 1000, with at most 4 digits after the decimal point.
More Jane Street interview questions
- Product Profit SummaryOA · Seen Sep 2026
- Cheating CodemakerOA · Seen Mar 2026
- Bond Haircut by Ratings and MaturityOA · Seen Aug 2024
- Currency Haircut with FX ForwardsOA · Seen Aug 2024
- Transform StringOA · Seen Jul 2024
- Price Deviation AlertsOA · Seen Nov 2023
- Biggest Daily Move and Longest Rising StreakOA · ONSITE INTERVIEW · Seen Apr 2021
- Transaction Fees by InstrumentOA · Seen Mar 2018
- Maximum-Scoring Consecutive Tree LevelsPHONE SCREEN · Seen Nov 2026
- Tree Selection and VisibilityPHONE SCREEN · Seen Nov 2026
Similar questions at other companies
- Students Scoring Above AverageCapstone Investment Advisors · OA
- Bond Interest Summary Above 3%Wells Fargo · OAWells Fargo interview questions
- Employee Promotion OpportunitiesIntuit · OAIntuit interview questions
- Students and Their SubjectsBirla Pivot · OA
- Companies with Average Salary Above 40000AT&T · OAAT&T interview questions
- Build Taxi Driver Performance FeaturesBoston Consulting Group · OABoston Consulting Group interview questions
- Weekend Appointments for Consular Services ReschedulingMcKinsey & Company · OAMcKinsey & Company interview questions
- Companies Above a Salary ThresholdVerisk · OA
- Customer Resource Usage AnalysisIBM · OAIBM interview questions
- Customers Who Never OrderedAccenture · OAAccenture interview questions