Indicators
The basic Components like Open, Close, High, Low, Volume and their Difference or RelativeDifference components can be used to generate derived Components like:
SMA{horizon, base_T}: simple moving average over a window/horizonEMA{horizon, base_T}: exponential moving average over a window/horizonMovingStdDev{horizon, base_T}: moving standard deviation over a window/horizonRSI{horizon, base_T}: moving relative strength index over a window/horizonBollinger{horizon, base_T}: Up and Down Bollinger bands
These indicators can be requested by Strategy systems for example:
struct TestStrat <: System
Overseer.requested_components(::TestStrat) = (SMA{20, Close}, RSI{14, Open})This leads that for any asset that TestStrat should be used on will automatically generate these derived Indicators as the data flows in. It is also used by new_entities to iterate over the new entities in a AssetLedger that hold the requested components for a given Strategy. reset! on the other hand clears all the data for the requested components of a strategy in a AssetLedger. This is useful for example to not use the data of the previous day when calculating moving averages etc.
function update(s::TestStrat, trader, asset_ledgers)
curt = current_time(trader)
if is_market_open(curt)
for l in asset_ledgers
# This clears the SMA{20, Close} and RSI{14, Open} Components from l
reset!(l, s)
end
end
for l in asset_ledgers
for e in new_entities(l, s)
# do something with e
# e[SMA{20, Close}] accesses the SMA
# e[RSI{14, Open}] accesses the RSI
end
end
endEach e in the above example will be seen only once. See the Strategies tutorial for more info.
Reference
Trading.SMA — TypeSMA{horizon, T}The simple moving average of a value over a sliding window of horizon.
Trading.MovingStdDev — TypeMovingStdDev{horizon, T}The moving standard deviation of a value over a sliding window of horizon.
Trading.EMA — TypeEMA{horizon, T}The exponential moving average of a value over a sliding window of horizon.
Trading.RSI — TypeRSI{horizon, T}The relative strength index of a value over timeframe of horizon.
Trading.Bollinger — TypeBollinger{horizon, T}The up and down Bollinger bands for a value, over a sliding window of horizon.
Trading.Sharpe — TypeSharpe{horizon, T}The sharpe ratio of a value over a timeframe horizon.
Trading.new_entities — Functionnew_entities(ledger, strategy)Returns a NewEntitiesIterator which iterates through the entities that have components that are requested by strategy, and were not yet seen. I.e. each entity in those components will be looped over once and only once when iteratively calling new_entities.
Missing docstring for Trading.reset!(::Trading.AssetLedger, ::Any). Check Documenter's build log for details.
Systems
Trading.SMACalculator — TypeSMACalculatorCalculates the SMA of data.
Trading.MovingStdDevCalculator — TypeMovingStdDevCalculatorCalculates the MovingStdDev of data.
Trading.EMACalculator — TypeEMACalculatorCalculates the EMA of data.
Trading.RSICalculator — TypeRSICalculatorCalculates the RSI of values.
Trading.BollingerCalculator — TypeBollingerCalculatorCalculates the Bollinger bands for data. The width parameter can be tuned, by default it is 2.0.
Trading.SharpeCalculator — TypeSharpeCalculatorCalculates the bare Sharpe ratio of data.