Skip to content

An automated script for recurring Bitcoin purchases on Binance using a Dollar-Cost Averaging (DCA) strategy.

Notifications You must be signed in to change notification settings

igorsoares/bitcoin-dca

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Shell Script

bitcoin-dca

Bitcoin Dollar Cost Averaging Script

Description

This script has been built using Shell Script and Python. The main goal is to automate the process of buying this asset on Binance through the cron service , which is typically a native service on Linux-based systems.

Requirements

  • Python 3.14.2 && python3.12-venv
  • Linux environment
  • Cron service

Motivation

This script was built primarily to run on a Linux-based system alongside the cron service, such as a VPS, Raspberry Pi, or server, where it can run continuously.

Why Python and Shell Script ?

  • Simplicity
  • Low resource consumption
  • Ideal for VPSs and Raspberry Pi devices
  • More flexibility and control over your orders and logs

Roadmap

Below are the upcoming planned features:

  • Implement a Telegram bot: This bot will notify the user of the current operation status when the script runs.
  • Update the API authentication method: Migrate from HMAC (current method) to Ed25519 , which provides a more secure communication mechanism.

It's possible to track this roadmap in the issues tab.

Installation

Before running setup.sh, ensure that the cron service is installed and enabled on your system.

Debian / Ubuntu (apt)

sudo apt update -y && \
sudo apt install cron && \
sudo systemctl enable cron && \
sudo systemctl start cron

Fedora (dnf)

sudo dnf update -y && \
sudo dnf install cronie -y && \
sudo systemctl enable crond && \
sudo systemctl start crond

Arch (pacman)

sudo pacman -Syu --noconfirm && \
sudo pacman -S cronie --noconfirm && \
sudo systemctl enable cronie && \
sudo systemctl start cronie

How to execute

1- Execution permission for setup.sh

chmod +x ./setup.sh

2- Execute the setup shell script

sudo ./setup.sh

How to uninstall

chmod +x ./uninstall.sh && sudo ./uninstall.sh

Contribute

If you wish to contribute to this script, you're more than welcome.

Before you start it is mandatory that you understand how the project structure works.

Below are the main directories and files you must be familiar with:

  • /etc/cron.d/: Directory repsonsible for storing all schedules jobs.
  • /var/log/bitcoindca/: Directory responsible for storing execution logs of this script, including all operations and their statuses.
  • /etc/default/btcdca/: Directory responsible for storing the Binance API secrets.
    • The secret file is stored with 600 permissions and is acessible only by the root user.
  • /usr/local/bin/dca_operation.py: File responsible executing the buy order itself.
    • It receives an argument (--amount or -A) passed from the cron configuration files located in /etc/cron.d/

About

An automated script for recurring Bitcoin purchases on Binance using a Dollar-Cost Averaging (DCA) strategy.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published