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

Improve optimizer settings, live metadata and fix position size calculation #2180

Open
wants to merge 2 commits into
base: dev
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
11 changes: 7 additions & 4 deletions octobot/storage/trading_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,11 @@ async def _get_multi_exchange_data(exchange_managers, is_backtesting):
for exchange_manager in exchange_managers
)
else:
start_time = exchange_managers[0].exchange.get_exchange_current_time()
start_time = trades[0].creation_time if trades else exchange_managers[0].exchange.get_exchange_current_time()
end_time = -1
origin_portfolio = {}
end_portfolio = {}
# handle live origin_portfolio
for exchange_manager in exchange_managers:
try:
exchange_origin_portfolio = trading_api.get_origin_portfolio(exchange_manager, as_decimal=False)
Expand All @@ -179,7 +180,7 @@ async def _get_multi_exchange_data(exchange_managers, is_backtesting):
values.pop("available", None)
if exchange_manager.is_future:
for position in trading_api.get_positions(exchange_manager):
exchange_end_portfolio[position.get_currency()]["position"] = float(position.quantity)
exchange_end_portfolio[position.get_currency()]["position"] = float(position.single_contract_value * position.size)
for exchange_portfolio, portfolio in zip((exchange_origin_portfolio, exchange_end_portfolio),
(origin_portfolio, end_portfolio)):
for currency, value_dict in exchange_portfolio.items():
Expand Down Expand Up @@ -241,8 +242,10 @@ async def _get_single_exchange_data(exchange_manager, trading_mode, run_start_ti
backtesting_only_metadata = {
common_enums.BacktestingMetadata.ID.value: run_dbs_identifier.backtesting_id,
common_enums.BacktestingMetadata.OPTIMIZATION_CAMPAIGN.value: run_dbs_identifier.optimization_campaign_name,
common_enums.BacktestingMetadata.USER_INPUTS.value: formatted_user_inputs,
} if is_backtesting else {}
common_enums.BacktestingMetadata.USER_INPUTS.value: formatted_user_inputs,
} if is_backtesting else {
common_enums.BacktestingMetadata.ID.value: run_dbs_identifier.live_id,
}
return {
**backtesting_only_metadata,
**{
Expand Down