Homework H21

Recommending transactions

Learning Goals

Learning about delta hedging and building an algorithm able to recommend transactions to make a portfolio delta-neutral.

Context

SigmaAndDelta by ChatGPT

“My friend,” Stockton announces, appearing at your desk with unusual solemnity, “it is time.”
You look up. “It is time for what, Mr. Bonds?”
He leans in dramatically. “It is time to infuse some smarts into our Spartan Trader. I feel like Dr. Frankenstein on the eve of the experiment. It will be WONDROUS!”
The imagery is vivid. The requirements, less so.
“Your analogy is truly thrilling, Mr. Bonds,” you say carefully, “what exactly do you have in mind? What kind of 'smarts' would you like me to 'infuse' into the program?”
He smiles broadly. “We shall endow the Spartan Trader with the ability to recommend transactions designed to make our portfolio price neutral.”
That got your attention. “How will we do that?”
Stockton straightens and begins pacing. “Think of our investment portfolio as composed of several families of related securities.”
You nod. “For example, AAPL stock and all options with AAPL as the underlying asset can be viewed as one family.”
“PRECISELY!” he booms. “I want an algorithm that computes the family delta for each family.”
He points emphatically at your screen.
“Then, for each family, the algorithm must recommend a transaction — buy, sell, sell short, or buy back — that brings the resulting family delta as close to neutral as possible.”
“Understood. First, compute family delta. Then identify one transaction that neutralizes the exposure.... but how will the algorithm determine the right transaction if many alternatives are possible?”
“INSIGHTFUL!” Stockton declares. “It must consider all possible transactions.”
“All?”
“ALL.”
He spreads his arms theatrically. “Every candidate action. Every relevant security in the family. Buy stock. Sell stock. Buy calls. Sell calls. Close shorts... the entire opportunity set.”
You nod slowly. “But some transactions won’t be feasible.”
Stockton points at you approvingly. “Of course.” Then he begins counting on his fingers. “Capital account constraints. Margin requirements. Market hours. Option expiration dates. Some trades will be too expensive. Others may simply be unavailable.”
“So,” you say, “the algorithm first generates all candidate trades, then eliminates infeasible ones.”
“MAGNIFICENT!”
You continue. “But what if more than one feasible trade remains?”
Stockton stops pacing. His smile widens. “MOST PERSPICACIOUS!” He lowers his voice. “That is where our secret sauce enters.”
You look up. “We will score each feasible transaction according to our preferences.”
He taps the desk. “Transaction cost. Capital efficiency. Transaction simplicity. Margin consumption. Strategic preference.” He pauses. “The trade with the highest score becomes the recommendation.”
You finish the thought. “And those preferences encode our hedging strategy.”
Stockton grins. “YES! That will be our competitive differentiation.” Then, with theatrical satisfaction: “I am so glad I hired you.”
You look at your notes, already filling with formulas, constraints, and scoring logic.
This is LongShort’s financial strategy translated into code.
This is truly exciting.
“I am on it, Boss.”

Criteria/Requirements

  • Homework is cumulative
  • Uses your TeamID
  • May or may not have updated volatilities in GetVol (ok to put there slightly incorrect ones to keep your 'real' volatilities secret)
  • Generates recommended transactions that hedge all your family portfolios.  *At this point the only recommendations it can generate are about buying and selling stocks* - as a result, many families may not be hedged.
  • Visualizes the recommended transactions, but does not automatically execute them.

Patches

  •  In ScoreBuyingStock, below Dim cRec As New Transaction, add
    cRec.securityType = "Stock"
  • In ScoreSellingStock, below Dim cRec As New Transaction, add
    cRec.securityType = "Stock"

Hints and Tips

  • This homework requires DB access (= you may not use the big Shumway lab and most of RRH 300).