Skip to content

Commit

Permalink
Upgraded to FinancePy 0.310
Browse files Browse the repository at this point in the history
  • Loading branch information
saeedamen committed Jan 1, 2024
1 parent 7af86b6 commit fa76439
Show file tree
Hide file tree
Showing 20 changed files with 2,419 additions and 1,480 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ One possible way to fix this is to delete the `__pycache__` folders underneath w
Eg. if you are using the `py38class` environment, if you've installed Anaconda in `C:\Anaconda3`, you might find the financepy
folder at the below location

`C:\Anaconda3\envs\py38\Lib\site-packages\financepy`
`C:\Anaconda3\envs\py38class\Lib\site-packages\financepy`

# finmarketpy examples

Expand All @@ -187,6 +187,9 @@ In finmarketpy/examples you will find several examples, including some simple tr

# finmarketpy log

* 01 Jan 2024
* Helper code to reduce boiler plate code for TradingModel
* Upgraded to FinancePy 0.310 and refactored FXVolSurface
* 26 Apr 2023
* Changed sklearn to scikit-learn dependency
* 05 Apr 2022
Expand Down
1,700 changes: 1,151 additions & 549 deletions finmarketpy/backtest/backtestengine.py

Large diffs are not rendered by default.

230 changes: 144 additions & 86 deletions finmarketpy/curve/volatility/fxoptionspricer.py

Large diffs are not rendered by default.

245 changes: 121 additions & 124 deletions finmarketpy/curve/volatility/fxvolsurface.py

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions finmarketpy/util/marketconstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,21 @@ class MarketConstants(object):
fx_options_tenor_for_interpolation = ["ON", "1W", "2W", "3W", "1M", "2M", "3M", "4M", "6M", "9M", "1Y"]#, "2Y", "3Y"]

# What contract will we generally be trading?
fx_options_trading_tenor = '1M'
fx_options_trading_tenor = "1M"

# When constructing total return index 'mult' or 'add'
fx_options_cum_index = 'mult'
fx_options_cum_index = "mult"

# For total return index use option price in base currency/for
fx_options_index_premium_output = 'pct-for'
fx_options_index_premium_output = "pct-for"

fx_options_index_strike = 'atm'
fx_options_index_contract_type = 'european-call'
fx_options_index_strike = "atm"
fx_options_index_contract_type = "european-call"

fx_options_freeze_implied_vol = False

# What is the point at which we roll?
fx_options_roll_event = 'expiry-date' # 'month-end', 'expiry-date', 'no-roll'
fx_options_roll_event = "expiry-date" # 'month-end', 'expiry-date', 'no-roll'

# How many days before that point should we roll?
fx_options_roll_days_before = 5
Expand All @@ -114,23 +114,23 @@ class MarketConstants(object):
# For fitting vol surface

# 'CLARK5', 'CLARK', 'BBG', 'SABR' and 'SABR3'
fx_options_vol_function_type = 'CLARK5'
fx_options_depo_tenor = '1M'
fx_options_vol_function_type = "CLARK5"
fx_options_depo_tenor = "1M"

# 'fwd-delta-neutral' or 'fwd-delta-neutral-premium-adj' or 'spot' or 'fwd'
fx_options_atm_method = 'fwd-delta-neutral-premium-adj'
fx_options_atm_method = "fwd-delta-neutral-premium-adj"

# 'fwd-delta' or 'fwd-delta-prem-adj' or 'spot-delta-prem-adj' or 'spot-delta'
fx_options_delta_method = 'spot-delta-prem-adj'
fx_options_delta_method = "spot-delta-prem-adj"
fx_options_alpha = 0.5

# 'pct-for' (in base currency pct) or 'pct-dom' (in terms currency pct)
fx_options_premium_output = 'pct-for'
fx_options_delta_output = 'pct-fwd-delta-prem-adj'
fx_options_premium_output = "pct-for"
fx_options_delta_output = "pct-fwd-delta-prem-adj"

# 'nelmer-mead' or 'nelmer-mead-numba' (faster but less accurate) or 'cg' (conjugate gradient tends to be slower, but more accurate)
fx_options_solver = 'nelmer-mead-numba'
fx_options_pricing_engine = 'financepy' # 'financepy' or 'finmarketpy'
fx_options_solver = "nelmer-mead-numba"
fx_options_pricing_engine = "financepy" # 'financepy' or 'finmarketpy'

fx_options_tol = 1e-8

Expand Down
14 changes: 7 additions & 7 deletions finmarketpy/util/marketutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ def parse_date(self, date):

date1 = datetime.datetime.utcnow()

if date is 'midnight':
if date == "midnight":
date1 = datetime.datetime(date1.year, date1.month, date1.day, 0, 0, 0)
elif date is 'decade':
elif date == "decade":
date1 = date1 - timedelta(days=365 * 10)
elif date is 'year':
elif date == "year":
date1 = date1 - timedelta(days=365)
elif date is 'month':
elif date == "month":
date1 = date1 - timedelta(days=30)
elif date is 'week':
elif date == "week":
date1 = date1 - timedelta(days=7)
elif date is 'day':
elif date == "day":
date1 = date1 - timedelta(days=1)
elif date is 'hour':
elif date == "hour":
date1 = date1 - timedelta(hours=1)
else:
# format expected 'Jun 1 2005 01:33', '%b %d %Y %H:%M'
Expand Down
Loading

0 comments on commit fa76439

Please sign in to comment.