README.md

June 2, 2023 ยท View on GitHub

binance-dca-bot

A dollar cost averaging bot for the Binance Cryptocurrency Exchange.

About

This bot allows you to schedule recurring buy orders for any trading pair available on the Binance cryptocurrency exchange.

What is dollar cost averaging? Dollar cost averaging DCA refers to the practice of investing fixed amounts at regular intervals (for instance, $20 every week). This is a strategy used by investors that wish to reduce the influence of volatility over their investment and, therefore, reduce their risk exposure.

Getting Started

Prerequisites

Installation

  1. Get your Binance API keys. You can learn how to from this tutorial

  2. Clone the repo

    git clone https://github.com/MlkMahmud/binance-dca-bot.git
    
  3. Install dependencies

    cd binance-dca-bot
    npm install
    

Configure environment varibles

Environment KeyDescriptionSample ValueRequired
BINANCE_API_KEYBinance API keyfrom BinanceTrue
BINANCE_API_SECRETBinance API secretfrom BinanceTrue
BINANCE_TESTNET_ENABLEDEnable/Disable Binance test mode (defaults to true). You must explicitly set this value to false if you want to run the bot in live modetrue/falseFalse
DB_URLA valid MongoDB connection string. Learn moremongodb://mongodb0.example.com:27017True
JWT_SECRETA string or buffer containing either the secret for HMAC algorithms, or the PEM encoded public key for RSA and ECDSAhelloiamasecretkeyTrue
PORTThe port you want your server to listen on3000False
SENTRY_AUTH_TOKENThe authentication token to use for all communication with Sentry.from SentryFalse
SENTRY_DSNThe Data Source Name (DSN) to use to connect to Sentryfrom SentryFalse
SENTRY_ENABLEDEnable/Disable SentrytrueFalse
SENTRY_RELEASEA release is a version of your code deployed to an environment. When you notify Sentry about a release, you can easily identify new issues, regressions, whether an issue is resolved in the next release, and apply source maps. Learn morev0.0.1False
SENTRY_ORGThe slug of the organization to use for a commandfrom SentryFalse
SENTRY_PROJECTThe slug of the project to use for a command.from SentryFalse
SLACK_ENABLEDEnable/Disable Slack notificationstrueFalse
SLACK_WEBHOOK_URLYour Slack webhook URLfrom SlackFalse
TELEGRAM_ENABLEDEnable/Disable Telegram notificationstrueFalse
TELEGRAM_BOT_TOKENAuthentication token for your Telegram Botfrom TelegramFalse
TELEGRAM_CHAT_IDThe ID for your Telegram Group/Channelfrom TelegramFalse
TIMEZONEThe default timezone to use for the job scheduler (must be moment compatible)Africa/LagosFalse

Run the bot

To start the bot in developement mode run

npm run dev

N.B. This command loads environment variables from the .env, if it exists

To start the bot in production mode run

npm run build
npm start

N.B. This command does not load env variables from the .env file, even if it exists.

Deployment

There are no strong constraints regarding deployments. The bot is a Next.js application powered by a custom Express server, so there are a myriad of options to choose from. I personally host my mine on an Azure Virtual Machine and I automate my deployments using GitHub Actions.

Some of my personal favourite options for deployment:

Features

Portfolio

View up to date balance of all assets in your portfolio

Authentication

Enable password

Update password

Disable password

Jobs

Create a new job

Edit an existing Job

Pause/Resume a Job

Delete a job

View Job order history

Notifications

Enable Slack and Telegram Notifications

Todo

  • Fix: unpausing a job causes the job to run immediately, instead of waiting for next scheduled interval.

Built with

Disclaimer

Please, use at your own discretion. I will not be liable for any losses or hardship incurred from using this bot. โœŒ

License

Distributed under the MIT License. See LICENSE for more information.