- Removed a small bug in
create_price_seq
in support.py - Improved the algorithm in
get_profit_range
in support.py, then renamed to_get_profit_range
- Created a helper function
_get_sign_changes
in support.py, called byget_profit_range
- Removed the fields
probability_of_profit_from_mc
,average_profit_from_mc
andaverage_loss_from_mc
fromOutputs
in models.py - Created the fields
expected_profit
andexpected_loss
inOutputs
in models.py - Created a class
PoPOutputs
in models.py containing fields returned byget_pop
in support.py - Removed Laplace form
get_pop
in support.py - Improved
get_pop
in support.py to return aPoPOutputs
object with more information - Added naked calls as an example of strategy
- Created a custom type
FloatOrNdarray
that can contain a float or a numpy.ndarray in models.py - Created the helper functions
_get_pop_bs
andget_pop_array
in support.py
- Changed the class name
DistributionInputs
toTheoreticalModelInputs
in models.py, to be more descriptive - Changed the class name
DistributionBlackScholesInputs
toBlackScholesModelInputs
in models.py - Changed the class name
DistributionLaplaceInputs
toLaplaceInputs
in models.py - Changed the class name
DistributionArrayInputs
toArrayInputs
in models.py - Changed literal
Distribution
toTheoreticalModel
- Moved
create_price_samples
from support.py to a new module price_array.py and renamed it tocreate_price_array
- Commented a code snippet in engine.py where terminal stock prices are created using
create_price_samples
, to be removed in a next version - Allowed a dictionary as input for
create_price_array
in price_array.py - Allowed a dictionary as input for
get_pop
in support.py
- Created a base class
DistributionInputs
- Changed the name of
ProbabilityOfProfitInputs
in models.py (and everywhere in the code) toDistributionBlackScholesInputs
, which inherits fromDistributionInputs
- Removed the
source
field fromDistributionBlackScholesInputs
- Modified interest_rate: float = Field(0.0, ge=0.0) in
DistributionBlackScholesInputs
in models.py - Modified volatility: float = Field(gt=0.0) in
DistributionInputs
in models.py - Modified years_to_maturity: float = Field(ge=0.0) in
DistributionInputs
in models.py - Created a class
DistributionLaplaceInputs
in models.py, which inherits fromDistributionInputs
- Changed
years_to_maturity
field inDistributionInputs
toyears_to_target_date
- Refactored
create_price_samples
in support.py - Added hash = object.hash in
DistributionBlackScholesInputs
andDistributionLaplaceInputs
in models.py to allow their use increate_price_samples
in support.py with caching - Updated tests to reflect those changes
- Removed a deprecated class,
StrategyEngine
, commented in a previous version - Added a test for Laplace distribution
- Added a test for Calendar Spread
- Deleted
OptionInfo
class in models.py, because it is not necessary - Deleted
return_in_the_domain_ratio
inOutputs
in models.py - Deleted
Country
in models.py, because it is not necessary - Deleted source: Literal["array"] = "array" in
ProbabilityOfProfitArrayInputs
class in models.py, because it is not necessary - Strike prices in black_scholes.py functions now can be provided also as numpy arrays and those functions return numpy arrays
BlackScholesInfo
fields in models.py now can be both float and numpy arrays- Split
get_d1_d2
function in black_scholes.py into two functions,get_d1
andget_d2
- Added the field
business_days_in_year
inInputs
class in models.py to allow market-dependent customization; also changed in engine.py - Added Greek Rho calculation to black-scholes.py
- Added
call_rho
andput_rho
fields toBlackScholesInfo
in models.py - Added
rho
field toEngineData
in models.py - Added
rho
field toOutputs
in models.py - Added
rho
data field in engine.py - Added a
seed
argument tocreate_price_samples
in support.py to make the generation of price samples deterministic - Changed
array_prices
field to simplyarray
inInputs
in models.py - Changed and commented some tests in test_core.py
- Updated docstrings to comply with reStructuredText (RST) standards
- Changed the
country
argument inget_nonbusiness_days
in utils.py to accept a string - Changed the
data
argument inget_pl
andpl_to_csv
in utils.py to accept anOutputs
object instead ofEngineData
- Commented 'source: Literal["array"] = "array"' in
ProbabilityOfProfitArrayInputs
class in models.py, becausesource
is not necessary - Commented
OptionInfo
class in models.py, because it is not used anywhere - Commented
return_in_the_domain_ratio
inOutputs
in models.py, because it is not necessary - Commented
Country
in models.py, because it is not necessary - Changed country: Country = "US" to country: str = "US" in models.py
- Changed Laplace distribution implementation in
create_price_samples
andget_pop
functions in support.py
- discriminator="type" removed from strategy: list[StrategyLeg] = Field(..., min_length=1) in models.py, since it was causing errors in new Pydantic versions.
- Changed
StotckStrategy
andOptionStrategy
toStock
andOption
in models.py, respectively. - Changed
BaseStrategy
toBaseLeg
in models.py - Changed
Strategy
toStrategyLeg
in models.py - Removed
premium
field fromStock
in models.py - Moved
n
field toBaseLeg
in models.py
- Remove the deprecated
StrategyEngine
class (it remains commented in the code). - Update the README.md file to reflect the current state of the library
- Add 1 to
time_to_target
andtime_to_maturity
inengine.py
to consider the target and expiration dates as trading days in the calculations - Change Jupyter notebooks in the
examples
directory to utilize therun_strategy()
function for performing options strategy calculations, instead of using theStrategyEngine
class (deprecated) - Correct the PoP Calculator notebook
- Change the name of variable
project_target_ranges
inmodels.py
andengine.py
toprofit_target_ranges
- Add functions to run engine
- Refactor the engine's
run
method for readability - Accept dictionary of inputs to
StratgyEngine
init
- Refactor holidays.py to a utils function using the
holiday
library
BREAKING CHANGES:
- Renamed strategy.py to engine.py and
Strategy
toStrategyEngine
- Using pydantic for input validation into
StrategyEngine
- Outputs are now also a Pydantic model
- Delete
use_dates
, as Pydantic will handle either using dates ordays_to_target
- Renamed functions to be PEP8 compliant, i.e. instead of
getPoP
, now isget_pop
- Deleted options_chain.py module
- Initial commit with strategy engine and examples