Hummingbot Create First Strategy Bot

使用simple_amm策略创建第一个机器人

使用命令:

1
2
3
start --script [SCRIPT NAME]
create --script-config [SCRIPT_FILE]
start --script [SCRIPT_FILE] --conf [SCRIPT_CONFIG_FILE]

初始的文件目录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
(hummingbot) root@vmi2090919:~/hummingbot/conf# tree
.
├── __init__.py
├── conf_client.yml
├── conf_fee_overrides.yml
├── connectors
│   ├── __init__.py
│   ├── mexc.yml
│   └── okx.yml
├── controllers
│   └── __init__.py
├── hummingbot_logs.yml
├── scripts
│   └── __init__.py
└── strategies
└── __init__.py

hummingbot cli中 通过下列指令创建基本策略

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
>>>  create --script-config simple_pmm                                                                                          For more information, please visit https://pyperclip.readthedocs.io/en/latest/introduction.html#not-implemented-erro
r (See log file for stack trace dump)
Exchange where the bot will trade >>> mexc

Trading pair in which the bot will place orders >>> MX-USDT

Order amount (denominated in base asset) >>> 0.01

Bid order spread (in percent) >>> 0.001

Ask order spread (in percent) >>> 0.001

Order refresh time (in seconds) >>> 15

Price type to use (mid or last) >>> mid

Enter a new file name for your configuration >>> conf_simple_pmm_1.yml
A new config file has been created: conf_simple_pmm_1.yml

ps: 配置过程中要终止配置的话,使用快捷键ctrl+x

查看文件目录,新配置已生成

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
(hummingbot) root@vmi2090919:~/hummingbot/conf# tree
.
├── __init__.py
├── conf_client.yml
├── conf_fee_overrides.yml
├── connectors
│   ├── __init__.py
│   ├── mexc.yml
│   └── okx.yml
├── controllers
│   └── __init__.py
├── hummingbot_logs.yml
├── scripts
│   ├── __init__.py
│   └── conf_simple_pmm_1.yml
└── strategies
└── __init__.py

conf_simple_pmm_1.yml 内容

1
2
3
4
5
6
7
8
script_file_name: simple_pmm.py
exchange: mexc
trading_pair: MX-USDT
order_amount: 0.01
bid_spread: 0.001
ask_spread: 0.001
order_refresh_time: 15
price_type: mid

使用start --script simple_pmm --conf conf_simple_pmm_1.yml 启动bot

错误

1
2
3
4
5
6
7
8
9
10
2024-11-15 13:10:31,262 - 2684330 - hummingbot.connector.exchange.mexc.mexc_exchange.MexcExchange - INFO - Network status has changed to NetworkStatus.CONNECTED. Starting networking...
2024-11-15 13:10:31,715 - 2684330 - hummingbot.connector.exchange.mexc.mexc_api_order_book_data_source.MexcAPIOrderBookDataSource - ERROR - Unexpected error occurred subscribing to order book trading and delta streams...
Traceback (most recent call last):
File "/root/hummingbot/hummingbot/connector/exchange/mexc/mexc_api_order_book_data_source.py", line 76, in _subscribe_channels
symbol = await self._connector.exchange_symbol_associated_to_pair(trading_pair=trading_pair)
File "hummingbot/connector/exchange_base.pyx", line 97, in exchange_symbol_associated_to_pair
return symbol_map.inverse[trading_pair]
File "/root/miniconda3/envs/hummingbot/lib/python3.10/site-packages/bidict/_base.py", line 524, in __getitem__
return self._fwdm[key]
KeyError: 'MX-USDT'

Mexc 中并不是所有交易对都支持api交易的,交易对要到https://api.mexc.com/api/v3/defaultSymbols接口中检查下
换了个PNUT-USDT交易对,正常交易了。

关于 PMM with Price Shift and Dynamic Spreads

simple_amm.py 使用的策略

参考资料

关于 PMM with Price Shift and Dynamic Spreads

Author

Gavin

Posted on

2024-11-15

Updated on

2024-11-15

Licensed under

Comments