TradingPipeline
Documentation for TradingPipeline.
TradingPipeline.simulate_sanity_check_failure_error
TradingPipeline.AbstractExchangeResponse
TradingPipeline.AbstractManualCommand
TechnicalIndicatorCharts.visualize
TradingPipeline.around
TradingPipeline.decide
TradingPipeline.load_strategy
TradingPipeline.load_strategy
TradingPipeline.pnl
TradingPipeline.pnl
TradingPipeline.qty
TradingPipeline.qty
TradingPipeline.report
TradingPipeline.simulate
TradingPipeline.@hsm
TradingPipeline.@pnl
TradingPipeline.@pnls
TradingPipeline.simulate_sanity_check_failure_error
— Constantsimulate_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
— TypeAn 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
— TypeAn AbstractManualCommand represents a manual intervention from a human to the StrategySubject.
Example
julia> subtypes(TradingPipeline.AbstractExchangeResponse)
TechnicalIndicatorCharts.visualize
— Methodvisualize(
+Home · TradingPipeline.jl TradingPipeline
Documentation for TradingPipeline.
TradingPipeline.simulate_sanity_check_failure_error
TradingPipeline.AbstractExchangeResponse
TradingPipeline.AbstractManualCommand
TechnicalIndicatorCharts.visualize
TradingPipeline.around
TradingPipeline.decide
TradingPipeline.load_strategy
TradingPipeline.load_strategy
TradingPipeline.pnl
TradingPipeline.pnl
TradingPipeline.qty
TradingPipeline.qty
TradingPipeline.report
TradingPipeline.simulate
TradingPipeline.@hsm
TradingPipeline.@pnl
TradingPipeline.@pnls
TradingPipeline.simulate_sanity_check_failure_error
— Constantsimulate_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.
sourceTradingPipeline.AbstractExchangeResponse
— TypeAn 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)
sourceTradingPipeline.AbstractManualCommand
— TypeAn AbstractManualCommand represents a manual intervention from a human to the StrategySubject.
Example
julia> subtypes(TradingPipeline.AbstractExchangeResponse)
sourceTechnicalIndicatorCharts.visualize
— Methodvisualize(
t::Tuple{TechnicalIndicatorCharts.Chart, ExchangeOperations.AbstractSession};
kwargs...
) -> LightweightCharts.LWCLayout
-
Let's see if I can visualize trades on top of a chart.
sourceTradingPipeline.around
— Methodaround(
+
Let's see if I can visualize trades on top of a chart.
sourceTradingPipeline.around
— Methodaround(
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
.
sourceTradingPipeline.decide
— Methoddecide(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.load_strategy
— MethodInitialize a long-only simple golden cross strategy.
sourceTradingPipeline.load_strategy
— MethodInitialize a long-only hma strategy.
- Looking for 330/440 crosses
sourceTradingPipeline.pnl
— Methodpnl(long::Long) -> TradingPipeline.Result
-
Calculate profit/loss of a long position.
sourceTradingPipeline.pnl
— Methodpnl(short::Short) -> TradingPipeline.Result
-
Calculate profit/loss of a short position.
sourceTradingPipeline.qty
— Methodqty(c::Contracts, price::Number)
Convert contracts into the equivalent quantity of the asset being traded.
sourceTradingPipeline.qty
— Methodqty(n::Number, price::Number)
This just returns n since the quantity n
.
sourceTradingPipeline.report
— Methodreport(session::XO.SimulatorSession) -> DataFrame
Return a list of trades that happened during the simulator session.
sourceTradingPipeline.simulate
— Methodsimulate(
+
Return a few rows before and after the given timestamp ts
in the DataFrame df
.
sourceTradingPipeline.decide
— Methoddecide(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.load_strategy
— MethodInitialize a long-only simple golden cross strategy.
sourceTradingPipeline.load_strategy
— MethodInitialize a long-only hma strategy.
- Looking for 330/440 crosses
sourceTradingPipeline.pnl
— Methodpnl(long::Long) -> TradingPipeline.Result
+
Calculate profit/loss of a long position.
sourceTradingPipeline.pnl
— Methodpnl(short::Short) -> TradingPipeline.Result
+
Calculate profit/loss of a short position.
sourceTradingPipeline.qty
— Methodqty(c::Contracts, price::Number)
Convert contracts into the equivalent quantity of the asset being traded.
sourceTradingPipeline.qty
— Methodqty(n::Number, price::Number)
This just returns n since the quantity n
.
sourceTradingPipeline.report
— Methodreport(session::XO.SimulatorSession) -> DataFrame
Return a list of trades that happened during the simulator session.
sourceTradingPipeline.simulate
— Methodsimulate(
candle_observable,
strategy_type::Type{<:TradingPipeline.AbstractStrategy};
kwargs...
@@ -21,4 +21,4 @@
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> candle_observable = df_candles_observable(btcusd1m)
IterableObservable(Candle, Vector{Candle}, Rocket.AsapScheduler)
-julia> @unpack simulator_session, chart_subject = simulate(candle_observable, HMAStrategy);
sourceTradingPipeline.@hsm
— Macro@hsm strategy_subject
Given a StrategySubject instance, define the states and transitions for a MarketOrderStrategyStateMachine, and return the singleton instance of that state machine.
sourceTradingPipeline.@pnl
— Macro@pnl entry exit quantity leverage
Calculate the profit/loss of a long positon. The quantity
and leverage
are optional.
sourceTradingPipeline.@pnls
— Macro@pnls entry exit quantity leverage
Calculate the profit/loss of a short positon. The quantity
and leverage
are optional.
sourceSettings
This document was generated with Documenter.jl version 1.8.0 on Sunday 29 December 2024. Using Julia version 1.11.2.
+julia> @unpack simulator_session, chart_subject = simulate(candle_observable, HMAStrategy);
TradingPipeline.@hsm
— Macro@hsm strategy_subject
Given a StrategySubject instance, define the states and transitions for a MarketOrderStrategyStateMachine, and return the singleton instance of that state machine.
TradingPipeline.@pnl
— Macro@pnl entry exit quantity leverage
Calculate the profit/loss of a long positon. The quantity
and leverage
are optional.
TradingPipeline.@pnls
— Macro@pnls entry exit quantity leverage
Calculate the profit/loss of a short positon. The quantity
and leverage
are optional.