Skip to content

Commit 5a455e0

Browse files
authored
Merge pull request hummingbot#7552 from hummingbot/staging
sync / staging -> master for Hummingbot version 2.5.0
2 parents 2124b71 + d1164b2 commit 5a455e0

File tree

346 files changed

+10311
-9011
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

346 files changed

+10311
-9011
lines changed

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
**Before submitting this PR, please make sure**:
22

33
- [ ] Your code builds clean without any errors or warnings
4+
- [ ] Tests all pass
45
- [ ] You are using approved title ("feat/", "fix/", "docs/", "refactor/")
56

67
**A description of the changes proposed in the pull request**:
@@ -13,4 +14,3 @@
1314

1415
**Tips for QA testing**:
1516

16-

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,5 @@ coverage.xml
9292
# External SDK files
9393
/**/.chain_cookie
9494
/**/.injective_cookie
95+
96+
.env

CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@
1818

1919
**Note:** Tests are crucial. If your pull request contains new, testable behavior, please submit tests. Refer to the 'Unit Test Coverage' section for more information.
2020

21+
## Development Environment Setup
22+
23+
### IDE Configuration
24+
If you're using VS Code or Cursor IDE, please refer to our [VS Code/Cursor Setup Guide](./CURSOR_VSCODE_SETUP.md) for detailed instructions on setting up your development environment, including:
25+
- VS Code/Cursor settings configuration
26+
- Debugging setup
27+
- Test discovery configuration
28+
2129
## Detailed Workflow
2230

2331
### 1. Fork the Repository

CURSOR_VSCODE_SETUP.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
## VS Code/Cursor Setup Guide for Hummingbot Testing
2+
3+
This guide outlines how to configure VS Code or Cursor to efficiently run and debug Hummingbot tests
4+
5+
**I. Prerequisites:**
6+
7+
* **Hummingbot Repository:** You have cloned the Hummingbot repository to your local machine.
8+
* **Conda Environment:** You have created and activated the `hummingbot` Conda environment with all necessary dependencies installed.
9+
10+
**II. Required Files and Configuration:**
11+
12+
Ensure the following files exist in your Hummingbot project directory with the specified content.
13+
14+
**1. `.env` (Project Root Directory):**
15+
16+
```
17+
PYTHONPATH=${PYTHONPATH}:${PWD}
18+
CONDA_ENV=hummingbot
19+
```
20+
21+
* **`PYTHONPATH`**: This ensures that Python can find the Hummingbot modules within your project directory.
22+
* **`CONDA_ENV`**: This variable can be used by other tools or scripts to identify the active Conda environment.
23+
24+
**2. `.vscode/settings.json` (Create this directory and file if it doesn't exist):**
25+
26+
```json
27+
{
28+
"python.testing.pytestEnabled": true,
29+
"python.testing.pytestArgs": [
30+
"test",
31+
// "-v", // optional: verbose output
32+
33+
// From MakeFile (currently broken tests - KEEP UPDATED)
34+
"--ignore=test/hummingbot/connector/derivative/dydx_v4_perpetual/",
35+
"--ignore=test/hummingbot/connector/derivative/injective_v2_perpetual/",
36+
"--ignore=test/hummingbot/connector/exchange/injective_v2/",
37+
"--ignore=test/hummingbot/remote_iface/",
38+
"--ignore=test/connector/utilities/oms_connector/",
39+
"--ignore=test/hummingbot/strategy/amm_arb/",
40+
41+
// Skip prompt tests that modify conf_client.yml
42+
"--ignore=test/hummingbot/client/command/test_create_command.py",
43+
],
44+
"python.envFile": "${workspaceFolder}/.env",
45+
"python.pythonPath": "${config:python.defaultInterpreterPath}" // Ensure correct Python interpreter
46+
}
47+
```
48+
49+
50+
**3. `.vscode/launch.json` (Create this directory and file if it doesn't exist):**
51+
52+
```json
53+
{
54+
"version": "0.2.0",
55+
"configurations": [
56+
{
57+
"name": "Python: Hummingbot",
58+
"type": "debugpy",
59+
"request": "launch",
60+
"program": "${workspaceRoot}/bin/hummingbot.py",
61+
"console": "integratedTerminal"
62+
}
63+
]
64+
}
65+
```
66+
67+
* This configuration allows you to run and debug the main Hummingbot application directly from VS Code/Cursor.
68+
69+
**III. Setup Steps in VS Code/Cursor:**
70+
71+
1. **Open the Hummingbot Project:** Open the root directory of your cloned Hummingbot repository in VS Code or Cursor.
72+
73+
2. **Select the Python Interpreter:**
74+
* Open the Command Palette: Press `Ctrl+Shift+P` (Windows/Linux) or `Cmd+Shift+P` (macOS).
75+
* Type "Python: Select Interpreter" and press Enter.
76+
* A list of available Python interpreters will appear. **Select the Python interpreter associated with your `hummingbot` Conda environment.** The path should typically include the name of your Conda environment.
77+
78+
3. **Ensure `.env` is Loaded:** VS Code/Cursor should automatically load the `.env` file specified in `settings.json`. You can verify this by checking the Python environment variables within the IDE's terminal or debug configurations.
79+
80+
4. **Fix Test Discovery (Conda Environment Issue):**
81+
* Open your terminal.
82+
* Run the following commands to create a symbolic link to work around a known Conda environment detection issue:
83+
```bash
84+
mkdir -p ~/anaconda3/envs/hummingbot/envs
85+
ln -s ~/anaconda3/envs/hummingbot/ ~/anaconda3/envs/hummingbot/envs/hummingbot
86+
```
87+
**Note:** Adjust `~/anaconda3/envs/hummingbot` to the actual path of your `hummingbot` Conda environment if it's located elsewhere.
88+
89+
**IV. Running Tests:**
90+
91+
1. **Open the Testing View:** In the VS Code/Cursor Activity Bar (usually on the left), click on the **Testing icon** (it often looks like a flask or a beaker).
92+
93+
2. **Discover Tests:** If the tests are not automatically discovered, you might see a prompt to configure testing. Ensure pytest is selected and the `test` directory is specified as the test source. VS Code/Cursor should then discover the tests based on your `settings.json`.
94+
95+
3. **Run Tests:**
96+
* You will see a list of discovered tests in the Testing View, organized by file and test function.
97+
* **Run All Tests:** Click the "Run All Tests" button (usually a play icon at the top).
98+
* **Run Specific Tests:** You can run individual test files, test classes, or specific test functions by right-clicking on them in the Testing View and selecting "Run".
99+
100+
4. **View Test Results:** The Testing View will display the status of each test (passed, failed, skipped). You can click on a failed test to see the error output and navigate to the test code.
101+
102+
**V. Debugging Tests:**
103+
104+
1. **Set Breakpoints:** In your test files or the Hummingbot code you want to debug, click in the gutter (the space to the left of the line numbers) to set breakpoints.
105+
106+
2. **Run Tests in Debug Mode:**
107+
* In the Testing View, right-click on the test(s) you want to debug and select "Debug".
108+
* VS Code/Cursor will start the debugger and stop at your breakpoints, allowing you to inspect variables, step through code, and understand the flow of execution.
109+
110+
**VI. Notes on Ignored Tests:**
111+
112+
* **Broken Tests (Makefile):** The `--ignore` flags in `settings.json` exclude tests that are currently known to be broken (as indicated in the project's `Makefile`). **It is crucial to regularly review and update this list if the status of these tests changes.**
113+
* **`test_create_command.py`:** Tests in `test_create_command.py` are ignored because they modify the `conf_client.yml` file. Running these tests locally can potentially interfere with your Hummingbot configuration. If you make changes that could affect these commands, ensure your Pull Request (PR) will pass the automated tests, as they might be run in the CI environment.
114+
115+
By following these steps, you can effectively use VS Code or Cursor to run and debug Hummingbot tests, leveraging the IDE's features for a more integrated and potentially more efficient testing experience, especially when debugging is required. Remember to keep the ignored tests list up-to-date with the `Makefile` to maintain consistency.

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ COPY README.md .
2828
SHELL [ "/bin/bash", "-lc" ]
2929
RUN echo "conda activate hummingbot" >> ~/.bashrc
3030

31+
COPY setup/pip_packages.txt /tmp/pip_packages.txt
32+
RUN python3 -m pip install --no-deps -r /tmp/pip_packages.txt && \
33+
rm /tmp/pip_packages.txt
34+
35+
3136
RUN python3 setup.py build_ext --inplace -j 8 && \
3237
rm -rf build/ && \
3338
find . -type f -name "*.cpp" -delete

Makefile

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@
88
.PHONY: uninstall
99
.PHONY: clean
1010
.PHONY: build
11+
.PHONY: run-v2
1112

1213
test:
1314
coverage run -m pytest \
1415
--ignore="test/mock" \
15-
--ignore="test/connector/utilities/*" \
16-
--ignore="test/hummingbot/connector/derivative/dydx_v4_perpetual" \
17-
--ignore="test/hummingbot/connector/derivative/kucoin_perpetual" \
18-
--ignore="test/hummingbot/connector/derivative/okx_perpetual" \
19-
--ignore="test/hummingbot/strategy/amm_arb/"
16+
--ignore="test/hummingbot/connector/derivative/dydx_v4_perpetual/" \
17+
--ignore="test/hummingbot/remote_iface/" \
18+
--ignore="test/connector/utilities/oms_connector/" \
19+
--ignore="test/hummingbot/strategy/amm_arb/" \
20+
--ignore="test/hummingbot/strategy/cross_exchange_market_making/" \
2021

2122
run_coverage: test
2223
coverage report
@@ -44,3 +45,9 @@ uninstall:
4445

4546
build:
4647
./compile
48+
49+
run-v2:
50+
./bin/hummingbot_quickstart.py -p a -f v2_with_controllers.py -c $(filter-out $@,$(MAKECMDGOALS))
51+
52+
%:
53+
@:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ Currently, the master branch of Hummingbot also includes the following exchange
6161
|----|------|-------|------|------|----------|
6262
| `ascend_ex` | AscendEx | CEX | CLOB Spot | [Docs](https://hummingbot.org/exchanges/ascendex/) | - |
6363
| `balancer` | Balancer | DEX | AMM | [Docs](https://hummingbot.org/exchanges/balancer/) | - |
64+
| `bing_x` | BingX | CEX | CLOB Spot | [Docs](https://hummingbot.org/exchanges/bing_x/) | - |
6465
| `bitget_perpetual` | Bitget | CEX | CLOB Perp | [Docs](https://hummingbot.org/exchanges/bitget-perpetual/) | - |
6566
| `bitmart` | BitMart | CEX | CLOB Spot | [Docs](https://hummingbot.org/exchanges/bitmart/) | - |
6667
| `bitrue` | Bitrue | CEX | CLOB Spot | [Docs](https://hummingbot.org/exchanges/bitrue/) | - |

bin/hummingbot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ def main():
8686
secrets_manager_cls = ETHKeyFileSecretManger
8787

8888
try:
89-
ev_loop: asyncio.AbstractEventLoop = asyncio.get_event_loop()
90-
except Exception:
89+
ev_loop: asyncio.AbstractEventLoop = asyncio.get_running_loop()
90+
except RuntimeError:
9191
ev_loop: asyncio.AbstractEventLoop = asyncio.new_event_loop()
9292
asyncio.set_event_loop(ev_loop)
9393

bin/hummingbot_quickstart.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ def main():
160160
secrets_manager = secrets_manager_cls(args.config_password)
161161

162162
try:
163-
ev_loop: asyncio.AbstractEventLoop = asyncio.get_event_loop()
164-
except Exception:
163+
ev_loop: asyncio.AbstractEventLoop = asyncio.get_running_loop()
164+
except RuntimeError:
165165
ev_loop: asyncio.AbstractEventLoop = asyncio.new_event_loop()
166166
asyncio.set_event_loop(ev_loop)
167167

conf/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@
9090
gate_io_api_key = os.getenv("GATE_IO_API_KEY")
9191
gate_io_secret_key = os.getenv("GATE_IO_SECRET_KEY")
9292
93+
# Mexc Tests
94+
mexc_api_key = os.getenv("MEXC_API_KEY")
95+
mexc_api_secret = os.getenv("MEXC_API_SECRET")
96+
9397
# Wallet Tests
9498
test_erc20_token_address = os.getenv("TEST_ERC20_TOKEN_ADDRESS")
9599
web3_test_private_key_a = os.getenv("TEST_WALLET_PRIVATE_KEY_A")

0 commit comments

Comments
 (0)