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

Refactor get profit range #42

Merged
merged 40 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
8ad26f7
Update version
rgaveiga Nov 30, 2024
62fa294
Correct distributions in support.py
rgaveiga Nov 30, 2024
6ced277
Update test_core.py
rgaveiga Nov 30, 2024
fa1731d
Black source
rgaveiga Nov 30, 2024
932e350
Update CHANGELOG.md
rgaveiga Dec 1, 2024
00ba6d2
Update version to 1.3.3
rgaveiga Dec 1, 2024
5cec22a
Updated CHANGELOG.md
rgaveiga Dec 1, 2024
9821ea5
Update docstrings in support.py
rgaveiga Dec 8, 2024
831d983
Update docstrings in engine.py and black-scholes.py
rgaveiga Dec 9, 2024
0c67bdc
Update docstrings in plot.py
rgaveiga Dec 12, 2024
2e9b884
Update docstrings in utils.py
rgaveiga Dec 12, 2024
62bbd62
Updated docstrings models.py
rgaveiga Dec 15, 2024
8ce3df8
Update CHANGELOG.MD, change functions in utils.py and update docstrin…
rgaveiga Dec 15, 2024
a5b108d
Update docstrings in black-scholes.py
rgaveiga Dec 15, 2024
60adab5
Update docstrings in plot.py
rgaveiga Dec 17, 2024
6c05cbb
Update docstrings in models.py and comment unnecessary code
rgaveiga Dec 17, 2024
8ac115a
Update docstrings in support.py
rgaveiga Dec 17, 2024
653faef
Updated CHANGELOG.md
rgaveiga Dec 17, 2024
28a168a
Updated docstrings in black-scholes.py
rgaveiga Dec 17, 2024
70a18ea
Black source
rgaveiga Dec 19, 2024
ca96932
Change version to 1.3.4
rgaveiga Dec 20, 2024
deb9941
Update .gitignore
rgaveiga Dec 21, 2024
47e8bc0
Add Rho calculation
rgaveiga Dec 24, 2024
930e237
Update tests
rgaveiga Dec 25, 2024
6ccc192
Update examples
rgaveiga Dec 25, 2024
1e9ba49
Black source
rgaveiga Dec 26, 2024
57308ee
Update library version
rgaveiga Dec 28, 2024
1ef8250
Add Laplace distribution and Calendar Spread as tests
rgaveiga Dec 29, 2024
30f2330
Blacked source
rgaveiga Dec 29, 2024
1762faf
Changed some class names in models.py
rgaveiga Jan 1, 2025
5da19de
Added dict argument to get_pop()
rgaveiga Jan 3, 2025
fe984d4
Black source
rgaveiga Jan 4, 2025
a99ff8d
Improve get_pop and engine.py
rgaveiga Jan 13, 2025
c4bc9b5
Update examples
rgaveiga Jan 15, 2025
638e677
Updated examples and blacked source
rgaveiga Jan 19, 2025
12746d6
Updated README.md
rgaveiga Jan 19, 2025
98172c3
Blacked source
rgaveiga Jan 23, 2025
9ad66ad
Update CHANGELOG.md
rgaveiga Jan 23, 2025
13ae03a
Update README.md
rgaveiga Jan 23, 2025
34f5aa1
Merge branch 'main' into refactor-get-profit-range
rgaveiga Jan 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
.benchmarks
.mypy_cache
.pytest_cache
__pycache__
dist
run_check
examples/.ipynb_checkpoints
optionlab/__pycache__
tests/__pycache__
tests/.benchmarks
*.old
89 changes: 81 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,96 @@
# CHANGELOG

## 1.4.1 (2025-01-04)

- 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 by `get_profit_range`
- Removed the fields `probability_of_profit_from_mc`, `average_profit_from_mc` and `average_loss_from_mc` from `Outputs` in models.py
- Created the fields `expected_profit` and `expected_loss` in `Outputs` in models.py
- Created a class `PoPOutputs` in models.py containing fields returned by `get_pop` in support.py
- Removed Laplace form `get_pop` in support.py
- Improved `get_pop` in support.py to return a `PoPOutputs` 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` and `get_pop_array` in support.py

## 1.4.0 (2025-01-01)

- Changed the class name `DistributionInputs` to `TheoreticalModelInputs` in models.py, to be more descriptive
- Changed the class name `DistributionBlackScholesInputs` to `BlackScholesModelInputs` in models.py
- Changed the class name `DistributionLaplaceInputs` to `LaplaceInputs` in models.py
- Changed the class name `DistributionArrayInputs` to `ArrayInputs` in models.py
- Changed literal `Distribution` to `TheoreticalModel`
- Moved `create_price_samples` from support.py to a new module price_array.py and renamed it to `create_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

## 1.3.5 (2024-12-28)

- Created a base class `DistributionInputs`
- Changed the name of `ProbabilityOfProfitInputs` in models.py (and everywhere in the code) to `DistributionBlackScholesInputs`, which inherits from `DistributionInputs`
- Removed the `source` field from `DistributionBlackScholesInputs`
- 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 from `DistributionInputs`
- Changed `years_to_maturity` field in `DistributionInputs` to `years_to_target_date`
- Refactored `create_price_samples` in support.py
- Added __hash__ = object.__hash__ in `DistributionBlackScholesInputs` and `DistributionLaplaceInputs` in models.py to allow their use in `create_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

## 1.3.4 (2024-12-20)

- Deleted `OptionInfo` class in models.py, because it is not necessary
- Deleted `return_in_the_domain_ratio` in `Outputs` 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` and `get_d2`
- Added the field `business_days_in_year` in `Inputs` 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` and `put_rho` fields to `BlackScholesInfo` in models.py
- Added `rho` field to `EngineData` in models.py
- Added `rho` field to `Outputs` in models.py
- Added `rho` data field in engine.py
- Added a `seed` argument to `create_price_samples` in support.py to make the generation of price samples deterministic
- Changed `array_prices` field to simply `array` in `Inputs` in models.py
- Changed and commented some tests in test_core.py

## 1.3.3 (2024-12-18)

- Updated docstrings to comply with reStructuredText (RST) standards
- Changed the `country` argument in `get_nonbusiness_days` in utils.py to accept a string
- Changed the `data` argument in `get_pl` and `pl_to_csv` in utils.py to accept an `Outputs` object instead of `EngineData`
- Commented 'source: Literal["array"] = "array"' in `ProbabilityOfProfitArrayInputs` class in models.py, because `source` is not necessary
- Commented `OptionInfo` class in models.py, because it is not used anywhere
- Commented `return_in_the_domain_ratio` in `Outputs` 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

## 1.3.2 (2024-11-30)

- Changed Laplace distribution implementation in `create_price_samples` and `get_pop` functions in support.py.
- Changed Laplace distribution implementation in `create_price_samples` and `get_pop` functions in support.py

## 1.3.1 (2024-09-27)

- 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 and OptionStrategy to Stock and Option in models.py, respectively.
- Changed BaseStrategy to BaseLeg in models.py.
- Changed Strategy to StrategyLeg in models.py.
- Removed premium field from Stock in models.py.
- Moved n field to BaseLeg in models.py.
- Changed `StotckStrategy` and `OptionStrategy` to `Stock` and `Option` in models.py, respectively.
- Changed `BaseStrategy` to `BaseLeg` in models.py
- Changed `Strategy` to `StrategyLeg` in models.py
- Removed `premium` field from `Stock` in models.py
- Moved `n` field to `BaseLeg` in models.py

## 1.3.0 (2024-09-13)

- Remove the deprecated `StrategyEngine` class (it remains commented in the code).
- Update the README.md file to reflect the current state of the library.
- Update the README.md file to reflect the current state of the library

## 1.2.1 (2024-06-03)

Expand All @@ -28,7 +101,7 @@ it was causing errors in new Pydantic versions.

## 1.2.0 (2024-03-31)

- Add functions to run engine.
- Add functions to run engine

## 1.1.0 (2024-03-24)

Expand Down
Loading
Loading