Skip to content

Commit 98d5089

Browse files
techfreaqueGuillaumeDSM
authored andcommitted
[Backtesting] allow custom exchange type
[Backtesting] improve allow custom exchange type Auto stash before checking out "origin/master"
1 parent 670c8c7 commit 98d5089

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

octobot/backtesting/independent_backtesting.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ def __init__(self, config,
6565
self.optimizer_id = None
6666
self.backtesting_id = None
6767
self._init_default_config_values()
68+
try:
69+
self.backtesting_config[common_constants.CONFIG_EXCHANGE_TYPE] \
70+
= config[common_constants.CONFIG_EXCHANGE_TYPE]
71+
except KeyError:
72+
self.backtesting_config[common_constants.CONFIG_EXCHANGE_TYPE] \
73+
= common_constants.CONFIG_EXCHANGE_CURRENT_PROFILE
6874
self.stopped = False
6975
self.stopped_event = None
7076
self.post_backtesting_task = None

octobot/backtesting/octobot_backtesting.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,24 @@ async def _create_service_feeds(self):
217217
f"might not work properly")
218218

219219
async def _init_exchanges(self):
220+
if self.backtesting_config[commons_constants.CONFIG_EXCHANGE_TYPE] \
221+
!= commons_constants.CONFIG_EXCHANGE_CURRENT_PROFILE:
222+
for exchange in self.exchange_type_by_exchange:
223+
if self.backtesting_config[commons_constants.CONFIG_EXCHANGE_TYPE] \
224+
== trading_enums.ExchangeTypes.SPOT.value:
225+
self.exchange_type_by_exchange[exchange] = commons_constants.CONFIG_EXCHANGE_SPOT
226+
elif self.backtesting_config[commons_constants.CONFIG_EXCHANGE_TYPE] \
227+
== trading_enums.FutureContractType.INVERSE_PERPETUAL.value:
228+
self.exchange_type_by_exchange[exchange] = commons_constants.CONFIG_EXCHANGE_FUTURE
229+
self.futures_contract_type = trading_enums.FutureContractType.INVERSE_PERPETUAL
230+
elif self.backtesting_config[commons_constants.CONFIG_EXCHANGE_TYPE] \
231+
== trading_enums.FutureContractType.LINEAR_PERPETUAL.value:
232+
self.exchange_type_by_exchange[exchange] = commons_constants.CONFIG_EXCHANGE_FUTURE
233+
self.futures_contract_type = trading_enums.FutureContractType.LINEAR_PERPETUAL
234+
elif self.backtesting_config[commons_constants.CONFIG_EXCHANGE_TYPE] \
235+
== trading_enums.ExchangeTypes.MARGIN.value:
236+
self.exchange_type_by_exchange[exchange] = commons_constants.CONFIG_EXCHANGE_MARGIN
237+
220238
self.backtesting = await backtesting_api.initialize_backtesting(self.backtesting_config,
221239
exchange_ids=self.exchange_manager_ids,
222240
matrix_id=self.matrix_id,

0 commit comments

Comments
 (0)