Skip to content

Commit

Permalink
Refactored and updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
LeviathanLevi committed Apr 17, 2021
1 parent c6aa3d0 commit d6f52c2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# CrypFinder Bot
## Version 1.4
## Version 1.5

## CrypFinder Summary:
CrypFinder is a Coinbase Pro API trading bot that currently implements a basic momentum trading strategy in NodeJS using the Coinbase Pro API, as well as its own custom library for the endpoints that are not supported by the now deprecated Coinbase Pro NodeJS Library. Currently, Coinbase Pro limits the number of portfolios to five, this means that the bot can run up to four trading instances simultaneously per Coinbase Pro account. This bot can be modified to trade any product pairs available on Coinbase Pro, such as BTC-USD, ETH-USD, etc., but stablecoin (USDC to other coins) and crypto markets (coin to other coins) aren't currently supported, only USD markets (USD to coins).
CrypFinder is a Coinbase Pro API trading bot that currently implements a basic momentum trading strategy and reverse momentum trading strategy in NodeJS using the Coinbase Pro API, as well as its own custom library for the endpoints that are not supported by the now deprecated Coinbase Pro NodeJS Library. Currently, Coinbase Pro limits the number of portfolios to five, this means that the bot can run up to four trading instances simultaneously per Coinbase Pro account. This bot can be modified to trade any product pairs available on Coinbase Pro, such as BTC-USD, ETH-USD, etc., but stablecoin (USDC to other coins) and crypto markets (coin to other coins) aren't currently tested, only USD markets (USD to coins).

The currently implemented momentum strategy will work as follows: The bot will start by getting the amount of USD available for the provided API key's profile (profile=portfolio on the coinbase pro website). If the amount is greater than zero, it will monitor the price changes of the chosen product using a peak/valley system; if the price changes by the specified delta, it will purchase a position. Then, it will monitor price changes until the delta condition and profit condition are met; after selling for a profit, it can deposit a cut of the profit to a different portfolio for saving.
The momentum strategy will work as follows: The bot will start by getting the amount of USD available for the provided API key's profile (profile=portfolio on the coinbase pro website). If the amount is greater than zero, it will monitor the price changes of the chosen product using a peak/valley system; if the price changes by the specified delta, it will purchase a position. Then, it will monitor price changes until the delta condition and profit condition are met; after selling for a profit, it can deposit a cut of the profit to a different portfolio for saving. The reverse momentum trading strategy, is, as the name implies the reverse where it sells when the price goes up and buys when it goes down.

The bot features a number of variables at the top that can be configured to customize how it trades. This includes the deltas that specify an amount of price change that will trigger a buy/sell, the minimum acceptable profit from a trade, the name of currency to trade, the profile names, the deposit enable/disable flag, the deposit amount, and more. Of course, any of the code can be modified to customize it fully. This project is a great way to trade crypto on Coinbase Pro through their API.

Expand Down Expand Up @@ -44,8 +44,8 @@ If at any point the bot stops running for any reason, the the bot keeps a file c
## Running the program out of sandbox:
When you're confident in the configuration/code base and want to run it in the real environment, comment out the sandbox env variables and uncomment out the real API URI variables. Update the .env file with a valid API key. You can run this program on your own machine or consider using a server such as an AWS EC2 instance with an EIP (you need to whitelist the API IP). AWS EC2 offers a free tier instance for a year that works well for hosting.

## Momentum trading strategy analyzer:
The momentumTradingAnalyzer is a way to run data against the momentum trading bot strategy to see how well it performs. It takes in a .csv file with OHLC data. Carston Klein has already compiled a massive dataset that is perfect for this task and it's available for free on Kaggle [check it out](https://www.kaggle.com/tencars/392-crypto-currency-pairs-at-minute-resolution?select=ampusd.csv). After downloading the file for the coin data you want, just trim the .csv file to the length of time you want to test and run the analyzer with the configuration you want and it will generate a report showing how it did. He also wrote [this article](https://medium.com/coinmonks/how-to-get-historical-crypto-currency-data-954062d40d2d) on how to get similar data yourself.
## Momentum and reverse momentum trading strategy analyzer:
The analyzers are a way to run data against the bot strategy to see how well it performs. It takes in a .csv file with OHLC data. Carston Klein has already compiled a massive dataset that is perfect for this task and it's available for free on Kaggle [check it out](https://www.kaggle.com/tencars/392-crypto-currency-pairs-at-minute-resolution?select=ampusd.csv). After downloading the file for the coin data you want, just trim the .csv file to the length of time you want to test and run the analyzer with the configuration you want and it will generate a report showing how it did. He also wrote [this article](https://medium.com/coinmonks/how-to-get-historical-crypto-currency-data-954062d40d2d) on how to get similar data yourself.

## Helpful links:
[Coinbase Pro](https://pro.coinbase.com/trade/BTC-USD)
Expand All @@ -57,10 +57,9 @@ The momentumTradingAnalyzer is a way to run data against the momentum trading bo
[Flow diagram of the momentum strategy, open it in Google draw.io for best results (May be outdated, but can help to give an idea of how the program works)](https://drive.google.com/file/d/1sMg7nWcuCDwHS5wdwHgoe5qqODO7UEFA/view?usp=sharing)

## Roadmap:
- Implement a CLI (command line interface) to control the bot. This would make it so that users won't have to edit the code directly to configure and run the bot.

### Possible future goals:
- Add more strategies or make the current momentum strategy better. If making major changes to a current trading strategy, keep the old version and just add a new version of it to the same folder (momentumTradingV1, V2, etc).
- Implement a CLI (command line interface) to control the bot. This would make it so that users won't have to edit the code directly to configure and run the bot.

## Interested in the project?:
Consider getting involved. Free to contact the creator on GitHub ([Levi Leuthold](https://github.com/LeviathanLevi)) for information on how to get started! Checkout the product roadmap to see what features are currently planned for the future or add your own ideas.
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const reverseMomentumStrategyAnalyzerStart = require("./strategies/reverseMoment

/*** Make sure to configure the momentumStrategy in ./strategies/momentumTrading/momentumTrading.js before launching ***/
//Launches the momentum strategy and starts the bot:
//momentumStrategyStart();
momentumStrategyStart();

//Launches the momentum strategy anaylzer for back testing:
//momentumStrategyAnalyzerStart();
Expand All @@ -24,4 +24,4 @@ const reverseMomentumStrategyAnalyzerStart = require("./strategies/reverseMoment
//reverseMomentumStrategyStart();

//Launches the reverse momentum strategy anaylzer for back testing:
reverseMomentumStrategyAnalyzerStart();
//reverseMomentumStrategyAnalyzerStart();
8 changes: 4 additions & 4 deletions strategies/reverseMomentumTrading/reverseMomentumTrading.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const websocketURI = "wss://ws-feed-public.sandbox.pro.coinbase.com";

//Trading config:
//Global constants, consider tuning these values to optimize the bot's trading:
const sellPositionDelta = .0001; //The amount of change between valley and peak to trigger a sell off
const buyPositionDelta = .0002; //The amount of change between the peak and valley price to trigger a buy in
const sellPositionDelta = .01; //The amount of change between valley and peak to trigger a sell off
const buyPositionDelta = .001; //The amount of change between the peak and valley price to trigger a buy in
const orderPriceDelta = .001; //The amount of extra room to give the sell/buy orders to go through

//Currency config:
Expand Down Expand Up @@ -360,7 +360,7 @@ async function returnHighestFee(){
* The loop checks the position info to decide if the bot needs to try and buy or sell, it also checks if there's an available
* balance to be traded with. Then it calls gainPosition or losePosition appropiately and waits for them to finish and repeats.
*/
async function momentumStrategyStart() {
async function reverseMomentumStrategyStart() {
try {
let accountIDs = {};
let lastPeakPrice;
Expand Down Expand Up @@ -471,4 +471,4 @@ async function momentumStrategyStart() {
}
}

module.exports = momentumStrategyStart;
module.exports = reverseMomentumStrategyStart;
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ async function gainPosition(positionInfo, tradingConfig, priceInfo, report) {
* This is the method someone could use to setup loops to test a range of trading config values to
* find the optimal configuration for a given set of data.
*/
async function momentumStrategyAnalyzerStart() {
async function reverseMomentumStrategyAnalyzerStart() {
try {
//Run once:
const report = await analyzeStrategy(tradingConfig, dataFileName);
Expand Down Expand Up @@ -232,4 +232,4 @@ async function analyzeStrategy(tradingConfig, dataFileName) {
}
}

module.exports = momentumStrategyAnalyzerStart;
module.exports = reverseMomentumStrategyAnalyzerStart;

0 comments on commit d6f52c2

Please sign in to comment.