Skip to content

Commit 700520f

Browse files
Guillaume De Saint MartinGuillaumeDSM
authored andcommitted
migrate trading config keys into commons
1 parent 397cbdd commit 700520f

File tree

7 files changed

+30
-32
lines changed

7 files changed

+30
-32
lines changed

Services/Interfaces/web_interface/controllers/configuration.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# License along with this library.
1616
import flask
1717

18-
import octobot_trading.constants as trading_constants
18+
import octobot_commons.constants as commons_constants
1919
import octobot_services.constants as services_constants
2020
import tentacles.Services.Interfaces.web_interface.constants as constants
2121
import tentacles.Services.Interfaces.web_interface.login as login
@@ -98,16 +98,16 @@ def config():
9898

9999
return flask.render_template('config.html',
100100

101-
config_exchanges=display_config[trading_constants.CONFIG_EXCHANGES],
102-
config_trading=display_config[trading_constants.CONFIG_TRADING],
103-
config_trader=display_config[trading_constants.CONFIG_TRADER],
104-
config_trader_simulator=display_config[trading_constants.CONFIG_SIMULATOR],
101+
config_exchanges=display_config[commons_constants.CONFIG_EXCHANGES],
102+
config_trading=display_config[commons_constants.CONFIG_TRADING],
103+
config_trader=display_config[commons_constants.CONFIG_TRADER],
104+
config_trader_simulator=display_config[commons_constants.CONFIG_SIMULATOR],
105105
config_notifications=display_config[
106106
services_constants.CONFIG_CATEGORY_NOTIFICATION],
107107
config_services=display_config[services_constants.CONFIG_CATEGORY_SERVICES],
108108
config_symbols=models.format_config_symbols(display_config),
109-
config_reference_market=display_config[trading_constants.CONFIG_TRADING][
110-
trading_constants.CONFIG_TRADER_REFERENCE_MARKET],
109+
config_reference_market=display_config[commons_constants.CONFIG_TRADING][
110+
commons_constants.CONFIG_TRADER_REFERENCE_MARKET],
111111

112112
real_trader_activated=interfaces_util.has_real_and_or_simulated_traders()[0],
113113

@@ -118,7 +118,7 @@ def config():
118118
notifiers_list=notifiers_list,
119119
symbol_list=sorted(models.get_symbol_list([exchange
120120
for exchange in display_config[
121-
trading_constants.CONFIG_EXCHANGES]])),
121+
commons_constants.CONFIG_EXCHANGES]])),
122122
full_symbol_list=models.get_all_symbols_dict(),
123123
strategy_config=models.get_strategy_config(media_url),
124124
evaluator_startup_config=models.get_evaluators_tentacles_startup_activation(),

Services/Interfaces/web_interface/models/configuration.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
import octobot_trading.modes as trading_modes
2828
import tentacles.Services.Interfaces.web_interface.constants as constants
2929
import octobot_evaluators.constants as evaluators_constants
30+
import octobot_services.interfaces.util as interfaces_util
3031
import octobot_commons.constants as commons_constants
3132
import octobot_commons.logging as bot_logging
32-
import octobot_services.interfaces.util as interfaces_util
3333
import octobot_commons.config_manager as config_manager
3434
import octobot_commons.tentacles_management as tentacles_management
3535
import octobot_backtesting.api as backtesting_api
@@ -536,7 +536,7 @@ def get_exchange_logo(exchange_name):
536536
def get_full_exchange_list(remove_config_exchanges=False):
537537
g_config = interfaces_util.get_global_config()
538538
if remove_config_exchanges:
539-
user_exchanges = [e for e in g_config[trading_constants.CONFIG_EXCHANGES]]
539+
user_exchanges = [e for e in g_config[commons_constants.CONFIG_EXCHANGES]]
540540
full_exchange_list = list(set(ccxt.exchanges) - set(user_exchanges))
541541
else:
542542
full_exchange_list = list(set(ccxt.exchanges))
@@ -563,7 +563,7 @@ def get_other_exchange_list(remove_config_exchanges=False):
563563

564564
def get_current_exchange():
565565
g_config = interfaces_util.get_global_config()
566-
exchanges = g_config[trading_constants.CONFIG_EXCHANGES]
566+
exchanges = g_config[commons_constants.CONFIG_EXCHANGES]
567567
if exchanges:
568568
return next(iter(exchanges))
569569
else:

