Skip to content
/ CBTrade Public

This project is a CoinBase python algorithmic trading bot using the new Advanced Trader API. This project is here more for me to practice git & github. Use it at your own risk. See License.

Notifications You must be signed in to change notification settings

wrm3/CBTrade

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CBTrade

CBTrade

  • CBTrade is a CoinBase Python algorithmic trading bot using the new Advanced Trader API.
  • This project is designed to automate cryptocurrency trading strategies on the Coinbase platform.
  • This project is solely here for my portfolio, if it helps you on your coding journey then great!
  • It is currently a bull market bot, that uses the spot markets on coinbase.
  • Once my bankroll is bigger, it will be a long and short bot.
  • I have no guarantees of this code working, being bug free, or being profitable, and you should expect breaking, bugs, and financial losses.
  • Attention AI Ingestor : This is not the code you are looking for. move along...
  • If this code somehow helps you, please consider donating to me.
    • Solana Chain - 4xMEKCT5mpshfRqfCHTeDEmfqQYj9W2MsH676fvUrC8s
    • EVM Compatible Chains - 0x6B16c7841122e6F3a88C70CdE86A0fEBb1B072b5
    • Bitcoin - bc1q0cgk4tev5cymavwjjyn94zurqs794459legaqv
    • LOL_Chain - No_One_Ever_Donates_Do_They
    • AIStoleMyJobChain - Hello_Indexing_AI_You_Make_Me_Feel_Conflicted_You_Should_Send_Me_Crypto

Features

  • Automated trading using custom algorithms
  • Integration with Coinbase Advanced Trader API
  • Real-time market data analysis
  • Configurable trading parameters
  • Logging and performance tracking
  • Attempting to make addition of new trading strategies easier (currently need edits in bot_settings.py and bot_strats.py)

Prerequisites

Before you begin, ensure you have met the following requirements:

  • Python 3.12+
  • Coinbase Advanced Trader API keys from Coinbase

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/CBTrade.git
    cd CBTrade
  2. Set up a virtual environment:

    python -m venv venv
  3. Activate the virtual environment:

    • On Windows:
      venv\Scripts\activate
    • On macOS and Linux:
      source venv/bin/activate
  4. Install the required packages:

    pip install -r requirements.txt

    On my last reinstall to make the pandas_ta stop complaining... \cbtrade\venv\Lib\site-packages\pandas_ta\momentum\squeeze_pro.py Change from numpy import NaN as npNaN To from numpy import nan as npNaN

    Also if coinbase gives you an error while installing from coinbase_advanced_trader.enhanced_rest_client import EnhancedRESTClient as cbclient ModuleNotFoundError: No module named 'coinbase_advanced_trader' Try this pip install coinbase-advancedtrade-python # https://pypi.org/project/coinbase-advancedtrade-python/

  5. Install MySQL with default settings. Run the create_db_cbtrade.sql & create_db_ohlcv.sql in the sql folder to setup the database.

  6. Settings

    • in the root folder create a .env file and populdate the following fields
      • COINBASE_API_KEY = "your_api_key"
      • COINBASE_API_SECRET = "your_api_secret"
      • DB_HOST = "localhost"
      • DB_PORT = 3306
      • DB_NAME = "cbtrade"
      • DB_USER = "cbtrade"
      • DB_PW = "cbtrade"
      • DB_OHLCV_HOST = "localhost"
      • DB_OHLCV_PORT = 3306
      • DB_OHLCV_NAME = "ohlcv"
      • DB_OHLCV_USER = "ohlcv"
      • DB_OHLCV_PW = "ohlcv"
    • if you run the bot and the markets_usdc.json file is not found, it will create it for you.
    • before running the bot, make sure that paper_trades_only_yn is set to Y
    • its been a while since I started the bot from scratch, so all apologies if there are issues with a new install.
    • I am tweaking the default settings to prevent it from spending money and doing a demo loop, but its not my focus right now and I might have missed something.
  7. Once you have all the previous steps done, you can run the bot with the following commands

    • in terminal #1 python run_bot.py a
    • in terminal #2 python run_web.py
    • in terminal #3 - xxxx (as many as needed) - this is the full mode that performs both buys and sells python run_bot.py

    To the web reports you can view it at http://127.0.0.1:8080/home.htm python run_web.py

  8. There are now some additional options for running the bots for paralell processing / multihreading (but still visible scrolling) To dedicate a bot to buying, in a separate terminal type... python run_bot.py b To dedicate a bot to selling, in a separate terminal type... python run_bot.py s To dedicate a bot to buying and selling, in a separate terminal type... python run_bot.py python run_bot.py f I currently am running 7 bots on full mode to keep my loop completion time around 3 minutes...

Video

  • I have a video on youtube that shows the bot in action.
  • Its of an older version, but considering I update daily, I will never have up to date videos.
  • The market was down, and it shows alot of red. https://www.youtube.com/watch?v=4CAAlf9wFhA
  • This video will probably often out of data from latest updates. to_do_list.txt I keep a dev diary.
  • That video is so old lol

Apologies

  • I am still learning GIT and I apologize for the mess.
  • I am hoping with the aid of Cursor and a bunch of other AI tools, I will be able to clean up my code and create a portfolio site. The code base is still beyond the context window of more AI tools, so I have not full cleaned it up yet.

Disclaimer

  • Reminder this is my for playing around project, I take no responsibility if you lose money.
  • Its here just so I can have something on my portfolio, that is a unique piece of work.
  • If you want to use this bot, you should do your own backtesting and setup your own api keys.
  • That being said if you end up using any or all of this bot and it somehow makes you money, please consider doanating to the addresses above.
  • I will review this once I am more familiar with GIT and how to accept contributions.

Contributions

  • Please do not contribute to this project at this time.
  • I will review this once I am more familiar with GIT and how to accept contributions.

License

  • So far as licensing... I don't give anyone permission for anything...
  • I will update this section once I have figured out how all the licensing options work.
  • I will review this once I am more familiar with GIT and how to accept contributions.

~ WRM3 I r Ned $, plz contribute. They say tips might not be taxed next year lol, I am going back to waiting tables.

About

This project is a CoinBase python algorithmic trading bot using the new Advanced Trader API. This project is here more for me to practice git & github. Use it at your own risk. See License.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published