OHLCFactory (ohlc v1.2.4)

This module provides functionality to generate random or defined OHLC candles or trades which can be used for testing, demoing etc.

Link to this section Summary

Functions

Generates candles based on parameters provided.

Generates empty OHLC candle.

Generates trades from provided arguments.

Link to this section Functions

Link to this function

gen_candles(timeframe, amount, opts \\ [])

@spec gen_candles(OHLC.timeframe(), number(), keyword() | nil) :: list()

Generates candles based on parameters provided.

Parameters:

  • timeframe - See available timeframes OHLCHelper.get_timeframes.
  • amount - Amount of candles to generate. Must be bigger than 0.

Available options:

  • :base_price - Base price to use when generating candles. Defaults to 9.
  • :price_direction - Generated candles can increase or decrease in price. :increase, :decrease or :rand which is used by default.
  • :price_change_percentage - With each new candle we dynamically update the price for each new candle. This price can be higher than the previous candle or lesser. With this option you can choose the percentage change for each new candle. Defaults to 2% change with each new candle.
Link to this function

gen_empty_candle(timeframe \\ nil)

@spec gen_empty_candle(OHLC.timeframe() | nil) :: OHLC.candle()

Generates empty OHLC candle.

If provided with timeframe stime and etime will be generated based on current time.

Link to this function

gen_trades(opts \\ [])

@spec gen_trades(keyword() | nil) :: list()

Generates trades from provided arguments.

Options:

  • timeframe - Timeframe used for rounding the timestamp. Available values are: :minute, :hour, :day, :week
  • min_price - The minimum price on the generated trades
  • max_price - The maximum price on the generated trades
  • volume - The volume each trade has
  • timeframe_multiplier - If you'd like to generate less trades per candle then you can increase the size of the timeframe_divider parameter(1-100) otherwise leave empty.
  • timeframe_divider - Is used for generating multiple candles of the same timeframe.