Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Commit

Permalink
Gallery content restructuring
Browse files Browse the repository at this point in the history
  • Loading branch information
HuifangYeo committed Sep 23, 2022
1 parent 2e9aba0 commit 851e007
Show file tree
Hide file tree
Showing 2,093 changed files with 10,521 additions and 8,571 deletions.
864 changes: 456 additions & 408 deletions README.md

Large diffs are not rendered by default.

Binary file added assets/ActiveViam-RVB-150dpi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/Atoti +-RVB.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
398 changes: 398 additions & 0 deletions notebooks/01-use-cases/README.md

Large diffs are not rendered by default.

202 changes: 202 additions & 0 deletions notebooks/01-use-cases/finance/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
<p align="center">
<img src="https://data.atoti.io/notebooks/banners/logo.png" alt="atoti logo">
</p>

<p align="center">
<a href="https://github.com/atoti/atoti/discussions"><img src="https://img.shields.io/github/discussions/atoti/atoti" alt="GitHub Discussion"></a>
<a href="https://hits.seeyoufarm.com"><img src="https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Fatoti%2Fnotebooks&count_bg=%23FF7375&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false" alt="Hits"></a>
<a href="https://stackoverflow.com/questions/tagged/atoti"><img src="https://img.shields.io/badge/StackOverflow-atoti-f58024.svg" alt="stackoverflow"></a>
</p>


## Financial use cases

<ol><li>
<details open>
<summary><b>Front Office</b></summary><blockquote>
<br/>

<table>

<img src="https://data.atoti.io/notebooks/banners/Atoti_plus_RVB_Icon.png" width="15px"/><b> indicates requires Atoti+</b>

<tr>
<td><b>Notebooks</b></td>
<td><b>Related media</b></td>
</tr>
<tr>
<td rowspan="1"><a href="notebooks/01-use-cases/finance/front-office/cumulative-pnl/main.ipynb">&nbsp;cumulative-pnl&nbsp;</a></td>
<td><a href="https://www.atoti.io/articles/dynamic-performance-analytics-handling-of-non-linear-aggregation/?utm_source=github">📰&nbsp;Dynamic Performance Analytics: Handling of non-linear aggregation</a></td>
</tr>
<tr>
<td rowspan="1"><a href="notebooks/01-use-cases/finance/front-office/pnl-explained/main.ipynb">&nbsp;pnl-explained&nbsp;</a></td>
<td><a href="https://www.atoti.io/articles/pnl-explained-with-atoti/?utm_source=github">📰&nbsp;PnL Explained with atoti</a></td>
</tr>
<tr>
<td rowspan="2"><a href="notebooks/01-use-cases/finance/front-office/real-time-risk/main.ipynb">&nbsp;real-time-risk&nbsp;</a></td>
<td><a href="https://www.atoti.io/guides/implementing-real-time-sources-with-atoti/?utm_source=github">📰&nbsp;Implementing real-time sources with atoti</a></td>
</tr>
<tr>
<td valign="center"><a href="https://www.atoti.io/guides/implementing-real-time-sources-with-atoti/?utm_source=github">📰&nbsp;Real-time risk analytics with atoti</a></td>
</tr>
</table>
<br/>
</blockquote></details>

</li><li>
<details open>
<summary><b>Risk Management</b></summary><blockquote>
<br/>

<ul><li>
<details open>
<summary><b>Credit Risk</b></summary><blockquote>
<br/>

<table>

<img src="https://data.atoti.io/notebooks/banners/Atoti_plus_RVB_Icon.png" width="15px"/><b> indicates requires Atoti+</b>

<tr>
<td><b>Notebooks</b></td>
<td><b>Related media</b></td>
</tr>
<tr>
<td rowspan="2"><a href="notebooks/01-use-cases/finance/risk-management/credit-risk/ifrs9/main.ipynb">&nbsp;ifrs9&nbsp;</a></td>
<td><a href="https://www.atoti.io/articles/ifrs-9-data-viz-ecl-pd-analytics-and-the-vintage-matrix/?utm_source=github">📰&nbsp;IFRS 9 Data Viz: ECL, PD Analytics and the Vintage Matrix</a></td>
</tr>
<tr>
<td valign="center"><a href="https://www.atoti.io/articles/tutorial-how-to-build-an-ifrs-9-solution-with-python-and-atoti/?utm_source=github">📰&nbsp;Tutorial: How to build an IFRS 9 solution with Python and atoti</a></td>
</tr>
<tr>
<td rowspan="1"><a href="notebooks/01-use-cases/finance/risk-management/credit-risk/sa-ccr/main.ipynb">&nbsp;sa-ccr&nbsp;</a></td>
<td><a href="https://www.atoti.io/articles/sa-ccr-with-python-and-atoti/?utm_source=github">📰&nbsp;SA-CCR with python and atoti</a></td>
</tr>
<tr>
<td rowspan="1"><a href="notebooks/01-use-cases/finance/risk-management/credit-risk/xva/main.ipynb">&nbsp;xva&nbsp;</a></td>
<td><a href="https://www.atoti.io/articles/interactive-xva-analytics-with-python-and-atoti/?utm_source=github">📰&nbsp;Interactive xVA analytics with Python and atoti</a></td>
</tr>
<tr>
<td rowspan="1"><a href="/notebooks/01-use-cases/finance/treasury/collateral-shortfall-forecast/notebooks/main.ipynb">&nbsp;collateral-shortfall-forecast&nbsp;</a></td>
<td><a href="https://www.atoti.io/articles/collateral-modelling-and-simulation-using-atoti-and-machine-learning/?utm_source=github">📰&nbsp;Collateral Modelling and Simulation Using atoti and Machine Learning</a></td>
</tr>
</table>
<br/>
</blockquote></details>
</li><li>
<details open>
<summary><b>Market Risk</b></summary><blockquote>
<br/>

<table>

<img src="https://data.atoti.io/notebooks/banners/Atoti_plus_RVB_Icon.png" width="15px"/><b> indicates requires Atoti+</b>

<tr>
<td><b>Notebooks</b></td>
<td><b>Related media</b></td>
</tr>
<tr>
<td rowspan="1"><a href="notebooks/01-use-cases/finance/risk-management/market-risk/sbm/main.ipynb">&nbsp;sbm&nbsp;</a></td>
<td><a href="https://www.atoti.io/articles/faster-algorithm-for-frtb-sbm-risk-aggregation/?utm_source=github">📰&nbsp;Faster Algorithm for FRTB SBM Risk Aggregation</a></td>
</tr>
<tr>
<td rowspan="1"><a href="notebooks/01-use-cases/finance/risk-management/market-risk/stressed-var-calibration/main.ipynb">&nbsp;stressed-var-calibration&nbsp;</a></td>
<td><a href="https://www.atoti.io/articles/market-risk-analytics-in-python-interactive-rolling-var/?utm_source=github">📰&nbsp;Market risk analytics in python: Interactive rolling VaR</a></td>
</tr>
<tr>
<td rowspan="1"><a href="notebooks/01-use-cases/finance/front-offices/main.ipynb">&nbsp;pnl-explained&nbsp;</a></td>
<td><a href="https://www.atoti.io/articles/pnl-explained-with-atoti/?utm_source=github">📰&nbsp;PnL Explained with atoti</a></td>
</tr>
<tr>
<td rowspan="1"><a href="notebooks/01-use-cases/finance/risk-management/market-risk/value-at-risk/main.ipynb">&nbsp;value-at-risk&nbsp;</a></td>
<td>&nbsp</td>
</tr>
</table>
<br/>
</blockquote></details>
</li><li>
<details open>
<summary><b>Operational Risk</b></summary><blockquote>
<br/>

<table>

<img src="https://data.atoti.io/notebooks/banners/Atoti_plus_RVB_Icon.png" width="15px"/><b> indicates requires Atoti+</b>

<tr>
<td><b>Notebooks</b></td>
<td><b>Related media</b></td>
</tr>
<tr>
<td rowspan="2"><a href="notebooks/01-use-cases/finance/risk-management/operational-risk/credit-card-fraud-detection/main.ipynb">&nbsp;credit-card-fraud-detection&nbsp;</a></td>
<td><a href="https://www.atoti.io/articles/credit-card-fraud-detection-part1/?utm_source=github">📰&nbsp;Part 1: Investigating fraudulent transactions real-time with atoti</a></td>
</tr>
<tr>
<td valign="center"><a href="https://www.atoti.io/articles/credit-card-fraud-detection-part2//?utm_source=github">📰&nbsp;Part 2: Fraud detection with Faker and PyCaret</a></td>
</tr>
</table>
<br/>
</blockquote></details>
</li>
</ul>
<br/>
</blockquote></details>

</li><li>
<details open>
<summary><b>Treasury</b></summary><blockquote>
<br/>

<table>

<img src="https://data.atoti.io/notebooks/banners/Atoti_plus_RVB_Icon.png" width="15px"/><b> indicates requires Atoti+</b>

<tr>
<td><b>Notebooks</b></td>
<td><b>Related media</b></td>
</tr>
<tr>
<td rowspan="1"><a href="notebooks/01-use-cases/finance/treasury/collateral-shortfall-forecast/main.ipynb">&nbsp;collateral-shortfall-forecast&nbsp;</a></td>
<td><a href="https://www.atoti.io/articles/collateral-modelling-and-simulation-using-atoti-and-machine-learning/?utm_source=github">📰&nbsp;Collateral Modelling and Simulation Using atoti and Machine Learning</a></td>
</tr>
<tr>
<td rowspan="1"><a href="notebooks/01-use-cases/finance/treasury/collateral-shortfall-monitoring/main.ipynb">&nbsp;collateral-shortfall-monitoring&nbsp;</a></td>
<td><a href="https://www.atoti.io/articles/rapid-collateral-modelling-and-simulation-with-atoti/?utm_source=github">📰&nbsp;Rapid collateral modelling and simulation with atoti</a></td>
</tr>
</table>
<br/>
</blockquote></details>

</li><li>
<details open>
<summary><b>Insurance</b></summary><blockquote>
<br/>

<table>

<img src="https://data.atoti.io/notebooks/banners/Atoti_plus_RVB_Icon.png" width="15px"/><b> indicates requires Atoti+</b>

<tr>
<td><b>Notebooks</b></td>
<td><b>Related media</b></td>
</tr>
<tr>
<td rowspan="1"><a href="notebooks/01-use-cases/finance/insurance/customer 360/03-main-csv.ipynb">&nbsp;customer 360&nbsp;</a></td>
<td><a href="https://www.atoti.io/articles/customer-360-how-it-can-be-achieved-with-atoti/?utm_source=github">📰&nbsp;Customer 360: How it can be achieved with atoti</a></td>
</tr>
<tr>
<td rowspan="1"><a href="notebooks/01-use-cases/finance/insurance/price-elasticity/main.ipynb">&nbsp;price-elasticity&nbsp;</a></td>
<td><a href="https://www.atoti.io/articles/unravel-price-elasticity-of-demand-with-atoti/?utm_source=github">📰&nbsp;Unravel price elasticity of demand with atoti</a></td>
</tr>
</table>
<br/>
</blockquote></details>

</li></ol>


<br/>
<p align="center">
Reach out to <a href="https://www.activeviam.com/contact-us/"><img src="https://data.atoti.io/notebooks/banners/ActiveViam-RVB-150dpi.png" alt="atoti logo" width="150px" /></a> for more information.
</p>
Binary file not shown.
44 changes: 44 additions & 0 deletions notebooks/01-use-cases/finance/front-office/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<p align="center">
<img src="https://data.atoti.io/notebooks/banners/logo.png" alt="atoti logo">
</p>

