TradingPipeline
Hello, how are you?
DocumenterVitepress.jl generates very good-looking output.
Documentation for TradingPipeline.
TradingPipeline.simulate_sanity_check_failure_errorTradingPipeline.AbstractExchangeResponseTradingPipeline.AbstractManualCommandTechnicalIndicatorCharts.visualizeTradingPipeline.PNL.pnlTradingPipeline.PNL.pnlTradingPipeline.PNL.qtyTradingPipeline.PNL.qtyTradingPipeline.Stops.set_subject!TradingPipeline.aroundTradingPipeline.backtestTradingPipeline.decideTradingPipeline.fooTradingPipeline.load_strategyTradingPipeline.load_strategyTradingPipeline.percent_diffTradingPipeline.reportTradingPipeline.simulateTradingPipeline.PNL.@pnlTradingPipeline.PNL.@pnls
TradingPipeline.simulate_sanity_check_failure_error Constant
simulate_sanity_check_failure_error is a tuple filled with a lot of nothing values so that code that's @unpack'ing return values from simulate() don't crash.
TradingPipeline.AbstractExchangeResponse Type
An AbstractExchangeResponse represents a message that was received from an ExchangeFillSubject. The most common is ExchangeFill which lets the StrategySubject know that after putting out an intent to open or close a position, the exchange has filled the order and the requested position change has occurred.
Example
julia> subtypes(TradingPipeline.AbstractExchangeResponse)TradingPipeline.AbstractManualCommand Type
An AbstractManualCommand represents a manual intervention from a human to the StrategySubject.
Example
julia> subtypes(TradingPipeline.AbstractExchangeResponse)TechnicalIndicatorCharts.visualize Method
visualize(
t::Tuple{TechnicalIndicatorCharts.Chart, ExchangeOperations.AbstractSession};
kwargs...
) -> LightweightCharts.LWCLayoutLet's see if I can visualize trades on top of a chart.
sourceTradingPipeline.around Method
around(
ts::Dates.DateTime,
df::DataFrames.AbstractDataFrame;
before,
after,
ts_field
) -> AnyReturn a few rows before and after the given timestamp ts in the DataFrame df.
TradingPipeline.backtest Function
backtest(
candle_observable::Rocket.AbstractSubscribable,
strategy_config::Pair{T, C} where {T<:DataType, C<:Union{AbstractDict, NamedTuple}}
) -> Any
backtest(
candle_observable::Rocket.AbstractSubscribable,
strategy_config::Pair{T, C} where {T<:DataType, C<:Union{AbstractDict, NamedTuple}},
stops_config::Union{Nothing, Pair{T, C} where {T<:DataType, C<:Union{AbstractDict, NamedTuple}}}
) -> AnyThis is the successor to the old `simulate' method. This lets one backtest strategies just as before. It also lets you specify a stop-loss policy similar to how strategies are specified.
Example
julia> strategy_config = HMA2Strategy => Dict()
julia> stops_config = DefaultStops => Dict()
julia> res = backtest(candle_observable, strategy_config, stops_config)TradingPipeline.decide Method
decide(strategy::AbstractStrategy, state::HSM.AbstractHsmState)
-> Union{Nothing, TradeDecision.T}The decide method takes the current strategy and the current state according to the state machine, and looks at the market data available to it to make a decision. Often, it decides to return nothing, but if conditions as defined by the strategy are met, it could return an HSM.AbstractHsmEvent which will cause the state machine to move to the next appropriate state.
There are decide methods for every state in the state machine.
sourceTradingPipeline.foo Method
foo(a::Int64; x, y)I'm just trying to figure out what can be passed in as kwargs.
It looks like Union{AbstractDict,NamedTuple} might work.
TradingPipeline.load_strategy Method
Initialize a long-only hma strategy.
- Looking for 330/440 crosses
TradingPipeline.percent_diff Method
percent_diff(a, b) -> AnyReturn the percent difference between a and b.
TradingPipeline.report Method
report(session::XO.SimulatorSession) -> DataFrame
Return a list of trades that happened during the simulator session.
sourceTradingPipeline.simulate Method
simulate(
candle_observable,
strategy_type::Type{<:TradingPipeline.AbstractStrategy};
kwargs...
) -> AnyRun a strategy on the simulator using the given candle_observable.
Return Values
A named tuple with the following keys will be returned: simulator_session, hsm, simultator_exchange_driver_subject, fill_observable, chart_subject, strategy_subject, simulator_session_actor.
Example
julia> candle_observable = df_candles_observable(btcusd1m)
IterableObservable(Candle, Vector{Candle}, Rocket.AsapScheduler)
julia> @unpack simulator_session, chart_subject = simulate(candle_observable, HMAStrategy);TradingPipeline.Stops.set_subject! Method
set_subject!(subject::Rocket.AbstractSubject)Mutate the subject of all TP.Stops state instances. This is my workaround for state machines being singletons.
source