Skip to content

🚀 Websocket based trading bot for 💰cryptocurrencies 📈

License

Notifications You must be signed in to change notification settings

Larrycoin/SockTrader

 
 

Repository files navigation

SockTrader logo

SockTrader

Cryptocurrency trading bot

License: GPL v3 Build status Dependencies Gitter

🚧 Project is currently under development! 🚧

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!

Any strategy that has been developed in SockTrader can be backtested using our online dashboard. Once you change and save the code of the selected strategy the dashboard should automatically update itself and rerun the backtest.

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!

SockTraderDashboard

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. Add trading bot configuration: cp src/config.ts.dist src/config.ts
  4. (optional) Edit src/config.ts
  5. Build project: npm run build
  6. Run SockTrader: node ./build/index.js --help
  7. Transform our candle data (BTC/USD Bitstamp) from src/data to a readable format in build/data: npm run normalize
  8. Run backtest with the normalized candles and the simple moving average strategy! npm run backtest -- --candles=bitstamp_btcusd_1h --strategy=simpleMovingAverage

Other available 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

Advanced

Load your own candle data of a trading pair of your interest: Create a candle normalizer in "src/data" folder

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,
}

Redundant properties which are not listed in the type definition above will be ignored by the trading bot. If you run into any issue, consider removing them as well by calling .dropSeries(["REDUNDANT_PROPERTY"]) since we cannot guarantee that it will still work in the future. Data-forge and moment are already included as a dependency and they are used throughout the SockTrader codebase.

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/bitstamp_btcusd_1h.ts
import {IDataFrame} from "data-forge";
import moment from "moment";
import path from "path";
import CandleNormalizer from "../sockTrader/core/candles/candleNormalizer";

// Be sure to go back to the src folder, since this script will be executed from the build/data folder!!
const SRC_PATH = "../../src/data";
const PATH = path.resolve(__dirname, SRC_PATH, "bitstamp_btcusd_1h.csv");

const parser = (dataFrame: IDataFrame<number, any>): IDataFrame<number, any> => {
    return dataFrame
        .dropSeries(["Symbol"]) // Redundant property
        .renameSeries({
            "Date": "timestamp",
            "High": "high",
            "Low": "low",
            "Open": "open",
            "Close": "close",
            "Volume To": "volume",
        })
        .select(row => {
            row.timestamp = moment(row.timestamp, "YYYY-MM-DD hh-A");
            return row;
        })
};

export default new CandleNormalizer(PATH, 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: Telegram or 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

cwouterthijs-raets

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.

About

🚀 Websocket based trading bot for 💰cryptocurrencies 📈

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 98.2%
  • JavaScript 1.6%
  • Dockerfile 0.2%