Cryptocurrency trading bot
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 advantagethat one can act very quickly in a changing market with low latency.
We've built an online dashboard that you can use to visually confirm all the trades that happened during a backtesting session. The dashboardhas a live reload functionality. So SockTrader will relaunch the current backtest once you've changed and saved the code of a strategy. All the tradeswill be shown on the chart as you can see in the screenshot.
Try it yourself:
npm run web
and leave all settings as default.git clone https://github.com/SockTrader/SockTrader
cp src/config.ts.dist src/config.ts
src/config.ts
cd SockTrader && docker build -t socktrader .
docker run socktrader --help
git clone https://github.com/SockTrader/SockTrader
cd SockTrader && npm install
cp src/config.ts.dist src/config.ts
npm run build
src/data
to a readable format in build/data
: npm run normalize
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 sessionLoad 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 candlesfrom a raw csv or json file and output them in a generic format in the build/data
folder. This normalization processcan 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 fileinto 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:
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.