操作指南:控制器
提示
从Hummingbot 2.0开始,您将能够使用仪表板(Dashboard)来配置和部署控制器,这是将于 2024 年 6 月推出的 Hummingbot 新入口!
在这个更复杂的示例中,策略逻辑被封装在控制器(Controller)中,用户生成一个控制器配置,并通过一个通用脚本运行该配置,该脚本充当控制器加载器。
这使得用户可以在单个脚本中运行多个配置以及多个控制器。

我们将介绍的内容¶
假设我们想要创建一个机器人,为币安期货上的两个不同交易对提供流动性,每个交易对都配置了独特的买卖价差、订单数量和其他特定于交易对的参数。在过去,用户必须为每个配置运行独立的 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命令查看机器人状态。
修改配置¶
用户经常需要在策略运行时修改其配置。在策略 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 秒)。
 
                


