Skip to content

This baby is a hyperliquid state machine fib bot that reads signals from a .json and makes a cool chart for you.

Notifications You must be signed in to change notification settings

alanwatts07/Hyperliquid-State-Machine-Bot

Repository files navigation

Hyperliquid Fibonacci Trading Bot

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.


How It Works

The system is composed of three core Python scripts that must be run simultaneously in separate terminal windows:

  1. 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 local price_data.json file.

  2. app.py: This is a web dashboard built with Dash. It reads the raw data from price_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.

  3. trade.py: This is the execution bot. It continuously monitors a trade_signals.json file generated by app.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 to trade_log.json.

File Descriptions

  • 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 trades
  • trade_bot.py: Runs the trade bot that reads from the .json
  • example_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 by trade.py.
  • trade_log.json: A log of all trade attempts made by trade.py.

Setup and Installation

1. Prerequisites

  • Python 3.8+
  • Git

2. Clone the Repository

git clone <your-repository-url>
cd <your-repository-name>

3. Set Up a Virtual Environment

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

4. Install Dependencies

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

5. Configuration

  • collector.py & app.py: Open these files and ensure the COIN_TO_TRACK variable is set to the desired asset (e.g., "SOL").
  • trade.py: Open this file and set the TRADE_USD_SIZE variable to your desired trade amount in USD.

How to Run the Bot

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.

About

This baby is a hyperliquid state machine fib bot that reads signals from a .json and makes a cool chart for you.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages