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

First cut of geometric asian pricer #82

Merged
merged 1 commit into from
Dec 8, 2022

Conversation

jackgillett101
Copy link
Contributor

Geometric asian option pricer under black scholes, this pricer transforms the asian problem into an equivalent vanilla problem and uses the vanilla pricer to price.

Affects this issue: #56

@google-cla
Copy link

google-cla bot commented Nov 28, 2022

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Contributor

@cyrilchim cyrilchim left a comment

Choose a reason for hiding this comment

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

Thank you! This is a very nice contributions. Just a bunch of minor comments

tf_quant_finance/black_scholes/asian_prices.py Outdated Show resolved Hide resolved
tf_quant_finance/black_scholes/asian_prices.py Outdated Show resolved Hide resolved
tf_quant_finance/black_scholes/asian_prices.py Outdated Show resolved Hide resolved
Comment on lines 199 to 200
t2 = tf.reduce_sum(tf.map_fn(lambda x: tf.minimum(*tf.meshgrid(x, tf.transpose(x))),
tf.transpose(sampling_times)), [1,2]) / sample_count**2
Copy link
Contributor

Choose a reason for hiding this comment

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

here use tf.vectorized_map and set fallback_to_while_loop to False. This should automatically vectorize what you want to do and provide significant speed up on a GPU device

Copy link
Contributor

Choose a reason for hiding this comment

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

also, could you please add a comment explaining what is achieved here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to vectorized_map

I've added an explanation comment above - let me know if this works or if you have a standard way of formatting math comments.

tf_quant_finance/black_scholes/asian_prices.py Outdated Show resolved Hide resolved
tf_quant_finance/black_scholes/asian_prices_test.py Outdated Show resolved Hide resolved
Copy link
Contributor

@cyrilchim cyrilchim left a comment

Choose a reason for hiding this comment

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

Thank you! Could you please squash the commits so I can push to the library.

tf_quant_finance/black_scholes/asian_prices.py Outdated Show resolved Hide resolved
First cut of geometric asian pricer

Code review updates
@cyrilchim
Copy link
Contributor

Thanks @jackgillett101 This is now submitted!

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.

3 participants