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

Feat/Create Cross-Exchange MM configuration schema #240

Merged
merged 34 commits into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5f7a91b
(refactor) config map
May 18, 2022
ad4456d
(feat) refactoring
May 18, 2022
287eb28
(feat) fix
May 18, 2022
686ac6b
(feat) fix
May 18, 2022
d8f05b9
(feat) refactor
May 18, 2022
f2a2fbb
(feat) tests
May 19, 2022
e8200ad
(feat) refactor
May 19, 2022
f572aa5
(feat) removed XEMM from test
May 19, 2022
8e0d4ba
(feat) descriptions
May 19, 2022
3991509
Update hummingbot/client/config/config_data_types.py
mhrvth May 19, 2022
1b68a12
Update hummingbot/client/config/config_data_types.py
mhrvth May 19, 2022
c824fd8
Update hummingbot/strategy/cross_exchange_market_making/cross_exchang…
mhrvth May 19, 2022
0f153a8
Merge branch 'feat/xemm_config_map' of https://github.com/CoinAlpha/h…
May 19, 2022
a5dc6d1
(fix) create command
May 20, 2022
9096f07
(fix) avellaneda
May 20, 2022
ef51651
(fix) OOP submodels & tests
May 20, 2022
88fc62e
(feat) config template yml deleted
May 20, 2022
1bd670a
Merge branch 'epic/config_management_refactoring' into feat/xemm_conf…
May 20, 2022
696b67f
(feat) validate_decimal()
May 20, 2022
31b76f9
(feat) config map pydantic tests
May 20, 2022
7ec1c00
(feat) config map pydantic tests
May 20, 2022
ee8e5f3
(feat) test yml
May 20, 2022
7fe3b80
Update hummingbot/strategy/cross_exchange_market_making/cross_exchang…
mhrvth May 23, 2022
0626eb1
Update hummingbot/strategy/cross_exchange_market_making/cross_exchang…
mhrvth May 23, 2022
74dc84e
Update hummingbot/strategy/cross_exchange_market_making/cross_exchang…
mhrvth May 23, 2022
f846b7c
Update hummingbot/strategy/cross_exchange_market_making/cross_exchang…
mhrvth May 23, 2022
276a85f
Update hummingbot/strategy/cross_exchange_market_making/cross_exchang…
mhrvth May 23, 2022
3bd6b41
(feat) fix
May 23, 2022
741f029
(feat) migration script
May 23, 2022
962bcc7
(feat) migration script improvements
May 23, 2022
664fea8
(feat) migration script refactor
May 24, 2022
cb35681
(feat) remove double logging
May 24, 2022
eba99d4
Update hummingbot/client/config/conf_migration.py
mhrvth May 24, 2022
e5133d2
(feat) improvements
May 24, 2022
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
54 changes: 51 additions & 3 deletions hummingbot/client/config/conf_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
from hummingbot import root_path
from hummingbot.client.config.config_crypt import BaseSecretsManager, store_password_verification
from hummingbot.client.config.config_data_types import BaseConnectorConfigMap
from hummingbot.client.config.config_helpers import ClientConfigAdapter
from hummingbot.client.config.config_helpers import ClientConfigAdapter, save_to_yml
from hummingbot.client.config.security import Security
from hummingbot.client.config.xemm_migration import migrate_xemm_confs
from hummingbot.client.settings import CONF_DIR_PATH, STRATEGIES_CONF_DIR_PATH
from hummingbot.strategy.cross_exchange_market_making.cross_exchange_market_making_config_map_pydantic import (
CrossExchangeMarketMakingConfigMap,
)

encrypted_conf_prefix = "encrypted_"
encrypted_conf_postfix = ".json"
Expand All @@ -29,7 +31,6 @@ def migrate_configs(secrets_manager: BaseSecretsManager) -> List[str]:
migrate_strategy_confs_paths()
mhrvth marked this conversation as resolved.
Show resolved Hide resolved
errors.extend(migrate_connector_confs(secrets_manager))
store_password_verification(secrets_manager)
migrate_xemm_confs()
logging.getLogger().info("\nConf migration done.")
else:
logging.getLogger().error("\nConf migration failed.")
Expand Down Expand Up @@ -75,9 +76,56 @@ def migrate_strategy_confs_paths():
if "strategy" in conf and _has_connector_field(conf):
new_path = strategies_conf_dir_path / child.name
child.rename(new_path)
if conf["strategy"] == "cross_exchange_market_making":
petioptrv marked this conversation as resolved.
Show resolved Hide resolved
migrate_xemm_confs()
logging.getLogger().info(f"Migrated conf for {conf['strategy']}")


def migrate_xemm_confs():
logging.getLogger().info("\nMigrating strategies...")
for child in strategies_conf_dir_path.iterdir():
if child.is_file() and child.name.endswith(".yml"):
with open(str(child), "r") as f:
conf = yaml.safe_load(f)
if "strategy" in conf:
if conf["strategy"] == "cross_exchange_market_making":
if "active_order_canceling" in conf:
if conf["active_order_canceling"]:
conf["order_refresh_mode"] = {}
else:
conf["order_refresh_mode"] = {
"cancel_order_threshold": conf["cancel_order_threshold"],
"limit_order_min_expiration": conf["limit_order_min_expiration"]
}
conf.pop("active_order_canceling")
conf.pop("cancel_order_threshold")
conf.pop("limit_order_min_expiration")

if "use_oracle_conversion_rate" in conf:
if conf["use_oracle_conversion_rate"]:
conf["conversion_rate_mode"] = {}
else:
conf["conversion_rate_mode"] = {
"taker_to_maker_base_conversion_rate": conf["taker_to_maker_base_conversion_rate"],
"taker_to_maker_quote_conversion_rate": conf["taker_to_maker_quote_conversion_rate"]
}
conf.pop("use_oracle_conversion_rate")
conf.pop("taker_to_maker_base_conversion_rate")
conf.pop("taker_to_maker_quote_conversion_rate")

if "template_version" in conf:
conf.pop("template_version")

try:
config_map = ClientConfigAdapter(CrossExchangeMarketMakingConfigMap(**conf))

save_to_yml(child.absolute(), config_map)

logging.getLogger().info(f"Migrated conf for {conf['strategy']}")
except Exception as e:
logging.getLogger().error(str(e))
petioptrv marked this conversation as resolved.
Show resolved Hide resolved


def _has_connector_field(conf: Dict) -> bool:
return (
"exchange" in conf
Expand Down
91 changes: 0 additions & 91 deletions hummingbot/client/config/xemm_migration.py

This file was deleted.