Skip to content

CableKungZ/autoDCA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

17 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– AutoDCA

Automated Dollar Cost Averaging bot for Binance and Bitkub

πŸ‡ΉπŸ‡­ ΰΈ ΰΈ²ΰΈ©ΰΈ²ΰΉ„ΰΈ—ΰΈ’

License: CC BY-NC 4.0 Python FastAPI Vue.js Docker PostgreSQL

100% self-hosted Β· No cloud dependency Β· Just docker compose up -d


✨ Features

Feature Detail
🏦 Multi-Exchange Binance (USDT pairs) and Bitkub (THB pairs)
⏰ Flexible Schedule Daily / Weekly / Monthly / Every N hours
πŸ“ˆ Buy & Sell Market, Limit, Percent of Holdings
πŸ“Š Live Stats Avg Cost, Unrealized PnL, Holdings per plan
πŸ”„ THB/USDT Toggle Automatic cross-currency conversion
πŸ”” Telegram Alerts Notifications for every buy/sell order
πŸ”’ Secure API keys encrypted with Fernet before storage
🌐 Web UI Dashboard, Plans, Orders, Settings

πŸš€ Quick Start

Prerequisites

1. Clone

git clone https://github.com/CableKungZ/autoDCA.git
cd autoDCA

2. Configure Environment

cp .env.example .env

Edit .env:

POSTGRES_PASSWORD=your_strong_password
FERNET_KEY=                   # ← see how to generate below
BINANCE_API_KEY=
BINANCE_API_SECRET=
BITKUB_API_KEY=
BITKUB_API_SECRET=
TELEGRAM_BOT_TOKEN=           # optional
TELEGRAM_CHAT_ID=             # optional

Generate Fernet Key:

python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"

3. Run πŸŽ‰

docker compose up -d

First build takes ~2-5 minutes

4. Open

Service URL
🌐 Web UI http://localhost:3333
πŸ“– API Docs http://localhost:8888/docs

βš™οΈ Exchange API Keys Setup

🟑 Binance
  1. Go to Binance API Management
  2. Create a new API Key
  3. Enable Spot & Margin Trading permission
  4. Whitelist your server IP β†’ find it at Settings β†’ Server Public IP
🟒 Bitkub
  1. Go to Bitkub API
  2. Create a new API Key
  3. Enable Trading permission
  4. Whitelist your server IP β†’ find it at Settings β†’ Server Public IP

πŸ“– Usage

Create a DCA Plan

  1. Go to Plans β†’ click + New Plan
  2. Select Exchange β†’ Select Pair β†’ Set amount per order
    • Binance β‰₯ 5 USDT Β· Bitkub β‰₯ 10 THB
  3. Set Schedule β†’ click Create

Buy Now

Click Buy Now on the Plans page to execute immediately without waiting for the schedule.

Sell

Click Sell to open the Sell modal:

  • ⚑ Market β€” Sell at current market price instantly
  • 🎯 Limit β€” Set a target price to sell at
  • % Percent β€” Sell a percentage of your holdings

🐳 Docker Commands

# Start
docker compose up -d

# Stop
docker compose down

# View logs
docker compose logs -f api
docker compose logs -f scheduler

# Rebuild after code changes
docker compose up -d --build

# Check status
docker compose ps

πŸ—‚οΈ Project Structure

autoDCA/
β”œβ”€β”€ 🐳 docker-compose.yml
β”œβ”€β”€ πŸ“„ .env.example
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ models/         # SQLAlchemy models
β”‚   β”‚   β”œβ”€β”€ routers/        # FastAPI endpoints
β”‚   β”‚   β”œβ”€β”€ services/       # exchange, dca_engine, telegram
β”‚   β”‚   └── scheduler/      # APScheduler jobs
β”‚   └── alembic/            # DB migrations
└── frontend/
    └── src/
        β”œβ”€β”€ views/          # Dashboard, Plans, Orders, Settings
        └── components/     # OrderTable, SellModal, SchedulePicker

πŸ”§ Troubleshooting

API not responding
docker compose logs api --tail=50
Orders stuck at Pending

Go to Orders page β†’ click Clear Pending

Binance / Bitkub 401 Unauthorized
  • Check API Key and Secret in .env
  • Whitelist your server IP (find it at Settings β†’ Server Public IP)
  • Re-run docker compose up -d after editing .env
Docker build fails (DNS error)

Edit ~/.docker/daemon.json:

{
  "dns": ["8.8.8.8", "1.1.1.1"]
}

Then restart Docker Desktop.


πŸ› οΈ Tech Stack

Layer Technology
Backend Python 3.12 + FastAPI
Scheduler APScheduler
Database PostgreSQL 16
Cache / Lock Redis 7
Frontend Vue 3 + Vite + TailwindCSS
Reverse Proxy Nginx
Container Docker Compose

πŸ“œ License

This project is licensed under CC BY-NC 4.0

Action Allowed
βœ… Personal use Yes
βœ… Modify / Adapt Yes (credit required)
βœ… Redistribute Yes (credit required)
❌ Commercial use Strictly prohibited

License: CC BY-NC 4.0


Made with β˜• by CableKungZ

⭐ Star this repo if you find it useful!

About

Self-hosted DCA bot for Binance & Bitkub β€” schedule automatic buys, track PnL, sell via UI. Runs locally with Docker. πŸ‡ΉπŸ‡­

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors