API Reference¶
Swing Class Properties¶
- on_reversal: Callable or None
A optional function or class method that is called when a trend reversal occurs.
Swing.on_reversal has the below signature:
def on_reversal(cls: Swing, date, close: float, reversal_level: float)Parameters:
cls - The Swing class instance which provides access to all its properties and methods.
date - The bar date on which the reversal occured.
close - The closing price of the reversal bar.
reversal_level - The coc price level that was broken.
- on_breakout: Callable or None
A optional function or class method that is called when a Break of Structure (BOS) or breakout/breakdown occurs.
Swing.on_breakout has the below signature.
def on_breakout(cls: Swing, date, close: float, breakout_level: float)Parameters:
cls - The Swing class instance which provides access to all its properties and methods.
date - The bar date on which the breakout occured.
close - The closing price of the breakout bar.
breakout_level - The breakout price or SPH/SPL level that was broken.
- symbol: str or None
The current symbol name if passed during
Swing.run.
- df: pandas.DataFrame or None
pandas.DataFrame if passed during
Swing.run.
- trend: str or None
The current trend as
UPorDOWN. Set to None, if too few candles were supplied.
- sph: float or None
The current swing point high. Set to None, if trend is Down or sph not yet formed.
- spl: float or None
The current swing point low. Set to None, if trend is UP or spl not yet formed.
- coc: float or None
Change of Character. It represents the trend reversal level. If trend is None, coc is None.
- high: float or None
The highest price reached within the current structure. Reset to None, when SPL is formed or a trend reversal has occured.
- low: float or None
The lowest price reached within the current structure. Reset to None, when SPH is formed or a trend reversal has occured.
Note regarding dates¶
Swing class does not perform any datetime operations.
All properties below are based on the input type. If you passed a str or timestamp or datetime, the same type is returned for the properties.
- sph_dt: datetime or None
Date of SPH candle formation.
- spl_dt: datetime or None
Date of SPL candle formation.
- coc_dt: datetime or None
Date of coc candle.
- low_dt: datetime or None
Candle date with lowest price in the current structure.
- high_dt: datetime or None
Candle date with highest price in the current structure.