-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* handling multiple charts for budget allocation * moving to gymnasium * improvements * fixed pygame and improved example * tests * working on the example * example.ipynb * requirements.txt updated * requirements.txt updated * requirements.txt updated * requirements.txt updated * black format * requirements and pylint fix * pylint.yml updated * pylint fix * pylint fix * pylint tests fix * pylint.yml updated
- Loading branch information
1 parent
6ceb545
commit 9d6f9ee
Showing
22 changed files
with
2,104 additions
and
790 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,5 @@ requirements.txt | |
# Miscellaneous | ||
.DS_Store | ||
Thumbs.db | ||
|
||
*.csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/models/ | ||
/logs/ | ||
/crypto_datasets_* |
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from typing import Any | ||
|
||
import numpy as np | ||
from gymnasium.spaces import Box | ||
from numpy._typing import NDArray | ||
|
||
|
||
class BudgetAllocationSpace(Box): | ||
""" | ||
Custom Gym space for budget allocation. | ||
This class defines a custom Gym space for representing budget allocation. It inherits from the Box space and enforces | ||
that the allocation vector is within the range [0, 1] and sums up to 1. | ||
Parameters: | ||
num_assets (int): The number of assets in the allocation. | ||
Example usage: | ||
space = BudgetAllocationSpace(num_assets=3) | ||
action = space.sample() | ||
""" | ||
|
||
def __init__(self, num_assets): | ||
""" | ||
Initialize the BudgetAllocationSpace. | ||
Args: | ||
num_assets (int): The number of assets in the allocation. | ||
""" | ||
super().__init__( | ||
low=np.zeros(num_assets, dtype=np.float32), | ||
high=np.ones(num_assets, dtype=np.float32), | ||
shape=(num_assets,), | ||
) | ||
|
||
def sample(self, mask: None = None) -> NDArray[Any]: | ||
""" | ||
Generate a normalized random sample within the defined space. | ||
This method generates a random sample within the defined space, typically used for generating initial action | ||
values in reinforcement learning tasks. The generated sample is then normalized so that the sum of its components | ||
equals 1. | ||
Args: | ||
mask: An optional mask that can be applied to restrict the sampling. | ||
Returns: | ||
NDArray[Any]: A normalized random sample within the space. | ||
""" | ||
sample = super().sample(mask) | ||
normalized_sample = sample / np.sum(sample) | ||
return normalized_sample |
Oops, something went wrong.