Skip to content

Commit

Permalink
Merge pull request #264 from ta-oliver/v0.0.62
Browse files Browse the repository at this point in the history
Version 0.0.62
  • Loading branch information
ta-oliver authored Dec 9, 2021
2 parents 6f177d6 + 9f6d03c commit 804b6b4
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion infertrade/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
File for storing current version of package.
"""

__version__ = "0.0.61"
__version__ = "0.0.62"
7 changes: 5 additions & 2 deletions infertrade/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,11 @@ def _get_raw_callable(name_of_strategy_or_signal: str) -> callable:

@staticmethod
def calculate_allocations(
df: pd.DataFrame, name_of_strategy: str, name_of_price_series: str = PandasEnum.MID.value,
allocation_lower_limit: float = -1.0, allocation_upper_limit: float = 1.0
df: pd.DataFrame,
name_of_strategy: str,
name_of_price_series: str = PandasEnum.MID.value,
allocation_lower_limit: float = -1.0,
allocation_upper_limit: float = 1.0,
) -> pd.DataFrame:
"""Calculates the allocations using the supplied strategy."""
if name_of_price_series is not PandasEnum.MID.value:
Expand Down
1 change: 1 addition & 0 deletions infertrade/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

# TODO - migrate last function to utilities.


def get_signal_calc(func: callable, adapter: callable = None) -> callable or pd.DataFrame:
"""An adapter to calculate a signal prior to usage within a trading rule."""
if adapter:
Expand Down
2 changes: 1 addition & 1 deletion infertrade/utilities/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ def calculate_regression_with_kelly_optimum(

if volatility < recent_fractional_realised_vol:
volatility = recent_fractional_realised_vol

# Absolute floor for volatility at 0.01% == 1bp
minimum_volatility = 0.0001
if volatility < minimum_volatility:
Expand Down
1 change: 0 additions & 1 deletion tests/test_allocations.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,3 @@ def test_all_allocations_list_required_series():
"""Checks that all allocation rules list required series."""
for ii_rule in Api.available_algorithms(filter_by_category="allocation"):
assert isinstance(Api.required_inputs_for_algorithm(ii_rule), list)

26 changes: 16 additions & 10 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ def test_return_representations(algorithm):
)
for representation in dict_of_properties[algorithm]["available_representation_types"]:
assert (
returned_representations[representation]
== dict_of_properties[algorithm]["available_representation_types"][representation]
returned_representations[representation]
== dict_of_properties[algorithm]["available_representation_types"][representation]
)

# Check if the if the function returns the correct representation when given a string
Expand All @@ -187,8 +187,8 @@ def test_return_representations(algorithm):
type(returned_representations),
)
assert (
returned_representations[representation]
== dict_of_properties[algorithm]["available_representation_types"][representation]
returned_representations[representation]
== dict_of_properties[algorithm]["available_representation_types"][representation]
)

# Check if the function returns the correct representations when given a list
Expand All @@ -200,8 +200,8 @@ def test_return_representations(algorithm):
)
for representation in algorithm_representations:
assert (
returned_representations[representation]
== dict_of_properties[algorithm]["available_representation_types"][representation]
returned_representations[representation]
== dict_of_properties[algorithm]["available_representation_types"][representation]
)


Expand Down Expand Up @@ -367,15 +367,21 @@ def test_allocation_limit(test_df):

test_df_copy = copy.deepcopy(test_df)
df_with_allocations = Api.calculate_allocations(
df=test_df_copy, name_of_strategy=available_allocation_algorithms[0], name_of_price_series="close",
allocation_lower_limit=0, allocation_upper_limit=0
df=test_df_copy,
name_of_strategy=available_allocation_algorithms[0],
name_of_price_series="close",
allocation_lower_limit=0,
allocation_upper_limit=0,
)
if not all(df_with_allocations["allocation"] == 0.0):
raise ValueError("Allocation limits breached")

df_with_allocations = Api.calculate_allocations(
df=test_df_copy, name_of_strategy=available_allocation_algorithms[0], name_of_price_series="close",
allocation_lower_limit=-0.1, allocation_upper_limit=0.1
df=test_df_copy,
name_of_strategy=available_allocation_algorithms[0],
name_of_price_series="close",
allocation_lower_limit=-0.1,
allocation_upper_limit=0.1,
)
if any(-0.1 > df_with_allocations["allocation"]) or any(df_with_allocations["allocation"] > 0.1):
raise ValueError("Allocation limits breached")

0 comments on commit 804b6b4

Please sign in to comment.