Skip to content

JeRuff/solana-trading-bot

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Solana Automated Trading Bot with Jupiter SDK

Solana Logo

Table of Contents

Overview

The Solana Automated Trading Bot is a Python-based application designed to execute automated trading strategies on the Solana blockchain. Leveraging the powerful Jupiter SDK, this bot filters high-potential Solana tokens from Dexscreener, manages trades with predefined milestones and stop-loss parameters, executes trades through the Jupiter API, and implements a Dollar Cost Averaging (DCA) strategy for profit-taking.

Features

  • Token Filtering: Automatically filters Solana tokens based on liquidity, transaction volume, holder distribution, and historical performance.
  • Trade Management: Treats each trade as an independent entity with specific investment percentages, milestones, and stop-loss parameters.
  • Jupiter SDK Integration: Seamlessly executes swaps, manages limit orders, and handles DCA strategies using the Jupiter SDK.
  • Profit-Taking Strategy: Implements a DCA strategy to sell positions at 30%, 65%, and 100% gains.
  • Asynchronous Operations: Utilizes asynchronous programming for efficient and non-blocking execution.
  • Secure Configuration: Stores sensitive information securely using environment variables.

Prerequisites

Before setting up the trading bot, ensure you have the following:

  1. Python Environment: Python 3.7 or higher installed on your system.
  2. Solana Wallet: A Phantom wallet set up with sufficient SOL for transaction fees.
  3. Jupiter SDK Access: Obtain API access credentials if required.
  4. Solana RPC Endpoint: Access to a Solana RPC node (e.g., QuickNode, Alchemy).
  5. Environment Variables: Securely store your private key and other sensitive information.

Installation

  1. Clone the Repository

    git clone https://github.com/yourusername/solana-trading-bot.git
    cd solana-trading-bot
  2. Create a Virtual Environment (Optional but Recommended)

    python3 -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install Required Dependencies

    pip install -r requirements.txt

    requirements.txt:

    jupiter-python-sdk
    solders
    solana
    aiohttp
    base58
    base64
    

Configuration

The bot requires specific environment variables to function securely and effectively. Create a .env file in the root directory of the project and add the following configurations:

PRIVATE_KEY=your_base58_encoded_private_key
SOLANA_RPC_ENDPOINT=https://api.mainnet-beta.solana.com

Important:

  • Never commit your .env file or expose your private key in any public repository.
  • Ensure that the private key corresponds to your Phantom wallet and has sufficient SOL for transaction fees.

To load environment variables from the .env file, you can use the python-dotenv package. Install it and modify your script accordingly:

pip install python-dotenv

Add the following lines at the beginning of your main script:

from dotenv import load_dotenv

load_dotenv()

Usage

  1. Run the Trading Bot

    Ensure that your virtual environment is activated and all dependencies are installed.

    python trading_bot.py
  2. Bot Workflow

    • Token Filtering: The bot fetches the latest Solana token profiles from Dexscreener and filters them based on predefined criteria such as liquidity, transaction count, holder distribution, and historical performance.
    • Trade Setup: For each valid token, the bot sets up trades with specified investment percentages (5%, 10%, 15%, 20%) of the total budget.
    • Trade Execution: Trades are executed using the Jupiter SDK, handling swaps and limit orders as per the strategy.
    • Profit-Taking: Implements a DCA strategy to sell portions of the holdings at 30%, 65%, and 100% gains.
    • Monitoring: Continuously monitors active trades for price changes to manage milestones and stop-loss triggers.
  3. Monitoring and Logs

    The bot prints logs to the console detailing the status of trades, executed transactions, and any errors encountered. For a more robust logging system, consider integrating Python's logging module.

Project Structure

solana-trading-bot/
├── trading_bot.py
├── requirements.txt
├── README.md
└── .env
  • trading_bot.py: The main script containing the trading logic.
  • requirements.txt: Lists all Python dependencies.
  • README.md: Documentation for the project.
  • .env: Stores environment variables (not committed to version control).

Security Considerations

  • Private Key Protection: Your Solana wallet's private key is sensitive. Store it securely using environment variables or secure vault services. Never hard-code it into your scripts or expose it publicly.
  • Environment Variables: Use environment variables to manage configuration settings securely.
  • Error Handling: Implement comprehensive error handling to manage exceptions gracefully and prevent unexpected behavior.
  • Rate Limiting: Be mindful of API rate limits to avoid being throttled or banned. Implement retry mechanisms with exponential backoff if necessary.
  • Testing: Always test your bot in a sandbox or testnet environment with minimal funds before deploying it with significant investments.

Contributing

Contributions are welcome! If you'd like to enhance the bot's functionality or improve its performance, feel free to open an issue or submit a pull request.

  1. Fork the Repository

  2. Create a New Branch

    git checkout -b feature/YourFeatureName
  3. Make Your Changes

  4. Commit Your Changes

    git commit -m "Add some feature"
  5. Push to the Branch

    git push origin feature/YourFeatureName
  6. Open a Pull Request

License

This project is licensed under the MIT License.

Acknowledgements

  • Jupiter SDK for providing a comprehensive SDK for Solana trading.
  • Dexscreener for offering reliable token data on Solana.
  • The Solana and Python communities for their invaluable resources and support.

Disclaimer: Trading cryptocurrencies involves significant risk of loss. This bot is provided for educational purposes only. Use it at your own risk. The developers are not responsible for any losses incurred.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%