Skip to content

Implement Gamma Exposure (GEX) Calculation and Curve Representation #134

@joaquinbejar

Description

@joaquinbejar

Implement the Gamma Exposure (GEX) calculation for the option chain, along with a method to return a Curve representation of GEX. GEX represents the second-order price risk in the options market and is crucial for understanding potential market stability or instability.

The GEX calculation should:

  • Consider both call and put options.
  • Handle both long and short positions.
  • Apply the appropriate contract multiplier.
  • Aggregate results by strike price.
  • Compute interpolated gamma exposure at the current spot price (spot GEX).
  • Provide a Curve representation for visualization and analysis.

Tasks

Implementation:

  • Create a structure to hold GEX-related data, including total GEX, exposure by strike, and interpolated spot GEX.
  • Implement a method to calculate GEX by iterating through the option chain, computing values for each position, and aggregating results by strike price.
  • Implement interpolation to estimate the gamma exposure at the current spot price.
  • Implement a method to transform the aggregated GEX data into a Curve representation, ensuring it captures key strike price points and their corresponding exposures.

Testing:

  • Write unit tests to validate the correctness of GEX calculations across different market conditions.
  • Include edge cases such as:
    • High and low volatility.
    • Strike prices very close to or far from the spot.
    • Long and short positions.
    • Effects of different contract multipliers.
    • Ensuring the curve representation properly handles empty or irregular data points.

Documentation:

  • Document the structure and methods related to GEX calculations.
  • Explain the purpose and expected output of the curve representation.
  • Provide usage examples demonstrating how to use the implemented methods.

Additional Notes

  • The implementation should prioritize accuracy and computational efficiency.
  • Ensure compatibility with the existing options system architecture.
  • The Curve representation will be useful for visualizing GEX changes across different strike prices.

Labels

enhancement, greeks, options-trading, visualization, testing, documentation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions