Skip to content

liuchunhao/binance-auto-trading-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Binance Auto Trading Backend

A trading bot for Binance exchange, which is designed to trade cryptocurrencies. The bot is designed to be used with the Binance exchange. It is written in Python and uses the Binance API to interact with the exchange and provide API endpoints for the frontend.

Table of Contents

Features

  • RESTful APIs for interacting with Binance & Exness exchange
    • Order Management
    • Wallet Management
    • Position Management
    • SMS push on mobile
  • WebSocket Server for Real-Time Data
    • Market Data
    • Account Update (Wallet, Position)
  • LINE Bot
    • Daily PnL Report
    • Funding Fee Notification
    • Trading Signal Notification
  • Discord Bot
    • Financial Report
    • ChatBot Integration with LLM
    • Configuration Management
    • Funding Fee Notification
    • Trading Signal Notification
  • Telegram Bot
    • System Monitoring
  • Trading Bot for Binance Exchange
    • Auto Trading

Quick Start

Configuration

# src/.env

# Binace API
API_KEY = '******'
API_SECRET = '*********'

# Telegram Bot
TELEGRAM_TOKEN = '****************'

# LINE Bot
LINE_TOKEN = '**********************'
CHANNEL_ACCESS_TOKEN = '!@#$%^&*'
CHANNEL_SECRET = '123456789qwerasdfzxcv'

# Admin website Login
ADMIN_LOGIN_PASSWORD = 'p@$$w0rd'

# JWT token
JWT_SECRET = '@#$%^&*!'

# Discord bot token 
DISCORD_TOKEN = 'abc.efg.hijk'
DISCORD_WEBHOOK_NOTIFICATION = 'https://discord.com/api/webhooks/***********'
DISCORD_WEBHOOK_ANNOUNCEMENT = 'https://discord.com/api/webhooks/***********'
DISCORD_WEBHOOK_SECRET = 'https://discord.com/api/webhooks/*********'
DISCORD_WEBHOOK_WARNING = 'https://discord.com/api/webhooks/*********'

NUM_OF_UNITS = 9

# number of deposit unit
SIZE_OF_CONTRACTS = 9

# Initial deposit amount (USDT)
DEPOSIT = 9999

# SMS
SMS_APP_MOBILE_LIST = '+886*********,+886***********'
SMS_APP_MOBILE_HB_INTERVAL = 1800

LINE Notify Management

API endpoints on Flask

sh/start_line_bot_server.sh

Real-time data server on Flask

sh/start_ws_server_producer.sh

Position check notify (every 30 seconds)

sh/futures_position_notify.sh

Funding fee notify (every 8 hours)

sh/funding_fee_notify.sh

Account status notify (once a day)

sh/futures_account_status_notify.sh

Stop all services

sh/stop.sh

Run Redis on Docker

cd docker/
docker-compose up -d
docker ps

SQLite


Run ngrok for LINE Webhook

/usr/bin/ngrok http 5000 --log=stdout &

Deployment

# Start up all services
# 00 10 * * * ~/workspace/binance-line-bot/sh/start.sh

# Account report notify per day
# 00 8 * * * ~/workspace/binance-line-bot/sh/futures_account_status_notify.sh > ~/workspace/binance-line-bot/log/futures_account_status_notify.log 2>&1

# Funding fee notify per 8 hours
# 01  0 * * * /home/ubuntu/workspace/binance-line-bot/sh/funding_fee_notify.sh
# 01  8 * * * /home/ubuntu/workspace/binance-line-bot/sh/funding_fee_notify.sh
# 01 16 * * * /home/ubuntu/workspace/binance-line-bot/sh/funding_fee_notify.sh
30 07 * * * ~/workspace/binance-line-bot/sh/funding_fee_notify.sh

# Time sync (Not necessary on AWS)
# * * * * * /usr/bin/uptime > /tmp/uptime

# Clean log
# 0 0 * * 7 rm -f ~/workspace/binance-line-bot/nohup.out
0 0 10 * * rm -f ~/workspace/binance-line-bot/log/*
0 0 10 * * rm -f ~/workspace/react-examples/lege-management/nohup.out
0 0 10 * * rm -f ~/workspace/ngrok/nohup.out

# PnL update notify
* * * * * ~/workspace/binance-line-bot/sh/futures_position_notify.sh

Order Type Support

  • Limit
  • Market
  • Post Only (Maker Only)
  • Stop Limit
  • Stop Market
  • Take Profit Limit
  • Take Profit Market
  • Trailing Stop Market
  • Trailing Stop Limit
  • Iceberg
  • TWAP
  • Scaled Orders

References

About

Auto-trading backend for Binance exchange

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published