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

[Context] add live id and rename analysis_settings #816

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
20 changes: 13 additions & 7 deletions octobot_trading/modes/script_keywords/context_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ def __init__(
backtesting_id,
optimizer_id,
optimization_campaign_name=None,
backtesting_analysis_settings=None,
analysis_settings=None,
live_id=None,
):
# no cache if live trading to ensure cache is always writen
# no cache if live trading to ensure cache is always written
super().__init__(
tentacle,
exchange_name,
Expand All @@ -93,13 +94,14 @@ def __init__(
exchange_manager.tentacles_setup_config if exchange_manager else None,
not exchange_manager.is_backtesting if exchange_manager else False
)
self.backtesting_analysis_settings = backtesting_analysis_settings
self.analysis_settings = analysis_settings
self.exchange_manager = exchange_manager
self.trader = trader
self.matrix_id = matrix_id
self.cryptocurrency = cryptocurrency
self.signal_symbol = signal_symbol
self.logger = logger
self.live_id = live_id
bot_id = exchange_manager.bot_id if \
(exchange_manager is not None) \
and (exchange_manager.bot_id is not None) \
Expand Down Expand Up @@ -222,7 +224,7 @@ async def local_nested_tentacle_config(self, tentacle_class, config_name, is_nes

@staticmethod
def minimal(trading_mode_class, logger, exchange_name, traded_pair, backtesting_id,
optimizer_id, optimization_campaign_name, backtesting_analysis_settings):
optimizer_id, optimization_campaign_name, analysis_settings, live_id=None):
return Context(
None,
None,
Expand All @@ -241,7 +243,8 @@ def minimal(trading_mode_class, logger, exchange_name, traded_pair, backtesting_
backtesting_id,
optimizer_id,
optimization_campaign_name,
backtesting_analysis_settings,
analysis_settings,
live_id=live_id,
)

@contextlib.asynccontextmanager
Expand All @@ -262,7 +265,7 @@ async def nested_call_context(self, tentacle):
self.trigger_source,
self.trigger_value,
self.backtesting_id,
self.optimizer_id
self.optimizer_id,
)
context.is_nested_tentacle = self.is_nested_tentacle
context.config_name = self.config_name
Expand Down Expand Up @@ -503,10 +506,13 @@ async def backtesting_results(self, with_lock=False, cache_size=None, database_a
display = commons_display.display_translator_factory()
run_dbs_identifier = databases.RunDatabasesIdentifier(
self.trading_mode_class,
self.optimization_campaign_name or optimization_campaign.OptimizationCampaign.get_campaign_name(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why removing this ?
Except for that, I think we can merge

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it again and adapted it for live as well

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great 👍

None if self.live_id else (
self.optimization_campaign_name
or optimization_campaign.OptimizationCampaign.get_campaign_name()),
database_adaptor=database_adaptor,
backtesting_id=self.backtesting_id,
optimizer_id=self.optimizer_id,
live_id=self.live_id,
context=self
)
if not await run_dbs_identifier.exchange_base_identifier_exists(self.exchange_name):
Expand Down