IbkrApi.Backtester.Bar (ibkr_api v1.0.0)
View SourceHistorical market data bar structure for backtesting.
This module provides a standardized bar structure and conversion utilities for backtesting with IBKR historical data.
Summary
Functions
Returns true if the bar is bearish (close < open).
Returns true if the bar is bullish (close > open).
Converts IbkrApi.ClientPortal.MarketData.HistoricalBar to IbkrApi.Backtester.Bar.
Converts IBKR API response data to IbkrApi.Backtester.Bar struct.
Returns the price range (high - low) for the bar.
Returns the typical price (HLC/3) for the bar.
Types
Functions
Returns true if the bar is bearish (close < open).
Returns true if the bar is bullish (close > open).
@spec from_historical_bar(IbkrApi.ClientPortal.MarketData.HistoricalBar.t()) :: t()
Converts IbkrApi.ClientPortal.MarketData.HistoricalBar to IbkrApi.Backtester.Bar.
This provides compatibility between the IBKR API module and backtesting framework.
Converts IBKR API response data to IbkrApi.Backtester.Bar struct.
Parameters
data
: Map containing IBKR bar data with keys "t", "o", "h", "l", "c", "v"
Examples
iex> IbkrApi.Backtester.Bar.from_ibkr(%{"t" => 1707139200000, "o" => 189.9, "h" => 190.3, "l" => 188.7, "c" => 189.5, "v" => 24018321})
%IbkrApi.Backtester.Bar{
timestamp: ~U[2024-02-05 13:20:00.000Z],
open: 189.9,
high: 190.3,
low: 188.7,
close: 189.5,
volume: 24018321
}
Returns the price range (high - low) for the bar.
Returns the typical price (HLC/3) for the bar.