SockTrader

🚀 Websocket based trading bot for 💰cryptocurrencies 📈

SockTrader/SockTrader
starsStars 103
forksForks 17
watchersWatchers 103
current-versionCurrent version
total-releasesTotal releases 0
open_issues_countOpen issues 15
dateFirst release -
dateLatest release -
updateLast update 2020-12-17

SockTrader

Cryptocurrency trading bot

🚧 Project is currently under development! 🚧

what is technical analysis?) or you could simply tell the bot to buy/sell at certain price levels. In fact, it's up to you to decide the rules of the game!

The name "SockTrader" comes from websocket based trading bot. Which means that SockTrader will try to make use of a realtime connection with the exchange. This has the advantage that one can act very quickly in a changing market with low latency.

Features

  • 🚀 Realtime super-fast websocket trading.
  • 📈 50+ Technical indicators. (docs)
  • 🌈 Written in TypeScript!
  • 🌿 Unit tested source code.
  • 🔫 Mutation testing for better testing quality
  • 📝 Paper trading a strategy on LIVE exchange data.
  • 🏡 Backtesting engine with local data.
  • ⚡️ Test & live reload your strategy in our online dashboard!
  • 🚢 Run SockTrader inside a docker container.
  • More features soon..

Use our online dashboard!

We've built an online dashboard that you can use to visually confirm all the trades that happened during a backtesting session. The dashboard has a live reload functionality. So SockTrader will relaunch the current backtest once you've changed and saved the code of a strategy. All the trades will be shown on the chart as you can see in the screenshot.

Try it yourself:

  1. Follow our Quick Start guide
  2. Run npm run web and leave all settings as default.
  3. Go to our online dashboard and test your strategies!

Getting started

Quick start

Dockerfile

  1. Clone the repository locally: git clone https://github.com/SockTrader/SockTrader
  2. Add trading bot configuration: cp src/config.ts.dist src/config.ts
  3. (optional) Edit src/config.ts
  4. Build docker image: cd SockTrader && docker build -t socktrader .
  5. Start container: docker run socktrader --help

Local scripts

  1. Clone the repository locally: git clone https://github.com/SockTrader/SockTrader
  2. Install dependencies: cd SockTrader && npm install
  3. Create trading bot configuration file: cp src/config.ts.dist src/config.ts
  4. Build project: npm run build
  5. Transform our candle data (BTC/USD coinbase) from src/data to a readable format in build/data: npm run normalize
  6. Run SockTrader: node ./build/index.js --help

Other scripts

  • npm run test run jest test suite
  • npm run web-dev start development webserver with nodemon for quick & easy development
  • npm run web start webserver. Can be used for "live reload" using websockets
  • npm run socktrader -- backtest --candles=coinbase_btcusd_1h --strategy=simpleMovingAverage start backtest trading session
  • npm run socktrader -- live --paper --pair btc usd --strategy simpleMovingAverage --exchange hitbtc --interval 1m start paper trading session

Advanced

Load your own candle data of a trading pair of your interest:

Create your own strategy Create your own strategy

Normalize raw candles

Add raw candle data

Download raw candles from a trusted source in json or csv format and copy this file to the src/data folder.

Create a candle normalizer

A candle normalizer is a small utility script that is tightly coupled to a raw candle file. It will normalize the candles from a raw csv or json file and output them in a generic format in the build/data folder. This normalization process can be triggered by running: npm run normalize.

The expected output of a normalizer is a IDataFrame interface from data-forge. Each row in the data frame should respect the following type definition:

{
  timestamp: Moment,
  high: number,
  low: number,
  open: number,
  close: number,
  volume: number,
}

The following example will give you a good idea of how you can create your own candle normalizer. Make sure to put this file into the src/data folder next to the raw candle files. Preferably with the same name as the candle file but with .ts extension.

Example:

// src/data/coinbase_btcusd_1h.ts
import {IDataFrame} from "data-forge";
import moment from "moment";
import path from "path";
import {Candle} from "../sockTrader/core/types/candle";
import CandleNormalizer from "../sockTrader/core/candles/candleNormalizer";
import CandleNormalizer, {CandleMetaInfo} from "../sockTrader/data/candleNormalizer";

const candleMeta: CandleMetaInfo = {symbol: ["BTC", "USD"], name: "Bitcoin"};

const parser = (dataFrame: IDataFrame): IDataFrame<number, Candle> => dataFrame
    .renameSeries({
        "Date": "timestamp",
        "High": "high",
        "Low": "low",
        "Open": "open",
        "Close": "close",
        "Volume USD": "volume",
    })
    .select(row => ({
        ...row,
        timestamp: moment.utc(row.timestamp, "YYYY-MM-DD hh-A"),
    }));

export default new CandleNormalizer("coinbase_btcusd_1h.csv", candleMeta, parser);

Your own strategy?

Take a look at the given example strategy in this repository: simpleMovingAverage strategy

We need your help!

We're looking for extra contributors to give this project a well deserved boost. Don't hesitate to contact us on: Gitter

Or you can also support us by:

  1. Donating money for covering the hosting costs
  2. Pay for advertisements on the SockTrader dashboard
  3. Or sharing interesting knowledge with the community

Become a Patron!

ROADMAP

v1.0

  • Improve communication between dashboard & SockTrader
  • Update and improve live trading
  • Test edge case scenarios (possible rounding issues)
  • Test altcoin trading and improve if needed
  • Add basic backtest analyzers
  • Dashboard internationalization
  • Improve dashboard architecture
  • Increase test coverage and test quality
  • Add more and better documentation

Later on..

  • Improve logging
  • Add extra exchanges
  • Add more advanced backtest analyzers
  • Show status of wallet in dashboard
  • Show status of analyzers in dashboard
  • And so much more..

Let us know if you have great ideas to improve the project! Feel free to open a pull request.

Contributors

DISCLAIMER

Using a trading bot does not mean guaranteed profit. 
Also, trading crypto currency is considered high risk.
Losses are possible, which SockTrader cannot be held responsible for.