<p align="center">
<a href="https://github.com/atoti/atoti/discussions"><img src="https://img.shields.io/github/discussions/atoti/atoti" alt="GitHub Discussion"></a>
<a href="https://hits.seeyoufarm.com"><img src="https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Fatoti%2Fnotebooks&count_bg=%23FF7375&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false" alt="Hits"></a>
<a href="https://stackoverflow.com/questions/tagged/atoti"><img src="https://img.shields.io/badge/StackOverflow-atoti-f58024.svg" alt="stackoverflow"></a>
</p>


## Financial use cases for Front Office


<table>

<img src="https://data.atoti.io/notebooks/banners/Atoti_plus_RVB_Icon.png" width="15px"/><b> indicates requires Atoti+</b>

<tr>
<td><b>Notebooks</b></td>
<td><b>Related media</b></td>
</tr>
<tr>
<td rowspan="1"><a href="notebooks/01-use-cases/finance/front-office/cumulative-pnl/main.ipynb">&nbsp;cumulative-pnl&nbsp;</a></td>
<td><a href="https://www.atoti.io/articles/dynamic-performance-analytics-handling-of-non-linear-aggregation/?utm_source=github">📰&nbsp;Dynamic Performance Analytics: Handling of non-linear aggregation</a></td>
</tr>
<tr>
<td rowspan="1"><a href="notebooks/01-use-cases/finance/front-office/pnl-explained/main.ipynb">&nbsp;pnl-explained&nbsp;</a></td>
<td><a href="https://www.atoti.io/articles/pnl-explained-with-atoti/?utm_source=github">📰&nbsp;PnL Explained with atoti</a></td>
</tr>
<tr>
<td rowspan="2"><a href="notebooks/01-use-cases/finance/front-office/real-time-risk/main.ipynb">&nbsp;real-time-risk&nbsp;</a></td>
<td><a href="https://www.atoti.io/guides/implementing-real-time-sources-with-atoti/?utm_source=github">📰&nbsp;Implementing real-time sources with atoti</a></td>
</tr>
<tr>
<td valign="center"><a href="https://www.atoti.io/guides/implementing-real-time-sources-with-atoti/?utm_source=github">📰&nbsp;Real-time risk analytics with atoti</a></td>
</tr>
</table>


<br/>
<p align="center">
Reach out to <a href="https://www.activeviam.com/contact-us/"><img src="https://data.atoti.io/notebooks/banners/ActiveViam-RVB-150dpi.png" alt="atoti logo" width="150px" /></a> for more information.
</p>
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
import numpy as np
import QuantLib as ql
import pandas as pd


def reprice_trade(spot_price, trade, calc_date):
# This function takes option trade object and spot prices and computes valuation and risk metrics.
# Volatility and interest rates are set to some constants for simplicity.

calculation_date = ql.Date(calc_date.day, calc_date.month, calc_date.year)
ql.Settings.instance().evaluationDate = calculation_date

# conventions
day_count = ql.Actual365Fixed()
calendar = ql.UnitedStates()
volatility = 0.3
dividend_rate = 0.0163
risk_free_rate = 0.001

maturity = trade["Maturity"]

maturity_date = ql.Date(maturity.day, maturity.month, maturity.year)
option_type = ql.Option.Call if trade.OptionType == "Call" else ql.Option.Put
strike_price = trade.Strike

# construct the European Option
payoff = ql.PlainVanillaPayoff(option_type, strike_price)
exercise = ql.EuropeanExercise(maturity_date)
european_option = ql.VanillaOption(payoff, exercise)

