Skip to content

TradingPipeline

  • Hello, how are you?

  • DocumenterVitepress.jl generates very good-looking output.

Documentation for TradingPipeline.

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.

source
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
julia> subtypes(TradingPipeline.AbstractExchangeResponse)
source
TradingPipeline.AbstractManualCommand Type

An AbstractManualCommand represents a manual intervention from a human to the StrategySubject.

Example

julia
julia> subtypes(TradingPipeline.AbstractExchangeResponse)
source
TechnicalIndicatorCharts.visualize Method
julia
visualize(
    t::Tuple{TechnicalIndicatorCharts.Chart, ExchangeOperations.AbstractSession};
    kwargs...
) -> LightweightCharts.LWCLayout

Let's see if I can visualize trades on top of a chart.

source
TradingPipeline.around Method
julia
around(
    ts::Dates.DateTime,
    df::DataFrames.AbstractDataFrame;
    before,
    after,
    ts_field
) -> Any

Return a few rows before and after the given timestamp ts in the DataFrame df.

source
TradingPipeline.backtest Function
julia
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}}}
) -> Any

This 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
julia> strategy_config = HMA2Strategy => Dict()
julia> stops_config = DefaultStops => Dict()
julia> res = backtest(candle_observable, strategy_config, stops_config)
source
TradingPipeline.decide Method
julia
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.

source
TradingPipeline.foo Method
julia
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.

source
TradingPipeline.load_strategy Method

Initialize a long-only simple golden cross strategy.

source
TradingPipeline.load_strategy Method

Initialize a long-only hma strategy.

  • Looking for 330/440 crosses
source
TradingPipeline.percent_diff Method
julia
percent_diff(a, b) -> Any

Return the percent difference between a and b.

source
TradingPipeline.report Method

report(session::XO.SimulatorSession) -> DataFrame

Return a list of trades that happened during the simulator session.

source
TradingPipeline.simulate Method
julia
simulate(
    candle_observable,
    strategy_type::Type{<:TradingPipeline.AbstractStrategy};
    kwargs...
) -> Any

Run 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
julia> candle_observable = df_candles_observable(btcusd1m)
IterableObservable(Candle, Vector{Candle}, Rocket.AsapScheduler)

julia> @unpack simulator_session, chart_subject = simulate(candle_observable, HMAStrategy);
source
TradingPipeline.Stops.set_subject! Method
julia
set_subject!(subject::Rocket.AbstractSubject)

Mutate the subject of all TP.Stops state instances. This is my workaround for state machines being singletons.

source