Trading/Mode/arbitrage_trading_mode/tests/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
import octobot_backtesting.api as backtesting_api
2020
import async_channel.util as channel_util
2121
import octobot_commons.tests.test_config as test_config
22+
import octobot_commons.constants as commons_constants
2223
import octobot_trading.api as trading_api
2324
import octobot_trading.exchange_channel as exchanges_channel
24-
import octobot_trading.constants as trading_constants
2525
import octobot_trading.exchanges as exchanges
2626
import tentacles.Trading.Mode as modes
2727

@@ -31,7 +31,7 @@ async def exchange(exchange_name, backtesting=None, symbol="BTC/USDT"):
3131
exchange_manager = None
3232
try:
3333
config = test_config.load_test_config()
34-
config[trading_constants.CONFIG_SIMULATOR][trading_constants.CONFIG_STARTING_PORTFOLIO]["USDT"] = 2000
34+
config[commons_constants.CONFIG_SIMULATOR][commons_constants.CONFIG_STARTING_PORTFOLIO]["USDT"] = 2000
3535
exchange_manager = exchanges.ExchangeManager(config, exchange_name)
3636

3737
# use backtesting not to spam exchanges apis

Trading/Mode/daily_trading_mode/tests/test_daily_trading_mode_consumer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@
4040
async def _get_tools():
4141
symbol = "BTC/USDT"
4242
config = test_config.load_test_config()
43-
config[trading_constants.CONFIG_SIMULATOR][trading_constants.CONFIG_STARTING_PORTFOLIO][
43+
config[commons_constants.CONFIG_SIMULATOR][commons_constants.CONFIG_STARTING_PORTFOLIO][
4444
"SUB"] = 0.000000000000000000005
45-
config[trading_constants.CONFIG_SIMULATOR][trading_constants.CONFIG_STARTING_PORTFOLIO][
45+
config[commons_constants.CONFIG_SIMULATOR][commons_constants.CONFIG_STARTING_PORTFOLIO][
4646
"BNB"] = 0.000000000000000000005
47-
config[trading_constants.CONFIG_SIMULATOR][trading_constants.CONFIG_STARTING_PORTFOLIO]["USDT"] = 2000
47+
config[commons_constants.CONFIG_SIMULATOR][commons_constants.CONFIG_STARTING_PORTFOLIO]["USDT"] = 2000
4848
exchange_manager = exchanges.ExchangeManager(config, "binance")
4949

5050
# use backtesting not to spam exchanges apis

Trading/Mode/daily_trading_mode/tests/test_daily_trading_mode_producer.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import octobot_evaluators.api as evaluators_api
2626
import octobot_trading.api as trading_api
2727
import octobot_trading.exchange_channel as exchanges_channel
28-
import octobot_trading.constants as trading_constants
2928
import octobot_trading.enums as trading_enums
3029
import octobot_trading.exchanges as exchanges
3130
import tentacles.Trading.Mode as Mode
@@ -36,7 +35,7 @@
3635

3736
async def _get_tools(symbol="BTC/USDT"):
3837
config = test_config.load_test_config()
39-
config[trading_constants.CONFIG_SIMULATOR][trading_constants.CONFIG_STARTING_PORTFOLIO]["USDT"] = 1000
38+
config[commons_constants.CONFIG_SIMULATOR][commons_constants.CONFIG_STARTING_PORTFOLIO]["USDT"] = 1000
4039
exchange_manager = exchanges.ExchangeManager(config, "binance")
4140

4241
# use backtesting not to spam exchanges apis

Trading/Mode/dip_analyser_trading_mode/tests/test_dip_analyser_trading_mode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
async def _get_tools(symbol="BTC/USDT"):
4343
config = test_config.load_test_config()
44-
config[trading_constants.CONFIG_SIMULATOR][trading_constants.CONFIG_STARTING_PORTFOLIO]["USDT"] = 2000
44+
config[commons_constants.CONFIG_SIMULATOR][commons_constants.CONFIG_STARTING_PORTFOLIO]["USDT"] = 2000
4545
exchange_manager = exchanges.ExchangeManager(config, "binance")
4646

4747
# use backtesting not to spam exchanges apis

Trading/Mode/staggered_orders_trading_mode/tests/test_staggered_orders_trading_mode.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import octobot_commons.tests.test_config as test_config
2828
import octobot_trading.api as trading_api
2929
import octobot_trading.exchange_channel as exchanges_channel
30-
import octobot_trading.constants as trading_constants
3130
import octobot_trading.enums as trading_enums
3231
import octobot_trading.exchanges as exchanges
3332
import octobot_trading.personal_data as trading_personal_data
@@ -53,15 +52,15 @@ async def _init_trading_mode(config, exchange_manager, symbol):
5352

5453
async def _get_tools(symbol, btc_holdings=None, additional_portfolio={}, fees=None):
5554
config = test_config.load_test_config()
56-
config[trading_constants.CONFIG_SIMULATOR][trading_constants.CONFIG_STARTING_PORTFOLIO]["USD"] = 1000
57-
config[trading_constants.CONFIG_SIMULATOR][trading_constants.CONFIG_STARTING_PORTFOLIO][
55+
config[commons_constants.CONFIG_SIMULATOR][commons_constants.CONFIG_STARTING_PORTFOLIO]["USD"] = 1000
56+
config[commons_constants.CONFIG_SIMULATOR][commons_constants.CONFIG_STARTING_PORTFOLIO][
5857
"BTC"] = 10 if btc_holdings is None else btc_holdings
59-
config[trading_constants.CONFIG_SIMULATOR][trading_constants.CONFIG_STARTING_PORTFOLIO].update(additional_portfolio)
58+
config[commons_constants.CONFIG_SIMULATOR][commons_constants.CONFIG_STARTING_PORTFOLIO].update(additional_portfolio)
6059
if fees is not None:
61-
config[trading_constants.CONFIG_SIMULATOR][trading_constants.CONFIG_SIMULATOR_FEES][
62-
trading_constants.CONFIG_SIMULATOR_FEES_TAKER] = fees
63-
config[trading_constants.CONFIG_SIMULATOR][trading_constants.CONFIG_SIMULATOR_FEES][
64-
trading_constants.CONFIG_SIMULATOR_FEES_MAKER] = fees
60+
config[commons_constants.CONFIG_SIMULATOR][commons_constants.CONFIG_SIMULATOR_FEES][
61+
commons_constants.CONFIG_SIMULATOR_FEES_TAKER] = fees
62+
config[commons_constants.CONFIG_SIMULATOR][commons_constants.CONFIG_SIMULATOR_FEES][
63+
commons_constants.CONFIG_SIMULATOR_FEES_MAKER] = fees
6564
exchange_manager = exchanges.ExchangeManager(config, "binance")
6665

6766
# use backtesting not to spam exchanges apis
@@ -100,11 +99,11 @@ async def _get_tools(symbol, btc_holdings=None, additional_portfolio={}, fees=No
10099

101100
async def _get_tools_multi_symbol():
102101
config = test_config.load_test_config()
103-
config[trading_constants.CONFIG_SIMULATOR][trading_constants.CONFIG_STARTING_PORTFOLIO]["USD"] = 1000
104-
config[trading_constants.CONFIG_SIMULATOR][trading_constants.CONFIG_STARTING_PORTFOLIO]["USDT"] = 2000
105-
config[trading_constants.CONFIG_SIMULATOR][trading_constants.CONFIG_STARTING_PORTFOLIO]["BTC"] = 10
106-
config[trading_constants.CONFIG_SIMULATOR][trading_constants.CONFIG_STARTING_PORTFOLIO]["ETH"] = 20
107-
config[trading_constants.CONFIG_SIMULATOR][trading_constants.CONFIG_STARTING_PORTFOLIO]["NANO"] = 2000
102+
config[commons_constants.CONFIG_SIMULATOR][commons_constants.CONFIG_STARTING_PORTFOLIO]["USD"] = 1000
103+
config[commons_constants.CONFIG_SIMULATOR][commons_constants.CONFIG_STARTING_PORTFOLIO]["USDT"] = 2000
104+
config[commons_constants.CONFIG_SIMULATOR][commons_constants.CONFIG_STARTING_PORTFOLIO]["BTC"] = 10
105+
config[commons_constants.CONFIG_SIMULATOR][commons_constants.CONFIG_STARTING_PORTFOLIO]["ETH"] = 20
106+
config[commons_constants.CONFIG_SIMULATOR][commons_constants.CONFIG_STARTING_PORTFOLIO]["NANO"] = 2000
108107
exchange_manager = exchanges.ExchangeManager(config, "binance")
109108

110109
# use backtesting not to spam exchanges apis

0 commit comments

Comments
 (0)