# The Black-Scholes-Merto process is constructed here.
spot_handle = ql.QuoteHandle(ql.SimpleQuote(spot_price))
flat_ts = ql.YieldTermStructureHandle(
ql.FlatForward(calculation_date, risk_free_rate, day_count)
)
dividend_yield = ql.YieldTermStructureHandle(
ql.FlatForward(calculation_date, dividend_rate, day_count)
)
flat_vol_ts = ql.BlackVolTermStructureHandle(
ql.BlackConstantVol(calculation_date, calendar, volatility, day_count)
)
bsm_process = ql.BlackScholesMertonProcess(
spot_handle, dividend_yield, flat_ts, flat_vol_ts
)

european_option.setPricingEngine(ql.AnalyticEuropeanEngine(bsm_process))

return {
"AsOfDate": calc_date.strftime("%Y-%m-%d"),
"TradeId": trade["TradeId"],
"RiskFactor": trade["Ticker"],
"MarketValue": european_option.NPV(),
"Delta": european_option.delta() * spot_price * trade["Quantity"],
}


def reprice_portfolio(market_data, positions, calc_date):
# This function reprices trades and greeks if market data is available,
# and returns new risk numbers as a dataframe
risk = []
for i, trade in positions.iterrows():
spot_price_update = market_data[trade["Ticker"]]
if not np.isnan(spot_price_update):
risk = risk + [reprice_trade(spot_price_update, trade, calc_date)]
return pd.DataFrame(data=risk)
import numpy as np
import QuantLib as ql
import pandas as pd


def reprice_trade(spot_price, trade, calc_date):
# This function takes option trade object and spot prices and computes valuation and risk metrics.
# Volatility and interest rates are set to some constants for simplicity.

calculation_date = ql.Date(calc_date.day, calc_date.month, calc_date.year)
ql.Settings.instance().evaluationDate = calculation_date

# conventions
day_count = ql.Actual365Fixed()
calendar = ql.UnitedStates()
volatility = 0.3
dividend_rate = 0.0163
risk_free_rate = 0.001

maturity = trade["Maturity"]

maturity_date = ql.Date(maturity.day, maturity.month, maturity.year)
option_type = ql.Option.Call if trade.OptionType == "Call" else ql.Option.Put
strike_price = trade.Strike

# construct the European Option
payoff = ql.PlainVanillaPayoff(option_type, strike_price)
exercise = ql.EuropeanExercise(maturity_date)
european_option = ql.VanillaOption(payoff, exercise)

# The Black-Scholes-Merto process is constructed here.
spot_handle = ql.QuoteHandle(ql.SimpleQuote(spot_price))
flat_ts = ql.YieldTermStructureHandle(
ql.FlatForward(calculation_date, risk_free_rate, day_count)
)
dividend_yield = ql.YieldTermStructureHandle(
ql.FlatForward(calculation_date, dividend_rate, day_count)
)
flat_vol_ts = ql.BlackVolTermStructureHandle(
ql.BlackConstantVol(calculation_date, calendar, volatility, day_count)
)
bsm_process = ql.BlackScholesMertonProcess(
spot_handle, dividend_yield, flat_ts, flat_vol_ts
)

european_option.setPricingEngine(ql.AnalyticEuropeanEngine(bsm_process))

return {
"AsOfDate": calc_date.strftime("%Y-%m-%d"),
"TradeId": trade["TradeId"],
"RiskFactor": trade["Ticker"],
"MarketValue": european_option.NPV(),
"Delta": european_option.delta() * spot_price * trade["Quantity"],
}


def reprice_portfolio(market_data, positions, calc_date):
# This function reprices trades and greeks if market data is available,
# and returns new risk numbers as a dataframe
risk = []
for i, trade in positions.iterrows():
spot_price_update = market_data[trade["Ticker"]]
if not np.isnan(spot_price_update):
risk = risk + [reprice_trade(spot_price_update, trade, calc_date)]
return pd.DataFrame(data=risk)
Loading

0 comments on commit 851e007

Please sign in to comment.