Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor option greeks feature #2266

Merged
merged 1 commit into from
Feb 1, 2025

Conversation

faysou
Copy link
Collaborator

@faysou faysou commented Jan 29, 2025

Pull Request

Refactor option greeks feature

  • integrate option greeks calculation method in actor so calculations can be done synchronously in a strategy
  • maintained ability to publish greeks, store them in a catalog and load them from a catalog
  • added helper function for subscribing to greeks so a callback stores cached greeks loaded from a catalog
  • improved example so it doesn't need a delay to wait for loaded greeks when subscribing to them from a catalog, the trick is to add the greeks backtestdataconfig before other types of market data so it reaches actors before.
  • ability to compute shocked greeks and prices by shifting spot, vol, or time to expiry, this allows to have estimate of how portfolio greeks could evolve by varying the relevant market data variables. taking into account Futures correctly for this.
  • the reason to have the greeks functionality in actor, is that any subclass of actor, for example a class responsible for monitoring greeks, can easily access the functionality
  • added price field to PortfolioGreeks
  • Removed InterateRateData, keeping only InterestRateCurveData
  • InterestRateProvider caches InterestRateCurveData so it's then accessible the greeks computation function
  • Fixed a bug in the cache when using price with bars
  • Added GreeksCalculator class for greeks related function, accessible via actor.greeks.portfolio_greeks for example

Type of changs

  • New feature (non-breaking change which adds functionality)

How has this change been tested?

Tested using databento_option_greeks.py notebook, updated

@faysou faysou force-pushed the optionrefactor branch 2 times, most recently from d2e1fc4 to a905955 Compare January 29, 2025 22:15
Copy link
Member

@cjdsellers cjdsellers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good change moving greeks.py from risk to model.

I'm still unsure if actor is the right location for greeks calculations though, as this makes every actor a specialized greeks calculator too.

nautilus_trader/common/actor.pyx Outdated Show resolved Hide resolved
@faysou faysou force-pushed the optionrefactor branch 5 times, most recently from f8ccd01 to c9b3247 Compare January 30, 2025 21:45
Copy link
Member

@cjdsellers cjdsellers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @faysou this is nicely done.

nautilus_trader/cache/cache.pyx Outdated Show resolved Hide resolved
nautilus_trader/common/actor.pyx Outdated Show resolved Hide resolved
nautilus_trader/risk/greeks.pyx Outdated Show resolved Hide resolved
@faysou faysou force-pushed the optionrefactor branch 2 times, most recently from 5357c4b to 7c0ffd6 Compare January 31, 2025 11:51
@faysou
Copy link
Collaborator Author

faysou commented Jan 31, 2025

I'm done with the changes mentioned above.

@cjdsellers cjdsellers merged commit e25786e into nautechsystems:develop Feb 1, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants