Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jialuechen committed Aug 11, 2024
1 parent 18fbdf3 commit 7ab949f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 19 deletions.
46 changes: 27 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,24 @@ pip install tfq-finance

## Usage (check out more in the examples folder)

### Example: Option Pricing
### Example: Barrier Option Pricing

```python
from tfq_finance.pricing.equity.option_pricing import price_option
from tfq_finance.pricing.exotic.exotic_option_pricing import price_barrier_option

spot_price = 100
strike_price = 105
time_to_maturity = 1
volatility = 0.2
risk_free_rate = 0.05
def barrier_option_pricing_example():
spot_price = 100
strike_price = 105
barrier_level = 110
time_to_maturity = 1
volatility = 0.2
risk_free_rate = 0.05

option_price = price_option(spot_price, strike_price, time_to_maturity, volatility, risk_free_rate)
print("Option Price:", option_price)
barrier_option_price = price_barrier_option(spot_price, strike_price, barrier_level, time_to_maturity, volatility, risk_free_rate)
print("Barrier Option Price:", barrier_option_price)

if __name__ == "__main__":
barrier_option_pricing_example()
```

### Example: Portfolio Optimization
Expand Down Expand Up @@ -130,19 +135,22 @@ liquidity_plan = manage_liquidity(cash_flows, liquidity_needs)
print("Liquidity Management Plan:", liquidity_plan)
```

### Example: Exotic Option Pricing

### Example: Variance Swap Pricing
```python
from tfq_finance.pricing.exotic.exotic_option_pricing import price_exotic_option
from tfq_finance.pricing.equity.variance_swap_pricing import price_variance_swap

spot_price = 100
strike_price = 105
time_to_maturity = 1
volatility = 0.2
risk_free_rate = 0.05
def variance_swap_pricing_example():
spot_price = 100
strike_price = 105
time_to_maturity = 1
volatility = 0.2
risk_free_rate = 0.05

variance_swap_price = price_variance_swap(spot_price, strike_price, time_to_maturity, volatility, risk_free_rate)
print("Variance Swap Price:", variance_swap_price)

exotic_option_price = price_exotic_option(spot_price, strike_price, time_to_maturity, volatility, risk_free_rate)
print("Exotic Option Price:", exotic_option_price)
if __name__ == "__main__":
variance_swap_pricing_example()
```

### Example: Spread Option Pricing
Expand Down
8 changes: 8 additions & 0 deletions examples/quantum_regression_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import numpy as np
from tfq_finance.ml.quantum_regression import train_quantum_regression_model

train_data = np.random.randn(100, 4)
train_labels = np.random.randn(100)

model = train_quantum_regression_model(train_data, train_labels)
print("Quantum Regression Model Trained")

0 comments on commit 7ab949f

Please sign in to comment.