Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jeka-kiselyov/kramjah
Crypto Trading Bot In Node.JS
https://github.com/jeka-kiselyov/kramjah
bitcoin crypto cryptocurrency ethereum hitbtc hitbtc-api instance-trading telegram trading trading-bot trading-pairs trading-simulation trading-strategy
Last synced: about 1 month ago
JSON representation
Crypto Trading Bot In Node.JS
- Host: GitHub
- URL: https://github.com/jeka-kiselyov/kramjah
- Owner: jeka-kiselyov
- License: agpl-3.0
- Created: 2021-03-06T17:28:27.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-10-12T23:28:41.000Z (about 3 years ago)
- Last Synced: 2024-04-12T16:00:39.074Z (9 months ago)
- Topics: bitcoin, crypto, cryptocurrency, ethereum, hitbtc, hitbtc-api, instance-trading, telegram, trading, trading-bot, trading-pairs, trading-simulation, trading-strategy
- Language: JavaScript
- Homepage: https://t.me/kramjah
- Size: 7.11 MB
- Stars: 28
- Watchers: 2
- Forks: 12
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Kramjah
Node.js trading bot application. Simple trading strategy included. Works over HitBTC exchange with any trading pair, but feel free to fork it and change to any exchange, should be relatively simple to.
![Kramjah in action](https://user-images.githubusercontent.com/1434612/110217873-3a7c2580-7ebf-11eb-862c-da91c15d548e.gif) | ![photo_2021-03-20_15-22-24](https://user-images.githubusercontent.com/1434612/112845420-83ce2800-90ad-11eb-9356-b11c2f549bdf.jpg)
------------- | -------------### Join Telegram Channel for updates
- [Kramjah](https://t.me/kramjah)
### Installation
- Install node.js [download](https://nodejs.org/en/download/)
- Download **Kramjah** and extract to new foler
- Or do `git clone https://github.com/jeka-kiselyov/kramjah.git`
- cd to folder and run `npm install`### Simulation or trade with real money?
First, you'd better spend some time optimizing the trading strategy for your needs and vision. Then run "flashback" command to check how successful your strategy would be on historical data. When you are ok with it, run real trading with `dotrade` or `trade` commands.
### Try it in action
Run `node app.js flashback data/btcusd2021.dat Simple btcusd 1` to simulate trading over btc/usd pair with Simple trading strategy over historical data.
### Do real trading
- Get your account on [HitBTC](https://hitbtc.com/).
- Create api keys with `Order book, History, Trading balance`, `Payment information` and `Place/cancel orders` access rights.
- Pop it up with some usd
- Add `.env` file to the application root with content of:
```
HITBTC_API_KEY=xxxxx
HITBTC_SECRET_KEY=yyyyyy
HITBTC_MODE=market
```
- Run `node app.js dotrade data/btcusd2021.dat Simple btcusd 1` to run trading.### Trade over few pairs based on settings.
No need to remember all symbol-strategies you are trading over. Edit `traders` array in `settings/settings.js` and run trading over them running `node app.js trade`. Use [up] and [down] keys for navigation between traders. Press [p] to pause traders loop for 30 seconds.
### Trading Window Hotkeys
- [1] - 5 minutes interval price chart
- [2] - 15 minutes interval price chart
- [3] - 1 hour interval price chart
- [4] - 5 minutes volatility chart
- [5] - 15 minutes volatility chart
- [6] - 1 hour volatility chart
- [up] - next trader (if trading over settings/setting.js file)
- [down] - prev trader (if trading over settings/setting.js file)
- [p] - pause next trader loop for 30 seconds (if trading over settings/setting.js file)
- [l] - show/hide debug dialog
- [q][ctrl+c] - quit#### Important notes
- Be sure there's only one running instance trading on specific TradingSymbol/Strategy. App doesn't catch parallel instances and can't produce too much orders in this case.
### Write your own trading strategy
- Extend Base class with other one and use its name instead of Simple when running the app.
- #todo: docs about getting statistics features from HistoricalMarketPriceCombined### Want to try other pairs?
- Donwload .csv file with historical prices from Kaggle [here](https://www.kaggle.com/tencars/392-crypto-currency-pairs-at-minute-resolution).
- Compress .csv file to binary format for faster reading: `node app.js cachecsv path/to/file.csv`
- Or compress part of .csv file for faster reading of final .dat file: `node app.js cachecsv path/to/file.csv maxWeeksCount startTimestamp`
- Check compressed .dat file: `node app.js testdat path/to/file.dat`
- Be sure this trading pair is available on HitBTC, check pairs [here](https://api.hitbtc.com/api/2/public/symbol). Use symbol as pairsymbol when running the app.
- Try running trading simulation over it: `node app.js flashback path/to/file.dat Simple pairsymbol 1`### Refresh .dat file with real market data
For faster initialization, refresh .dat file, run `node app.js refreshdat path/to/file.dat pairsymbol`, result file will be saved at path/to/file_updated.dat
### Let Kramjah notify you of profits in Telegram?
- Create new telegram bot, [how](https://core.telegram.org/bots#3-how-do-i-create-a-bot)
- Add line `TELEGRAM_BOT_TOKEN=xxxxx:xxxx-xxx-xx` with bot token to .env file
- Add the bot you created to your telegram contacts (send any message to it).
- Run `node app.js checktelegram` and send another message to the bot while command is running
- Command will show you your telegram user id, add it to .env file as line of `TELEGRAM_NOTIFY_USER_ID=xxxxx`
- Bot will send you telegram notification on any successful sale with profit.
- If trading over few pairs with `node app.js trade` command, you can ask bot to check your profits balance. Send `/balance` command to it.### Want to simulate trading on different time interval?
There's an option:
`node app.js flashback path/to/file.dat Simple pairsymbol 1 fromTime toTime` where fromTime and toTime are timestamps. Use something like [this](https://www.unixtimestamp.com/index.php) to generate needed timestamps.### Want to simulate with different starting balance?
`node app.js flashback path/to/file.dat Simple pairsymbol 1 fromTime toTime startBalance`
### Get statistic on available trading pairs to decide what to trade on
Run `node app.js checkpair` or `node app.js checkpair >> report.csv` to write to the file. It will take few hours, but will generate you a report for some statistics over the last 7 days on all available symbols on the marketplace.