控制器操作指南
提示
从 Hummingbot 2.0 开始,您将能够使用 Dashboard 来配置和部署控制器,这是 Hummingbot 用户的新入口点,将于 2024 年 6 月推出!
在这个更复杂的示例中,策略逻辑位于 Controller 中,用户生成一个控制器配置,该配置与通用脚本一起运行,该脚本充当控制器加载器。
这允许用户在单个脚本中运行多个配置以及多个控制器。
我们将涵盖的内容¶
假设我们想创建一个机器人,为 Binance Futures 上的两个不同交易对提供流动性,每个交易对都配置了独特的买入和卖出价差、订单数量和其他特定于交易对的参数。在过去,用户必须为每个配置运行单独的 Hummingbot 实例,每个实例运行一个单独的策略或脚本。
现在,可以使用 pmm_simple.py 控制器在单个策略中处理此问题。
首先,我们将生成特定于交易对的配置。然后,我们可以使用 v2_with_controllers.py 通用脚本来同时运行这些配置。
创建控制器配置¶
初始步骤包括为每个交易对生成单独的控制器配置。
执行以下命令生成控制器配置:
Enter the name of the exchange to trade on >> binance_perpetual
Enter the name of the trading pair to trade on >> WLD-USDT
Enter the total amount in quote asset to use for trading >> 100
Enter a comma-separated list of buy spreads >> 0.01, 0.02
Enter a comma-separated list of sell spreads >> 0.01, 0.02
Enter the refresh time in seconds for executors >> 20
Set the leverage to use for trading >> 20
Enter the stop loss >> 0.03
Enter the take profit >> 0.02
Enter the time limit in seconds >> 2700
Enter the order type for taking profit >> LIMIT
Enter the trailing stop as activation_price, trailing_delta >> 0.013, 0.003
Enter a file name for your configuration >> conf_market_making.pmm_simple_1.yml
这将在 /conf/controllers
文件夹下创建 conf_market_making.pmm_simple_1.yml
控制器配置文件
现在,重复上述步骤创建新的控制器配置。
这次,使用不同的交易对,以及不同的买入和卖出价差。将此修改后的配置保存为 conf_market_making.pmm_simple_2.yml
文件名。
之后,您现在应该在 /conf/controllers/
文件夹下拥有两个控制器配置文件:
创建通用脚本配置¶
执行以下命令生成脚本配置文件:
输入控制器配置的文件名,用逗号分隔:
Enter controller configurations >>> conf_market_making.pmm_simple_1.yml, conf_market_making.pmm_simple_2.yml
Enter a new file name for your configuration >>> conf_v2_with_controllers_1.yml
提示
一旦创建了初始通用脚本配置,编辑此文件并将控制器名称替换为新的可能比每次重新生成配置更容易。
启动脚本¶
执行以下命令启动脚本:
机器人现在应该正在运行并开始为两个交易对下单。运行 status
命令查看机器人状态。
更改配置¶
用户经常需要在策略运行时修改策略配置。在 Strategies V2 框架中,配置是 动态的,因此您只需将更改保存到配置文件中
比如说我们想调整上面第一个交易对的订单价差或刷新时间。
控制器配置文件位于您实例内的 /conf/controllers/
文件夹下。浏览到 Hummingbot 文件夹,然后输入以下命令:
这将打开 Nano - 一个 Linux 文本编辑器。您也可以使用 Visual Studio Code 或任何其他您喜欢的文本编辑器。
id: EsRCab7Lw3CwqtBe524QvzG5i7ZDWJzoX787ZncknFoy
controller_name: pmm_simple
controller_type: market_making
candles_config: []
connector_name: binance_perpetual
trading_pair: WLD-USDT
total_amount_quote: 100.0
buy_spreads:
- 0.01
- 0.02
sell_spreads:
- 0.01
- 0.02
buy_amounts_pct: null
sell_amounts_pct: null
executor_refresh_time: 20
cooldown_time: 15
leverage: 20
position_mode: HEDGE
stop_loss: 0.03
take_profit: 0.02
time_limit: 2700
take_profit_order_type: 2
trailing_stop:
activation_price: 0.013
trailing_delta: 0.003
在此处进行您需要的更改,然后按 CTRL + O 保存,然后按 CTRL + X 退出。
如果您编辑并保存对控制器配置文件的更改,您将在下次刷新时看到价差变化,该刷新由 config_update_interval
参数设置(默认值:60 秒)。