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

Added monte carlo engine #9

Merged
merged 4 commits into from
Oct 22, 2023
Merged

Added monte carlo engine #9

merged 4 commits into from
Oct 22, 2023

Conversation

nrupprecht
Copy link
Collaborator

Added some support for monte carlo.

  • Added StochasicProcess as the base class for (loosely speaking) things that can be evolved by the monte carlo engine.
  • Added a StochasticProcesse that wraps around existing Diffusion1Ds, added BlackScholes and Heston specific stochastic processes.
  • Created MonteCarloEngine, which generates the random variables, evolves the states of the stochastic process it manages, manages the trajectories, etc.
  • Added unit tests showing how to price some simple options using different types of stochastic processes.
  • Created the AdditionalState class to allow additional data to be tracked during the monte carlo, e.g. the maximum so far, whether a barrier has been crossed by some state variable, realized var, maximum return, etc.

Current limitations:

  • The monte carlo engine takes a single stochastic process. This process can have a state of arbitrary size, and can need an arbitrary number of random variable inputs, but all correlations would currently be internal to the stochastic process. This may not be a real flaw, perhaps the right thing to do is always to just have the MC generate uncorrelated random variables of different types, and the model layer determine what the separate pieces of the model are, and how to correlate them.
  • It would be ideal to have some abstraction of "instruments that are priceable via monte carlo" and to incorporate the behavior of StochasticProcess more deeply into the existing framework.

…rajectory pricers, a class to adapt any Diffusion1D into a stochastic pricer, and some other smaller supporting things
… state more fully into MC engine, added unit tests
@nrupprecht nrupprecht added the enhancement New feature or request label Oct 17, 2023
@nrupprecht nrupprecht requested a review from jkirkby3 October 17, 2023 01:52
@nrupprecht nrupprecht self-assigned this Oct 17, 2023
"""

def __init__(self, r: float, sigma: float):
self._r = r
Copy link
Owner

Choose a reason for hiding this comment

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

We should have a parameter mu which describes the drift rate, and mu = r - q (r = interest rate, q = div yield)

pass

def evolve(self, state: np.array, t0: float, t1: float, N: int, dZ: np.array):
"""
Copy link
Owner

Choose a reason for hiding this comment

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

np.ndarray instead of np.array?

@jkirkby3 jkirkby3 merged commit e0eb3e6 into master Oct 22, 2023
6 checks passed
@nrupprecht nrupprecht deleted the monte-carlo branch October 25, 2023 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants