Cryptocurrency trading bot
🚧 Project is currently under development! 🚧
SockTrader is an open source cryptocurrency trading bot. You can use it to automatically buy and/or sell cryptocurrencies based on a strategy that you've programmed. The strategy basically contains a set of rules that will define when and how the bot should act in the cryptocurrency market. These rules can be based on technical analysis (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.
- 🚀 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..
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:
- Follow our Quick Start guide
- Run
npm run web
and leave all settings as default. - Go to our online dashboard and test your strategies!
- Clone the repository locally:
git clone https://github.com/SockTrader/SockTrader
- Add trading bot configuration:
cp src/config.ts.dist src/config.ts
- (optional) Edit
src/config.ts
- Build docker image:
cd SockTrader && docker build -t socktrader .
- Start container:
docker run socktrader --help
- Clone the repository locally:
git clone https://github.com/SockTrader/SockTrader
- Install dependencies:
cd SockTrader && npm install
- Create trading bot configuration file:
cp src/config.ts.dist src/config.ts
- Build project:
npm run build
- Transform our candle data (BTC/USD coinbase) from
src/data
to a readable format inbuild/data
:npm run normalize
- Run SockTrader:
node ./build/index.js --help
npm run test
run jest test suitenpm run web-dev
start development webserver with nodemon for quick & easy developmentnpm run web
start webserver. Can be used for "live reload" using websocketsnpm run socktrader -- backtest --candles=coinbase_btcusd_1h --strategy=simpleMovingAverage
start backtest trading sessionnpm run socktrader -- live --paper --pair btc usd --strategy simpleMovingAverage --exchange hitbtc --interval 1m
start paper trading session
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
Download raw candles from a trusted source in json or csv format and copy this file to the src/data
folder.
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);
Take a look at the given example strategy in this repository: simpleMovingAverage strategy
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:
- Donating money for covering the hosting costs
- Pay for advertisements on the SockTrader dashboard
- Or sharing interesting knowledge with the community
- 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
- 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.
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.