This project is a complete, three-part automated trading signal and execution system for the Hyperliquid DEX. It uses a Fibonacci-based strategy to identify potential long entries, displays the data on a web dashboard, and executes trades based on the generated signals.
The system is composed of three core Python scripts that must be run simultaneously in separate terminal windows:
-
collector.py
: This script acts as the data pipeline. It connects to the Hyperliquid API, fetches the price of a configured asset (e.g., SOL) every 60 seconds, and appends the timestamped price to a localprice_data.json
file. -
app.py
: This is a web dashboard built with Dash. It reads the raw data fromprice_data.json
, processes it into 5-minute OHLC candlestick data, calculates rolling Fibonacci support and resistance levels, and displays everything on an interactive chart. It also manages the state logic for generating trade signals. -
trade.py
: This is the execution bot. It continuously monitors atrade_signals.json
file generated byapp.py
. When a valid "buy" signal is detected, it connects to the Hyperliquid exchange, places a market order for a pre-configured size, and logs the transaction totrade_log.json
.
collector.py
: Fetches 1-minute price data and saves it.app.py
: Runs the Dash web server, calculates indicators, and generates trade signals.trade.py
: Executes tradestrade_bot.py
: Runs the trade bot that reads from the .jsonexample_utils.py
: A utility file for connecting to the Hyperliquid SDK.price_data.json
: Stores the raw, 1-minute price data.trade_signals.json
: Stores the latest calculated signal. This file is read bytrade.py
.trade_log.json
: A log of all trade attempts made bytrade.py
.
- Python 3.8+
- Git
git clone <your-repository-url>
cd <your-repository-name>
It's highly recommended to use a virtual environment to manage dependencies.
Windows:
python -m venv venv
.\venv\Scripts\activate
macOS / Linux:
python3 -m venv venv
source venv/bin/activate
Create a file named requirements.txt
with the following content:
dash
pandas
plotly
numpy
hyperliquid-python-sdk
Then, install the packages using pip:
pip install -r requirements.txt
collector.py
&app.py
: Open these files and ensure theCOIN_TO_TRACK
variable is set to the desired asset (e.g., "SOL").trade.py
: Open this file and set theTRADE_USD_SIZE
variable to your desired trade amount in USD.
You must run the three main scripts in the correct order from three separate terminals. Make sure your virtual environment is activated in each terminal.
Terminal 1: Start the Data Collector
python collector.py
Leave this running. It will start creating price_data.json
.
Terminal 2: Start the Dash App
python app.py
This will start the web server. You can view the dashboard at http://127.0.0.1:8050/. Once it has enough data, it will create trade_signals.json
.
Terminal 3: Start the Trading Bot
python trade_bot.py
This bot will now monitor trade_signals.json
and execute trades when a signal appears.