This project aims to provide robust and extensible tools for better understanding market behavior and gaining insights on future trends. It has three pillars of focus:
- Collecting data (historic and real-time) relevant to market behavior (e.g. GDAX candles, tweets, etc.)
- Training plugins using historic data
- Inferring future market behavior using live data and knowledge gained through training
First, ensure that Mongo, Node and Yarn are installed. Then, run the following from the project's root:
yarn install
This repository's scripts use dotenv to manage environment variables. All variables documented in .env.template
must be defined either in a .env
file (located at the project root) or configured on the system.
Note: Currently there are no required environment variables, but if future plugins require API keys, this is where they should live.
In addition to any environment variables, there are a few required shared settings defined in ./settings.js
, notably mongoUri
and mongoDatabaseName
. The default values are sensible, but should be reviewed.
Most/all plugins will require historic data for training and real-time data for inference. Listed below are the strategies currently available for collecting data.
To collect GDAX's historic candle data, first instantiate a new OneTimeGDAXCandleCollector
with the following configuration:
- product: The trading pair, e.g.
BTC-USD
- startTime: A
Date
object denoting the beginning of the range - endtime: A
Date
object denoting the end of the range - candleSize: The duration of candles to be gathered, supported values are
1-day
,6-hour
,1-hour
,15-minute
,5-minute
, and1-minute
.
Next, invoke the start
method of the collector, and when the candles for the given configuration have been gathered, the returned promise will resolve. Below is a simple example. See ./bin/collect_historic_gdax_candles.js
for more details:
const config = { product, startTime, endTime, candleSize };
const collector = new OneTimeGDAXCandleCollector(config);
collector.start().then((candles) => console.log(candles));
To collect real-time GDAX candles, first instantiate a new RealTimeGDAXCandleCollector
with the following configuration:
- product: The trading pair, e.g.
BTC-USD
- candleSize: The duration of candles to be gathered, supported values are
1-day
,6-hour
,1-hour
,15-minute
,5-minute
, and1-minute
. - interval: The polling frequency in milliseconds.
In most cases, the collector instance should be passed to a Quant
instance, which will manage starting and stopping the collector. When new candles have been retrieved, the collector will emit a RealTimeGDAXCandleCollector.events.COLLECT_FINISHED
event, which can be utilized by concerned plugins. See ./bin/infer_bullish_engulfing.js
for example usage.
Coming Soon...
Once the necessary data has been collected, plugins can begin training with historic data. Listed below are the plugins currently available:
The BullishEngulfingTrainer
identifies historic instances of bullish engulfing candles and calculates the probability of various percent-price increases in the near-term future. For this exercise, a bullish engulfing candle is defined as having:
- a higher closing price than opening price
- a taller candle body than all recent candles
- a closing price that is at or near its highest price
- larger volume than all recent candles
The plugin requires the following to be configured:
- product: The trading pair to be analyzed, e.g.
BTC-USD
- priceHistoryFile: The absolute path to a historic GDAX candle file generated by the script mentioned in the "Historic GDAX Candles" section
- dbCollection: The mongo collection into which the results will be inserted
- lookbackCandles: The number of previous candles that the current candle needs to be larger than in order to be considered "engulfing"
- lookaheadCandles: The maximum number of candles to look ahead when determining the highs following a bullish engulfing candle
- allowedWickToBodyRatio: The maximum body-to-upper-wick ratio that is allowed for a candle to be considered engulfing
- groupSizeForPctPriceIncreaseProbability: The grouping size applied when calculating the probability of the price increasing by a particular percentage
Coming Soon...
Once the necessary training has been completed, plugins can begin inferring with real-time data. Listed below are the plugins currently available:
When the current candle meets the criteria defined in the "Bullish Engulfing Trainer" section, the BullishEngulfingInferrer
emits a BullishEngulfingInferrer.CURRENT_CANDLE_IS_BULLISH_ENGULFING
event, which contains the plugin settings, data about the most recent candle, along with probabilities of various percentage-price increases over the next lookaheadCandles
candles. The plugin requires the following to be configured:
- product: The trading pair to be analyzed, e.g.
BTC-USD
- dbCollection: The mongo collection where Bullish Engulfing Training data is stored
- lookbackCandles: The number of previous candles that the current candle needs to be larger than in order to be considered "engulfing"
- lookaheadCandles: The maximum number of candles to look ahead when determining the highs following a bullish engulfing candle (used to identify the appropriate training data)
- allowedWickToBodyRatio: The maximum body-to-upper-wick ratio that is allowed for a candle to be considered engulfing
The BullishEngulfingInferrer
also requires a RealTimeGDAXCandleCollector
for a data feed. See ./bin/infer_bullish_engulfing.js
for example usage.
Coming Soon...
Coming Soon...
Coming Soon...