MCPcopy
hub / github.com/Haehnchen/crypto-trading-bot

github.com/Haehnchen/crypto-trading-bot @main sqlite

repository ↗ · DeepWiki ↗
767 symbols 1,552 edges 101 files 90 documented · 12%
README

Crypto Trading Bot

Build Status

A cryptocurrency trading bot supporting multiple exchanges via CCXT.

Not production ready only basic functionality

Features

  • Multi pair support in one instance
  • sqlite3 storage for candles, tickers, ...
  • Webserver UI with dashboard
  • Support for going "Short" and "Long"
  • Signal browser dashboard for pairs
  • Slack, Telegram and email notification
  • Profile-based bot management with strategy execution
  • CCXT-based exchange support (100+ exchanges)

Technical stuff and packages

How to use

[optional] Preinstall

For building sqlite and indicators libraries (if needed)

sudo apt-get install build-essential

Start

npm install --production
npm start
# or with special port
# npm start -- --port=55555
open browser: http://127.0.0.1:8080

Web UI

Dashboard

Webserver UI

Trades / Positions / Orders

Webserver UI

Manual Orders

Webserver UI

Build In Strategies

Common strategy with indicators are inside, which most of the time are not profitable. See some more advanced strategy in the list below

Find some example strategies inside src/strategy/strategies

Custom Strategies

For custom strategies use var/strategies folder.

# simple file structure
var/strategies/your_strategy.js

# or wrap strategy into any sub folder depth
var/strategies/my_strategy/my_strategy.js

Signals

Slack

Webserver UI

Tests

npm test

Security / Authentication

As the webserver provides just basic auth for access you should combine some with eh a https for public server. Here s simple proxy_pass for nginx.

# /etc/nginx/sites-available/YOURHOST
server {
    server_name YOURHOST;

    location / {
        proxy_pass http://127.0.0.1:8080;
    }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/YOURHOST/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/YOURHOST/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

Setting Up Telegram Bot

First, you'll need to create a bot for Telegram. Just talk to BotFather and follow simple steps until it gives you a token for it. You'll also need to create a Telegram group, the place where you and crypto-trading-bot will communicate. After creating it, add the bot as administrator (make sure to uncheck "All Members Are Admins").

Retrieving Chat IDs

Invite @RawDataBot to your group and get your group id in sended chat id field

Message
 ├ message_id: 338
 ├ from
 ┊  ├ id: *****
 ┊  ├ is_bot: false
 ┊  ├ first_name: 사이드
 ┊  ├ username: ******
 ┊  └ language_code: en
 ├ chat
 ┊  ├ id: -1001118554477
 ┊  ├ title: Test Group
 ┊  └ type: supergroup
 ├ date: 1544948900
 └ text: A

Look for id: -1001118554477 is your chat id (with the negative sign).

Related Links

Trading Bots Inspiration

Other bots with possible design pattern

  • https://github.com/DeviaVir/zenbot
  • https://github.com/magic8bot/magic8bot
  • https://github.com/askmike/gekko
  • https://github.com/freqtrade/freqtrade
  • https://github.com/Ekliptor/WolfBot
  • https://github.com/andresilvasantos/bitprophet
  • https://github.com/kavehs87/PHPTradingBot
  • https://github.com/Superalgos/Superalgos

Strategies

Some strategies based on technical indicators for collection some ideas

  • https://github.com/freqtrade/freqtrade-strategies
  • https://github.com/freqtrade/freqtrade-strategies/tree/master/user_data/strategies/berlinguyinca
  • https://github.com/xFFFFF/Gekko-Strategies
  • https://github.com/sthewissen/Mynt/tree/master/src/Mynt.Core/Strategies
  • https://github.com/Ekliptor/WolfBot/tree/master/src/Strategies
  • https://github.com/Superalgos/Strategy-BTC-WeakHandsBuster
  • https://github.com/Superalgos/Strategy-BTC-BB-Top-Bounce

Extension points exported contracts — how you extend this code

Controller (Interface)
(no doc) [13 implementers]
src/controller/base_controller.ts
Notifier (Interface)
(no doc) [4 implementers]
src/notify/notify.ts
RawCandle (Interface)
* Raw candle data from fixture (plain objects)
test/modules/strategy/v2/strategies/playground.test.ts
TalibIndicatorConfig (Interface)
* Configuration for a talib indicator
src/utils/indicators.ts
Candlestick (Interface)
(no doc)
test/utils/resample.test.ts
ProfilePair (Interface)
(no doc)
src/modules/profile_pair_service.ts
BollingerBandsResult (Interface)
(no doc)
src/strategy/strategy.ts
Profile (Interface)
(no doc)
src/profile/types.ts

Core symbols most depended-on inside this repo

log
called by 52
src/utils/winston_sqlite_transport.ts
get
called by 49
src/utils/file_cache.ts
execute
called by 47
src/strategy/strategy.ts
getOptions
called by 35
src/strategy/strategy.ts
createIndicator
called by 32
src/strategy/strategy.ts
debugAll
called by 27
src/strategy/strategy.ts
getConfig
called by 18
src/modules/services.ts
getIndicatorSlice
called by 18
src/strategy/strategy.ts

Shape

Method 390
Interface 135
Class 132
Function 110

Languages

TypeScript100%

Modules by API surface

src/strategy/strategy.ts58 symbols
src/modules/services.ts53 symbols
src/modules/system/config_service.ts28 symbols
src/profile/profile_service.ts27 symbols
src/controller/profile_controller.ts26 symbols
src/utils/indicators.ts23 symbols
src/modules/strategy/v2/typed_backtest.ts18 symbols
src/modules/strategy/v2/strategy_registry.ts17 symbols
src/repository/candlestick_repository.ts16 symbols
src/profile/profile_order_service.ts14 symbols
src/modules/system/ccxt_candle_watch_service.ts14 symbols
src/modules/system/ccxt_candle_prefill_service.ts13 symbols

Dependencies from manifests, versioned

@types/mocha10.0.10 · 1×
@types/request2.48.13 · 1×
basic-auth2.0.1 · 1×
better-sqlite312.6.2 · 1×
ccxt4.5.38 · 1×
commander14.0.3 · 1×
compression1.8.1 · 1×
cookie-parser1.4.7 · 1×
ejs4.0.1 · 1×
esbuild0.27.3 · 1×
eslint9.22.0 · 1×

For agents

$ claude mcp add crypto-trading-bot \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact