Skip to content
This repository was archived by the owner on Feb 21, 2026. It is now read-only.

Commit 71cfdf0

Browse files
committed
[DataCollector] add support for multi data files
tmp
1 parent ea4628a commit 71cfdf0

4 files changed

Lines changed: 23 additions & 12 deletions

File tree

Meta/Keywords/scripting_library/data/reading/exchange_public_data.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,23 @@ async def get_candles_from_name(ctx, source_name="low", time_frame=None, symbol=
210210

211211
async def _local_candles_manager(exchange_manager, symbol, time_frame, start_timestamp, end_timestamp):
212212
# warning: should only be called with an exchange simulator (in backtesting)
213-
ohlcv_data: list = await exchange_manager.exchange.exchange_importers[0].get_ohlcv(
214-
exchange_name=exchange_manager.exchange_name,
215-
symbol=symbol,
216-
time_frame=commons_enums.TimeFrames(time_frame))
213+
ohlcv_data: list = None
214+
for importer in exchange_manager.exchange.exchange_importers:
215+
if (importer.exchange_name == exchange_manager.exchange_name
216+
and symbol in importer.symbols
217+
and commons_enums.TimeFrames(time_frame) in importer.time_frames
218+
):
219+
ohlcv_data: list = await importer.get_ohlcv(
220+
exchange_name=exchange_manager.exchange_name,
221+
symbol=symbol,
222+
time_frame=commons_enums.TimeFrames(time_frame),
223+
)
224+
break
225+
if not ohlcv_data:
226+
raise(
227+
f"Failed to load candles data for {symbol} {time_frame} "
228+
f"{exchange_manager.exchange_name} - no data available to load"
229+
)
217230
chronological_candles = sorted(ohlcv_data, key=lambda candle: candle[0])
218231
full_candles_history = [
219232
ohlcv[-1]
@@ -237,7 +250,7 @@ async def _get_candle_manager(context, symbol, time_frame, max_history):
237250
return candle_manager
238251
start_timestamp = backtesting_api.get_backtesting_starting_time(context.exchange_manager.exchange.backtesting)
239252
end_timestamp = backtesting_api.get_backtesting_ending_time(context.exchange_manager.exchange.backtesting)
240-
_key = symbol + time_frame + str(start_timestamp) + str(end_timestamp)
253+
_key = context.exchange_manager.exchange_name + symbol + time_frame + str(start_timestamp) + str(end_timestamp)
241254
try:
242255
return run_persistence.get_shared_element(_key)
243256
except KeyError:

Services/Interfaces/web_interface/controllers/backtesting.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import octobot_commons.time_frame_manager as time_frame_manager
2121
import octobot_commons.constants as commons_constants
22+
import octobot_backtesting.constants as backtesting_constants
2223

2324
import tentacles.Services.Interfaces.web_interface as web_interface
2425
import tentacles.Services.Interfaces.web_interface.login as login
@@ -61,10 +62,10 @@ def backtesting():
6162
auto_stop = flask.request.args.get("auto_stop", False)
6263
data_sources = data.get("data_sources", None)
6364
if data_sources:
64-
if models.CURRENT_BOT_DATA in data_sources:
65-
data_sources = [models.CURRENT_BOT_DATA]
65+
if backtesting_constants.CONFIG_CURRENT_BOT_DATA in data_sources:
66+
data_sources = [backtesting_constants.CONFIG_CURRENT_BOT_DATA]
6667
else:
67-
data_sources = [data.get("data_source", models.CURRENT_BOT_DATA) ]
68+
data_sources = [data.get("data_source", backtesting_constants.CONFIG_CURRENT_BOT_DATA) ]
6869
exchange_ids = data.get("exchange_ids", None)
6970
if not exchange_ids:
7071
exchange_ids = [data.get("exchange_id", None)]

Services/Interfaces/web_interface/models/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232

3333
from tentacles.Services.Interfaces.web_interface.models.backtesting import (
34-
CURRENT_BOT_DATA,
3534
get_full_candle_history_exchange_list,
3635
get_other_history_exchange_list,
3736
get_data_files_with_description,

Services/Interfaces/web_interface/models/backtesting.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import octobot_tentacles_manager.api as tentacles_manager_api
3333
import octobot_backtesting.constants as backtesting_constants
3434
import octobot_backtesting.enums as backtesting_enums
35-
import octobot_backtesting.collectors as collectors
3635
import octobot_services.interfaces.util as interfaces_util
3736
import octobot_services.enums as services_enums
3837
import octobot_trading.constants as trading_constants
@@ -45,7 +44,6 @@
4544

4645

4746
STOPPING_TIMEOUT = 30
48-
CURRENT_BOT_DATA = "current_bot_data"
4947
# data collector can be really slow, let it up to 2 hours to run
5048
DATA_COLLECTOR_TIMEOUT = 2 * commons_constants.HOURS_TO_SECONDS
5149

@@ -104,7 +102,7 @@ def start_backtesting_using_current_bot_data(data_sources, exchange_ids, source,
104102
start_timestamp=None, end_timestamp=None, trading_type=None,
105103
enable_logs=False, auto_stop=False,
106104
collector_start_callback=None, start_callback=None):
107-
use_current_bot_data = data_sources == [CURRENT_BOT_DATA]
105+
use_current_bot_data = data_sources == [backtesting_constants.CONFIG_CURRENT_BOT_DATA]
108106
files = None if use_current_bot_data else data_sources
109107
return _start_backtesting(files, source, reset_tentacle_config=reset_tentacle_config,
110108
run_on_common_part_only=False,

0 commit comments

Comments
 (0)