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

Back #413

Merged
merged 2 commits into from
Dec 11, 2023
Merged

Back #413

Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.9.34] - 2023-12-11
### Added
- Profiles: extra_backtesting_time_frames

## [1.9.33] - 2023-12-08
### Added
- Enums: TRIGGER_HEALTH_CHECK
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# OctoBot-Commons [1.9.33](https://github.com/Drakkar-Software/OctoBot-Commons/blob/master/CHANGELOG.md)
# OctoBot-Commons [1.9.34](https://github.com/Drakkar-Software/OctoBot-Commons/blob/master/CHANGELOG.md)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/b31f3ab3511744a5a5ca6b9bb48e77bb)](https://app.codacy.com/gh/Drakkar-Software/OctoBot-Commons?utm_source=github.com&utm_medium=referral&utm_content=Drakkar-Software/OctoBot-Commons&utm_campaign=Badge_Grade_Dashboard)
[![PyPI](https://img.shields.io/pypi/v/OctoBot-Commons.svg)](https://pypi.python.org/pypi/OctoBot-Commons/)
[![Coverage Status](https://coveralls.io/repos/github/Drakkar-Software/OctoBot-Commons/badge.svg?branch=master)](https://coveralls.io/github/Drakkar-Software/OctoBot-Commons?branch=master)
Expand Down
2 changes: 1 addition & 1 deletion octobot_commons/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# License along with this library.

PROJECT_NAME = "OctoBot-Commons"
VERSION = "1.9.33" # major.minor.revision
VERSION = "1.9.34" # major.minor.revision

MARKET_SEPARATOR = "/"
SETTLEMENT_ASSET_SEPARATOR = ":"
Expand Down
2 changes: 2 additions & 0 deletions octobot_commons/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
CONFIG_ORIGIN_URL = "origin_url"
CONFIG_READ_ONLY = "read_only"
CONFIG_IMPORTED = "imported"
CONFIG_EXTRA_BACKTESTING_TIME_FRAMES = "extra_backtesting_time_frames"
CONFIG_COMPLEXITY = "complexity"
CONFIG_RISK = "risk"
CONFIG_TYPE = "type"
Expand All @@ -90,6 +91,7 @@
CONFIG_EXCHANGE_PASSWORD = "api-password"
CONFIG_EXCHANGE_TYPE = "exchange-type"
CONFIG_CONTRACT_TYPE = "contract-type"
CONFIG_REQUIRED_EXTRA_TIMEFRAMES = "required_extra_timeframes"
CONFIG_EXCHANGE_SANDBOXED = "sandboxed"
CONFIG_EXCHANGE_FUTURE = "future"
CONFIG_EXCHANGE_MARGIN = "margin"
Expand Down
5 changes: 5 additions & 0 deletions octobot_commons/profiles/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def __init__(self, profile_path: str, schema_path: str = None):
self.complexity: enums.ProfileComplexity = enums.ProfileComplexity.MEDIUM
self.risk: enums.ProfileRisk = enums.ProfileRisk.MODERATE
self.profile_type: enums.ProfileType = enums.ProfileType.LIVE
self.extra_backtesting_time_frames = []

self.config: dict = {}

Expand Down Expand Up @@ -106,6 +107,9 @@ def from_dict(self, profile_dict: dict):
self.profile_type = enums.ProfileType(
profile_config.get(constants.CONFIG_TYPE, enums.ProfileType.LIVE.value)
)
self.extra_backtesting_time_frames = profile_config.get(
constants.CONFIG_EXTRA_BACKTESTING_TIME_FRAMES, []
)
self.config = profile_dict[constants.PROFILE_CONFIG]
if self.avatar and self.path:
avatar_path = os.path.join(self.path, self.avatar)
Expand Down Expand Up @@ -250,6 +254,7 @@ def as_dict(self) -> dict:
constants.CONFIG_TYPE: self.profile_type.value
if self.profile_type
else None,
constants.CONFIG_EXTRA_BACKTESTING_TIME_FRAMES: self.extra_backtesting_time_frames,
},
constants.PROFILE_CONFIG: self.config,
}
Expand Down
6 changes: 6 additions & 0 deletions octobot_commons/profiles/profile_data_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
import octobot_commons.enums as enums

IMPORTED_AVATAR = "avatar"
IMPORTED_PROFILES_DEFAULT_EXTRA_BACKTESTING_TIMEFRAME = (
enums.TimeFrames.FIFTEEN_MINUTES.value
)


async def convert_profile_data_to_profile_directory(
Expand Down Expand Up @@ -79,6 +82,9 @@ def _get_profile(
profile.risk = risk
profile.profile_id = str(uuid.uuid4().hex)
profile.read_only = True
profile.extra_backtesting_time_frames = [
IMPORTED_PROFILES_DEFAULT_EXTRA_BACKTESTING_TIMEFRAME
]
return profile


Expand Down
3 changes: 3 additions & 0 deletions tests/profiles/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ def test_as_dict(profile):
constants.CONFIG_COMPLEXITY: enums.ProfileComplexity.MEDIUM.value,
constants.CONFIG_RISK: enums.ProfileRisk.MODERATE.value,
constants.CONFIG_TYPE: enums.ProfileType.LIVE.value,
constants.CONFIG_EXTRA_BACKTESTING_TIME_FRAMES: [],
},
constants.PROFILE_CONFIG: {},
}
Expand All @@ -180,6 +181,7 @@ def test_as_dict(profile):
profile.complexity = enums.ProfileComplexity.DIFFICULT
profile.risk = enums.ProfileRisk.LOW
profile.profile_type = enums.ProfileType.BACKTESTING
profile.extra_backtesting_time_frames = [enums.TimeFrames.ONE_DAY.value]
assert profile.as_dict() == {
constants.CONFIG_PROFILE: {
constants.CONFIG_ID: "default",
Expand All @@ -192,6 +194,7 @@ def test_as_dict(profile):
constants.CONFIG_COMPLEXITY: enums.ProfileComplexity.DIFFICULT.value,
constants.CONFIG_RISK: enums.ProfileRisk.LOW.value,
constants.CONFIG_TYPE: enums.ProfileType.BACKTESTING.value,
constants.CONFIG_EXTRA_BACKTESTING_TIME_FRAMES: [enums.TimeFrames.ONE_DAY.value],
},
constants.PROFILE_CONFIG: {
"a": 1
Expand Down