Contents Menu Expand Light mode Dark mode Auto light/dark mode
Trading Strategy documentation
  • Documention home
  • Getting started
  • Overview
    • About Trading Strategy
    • Supported markets and venues
    • Accessing market data
    • Tooling
    • Oracles
    • Wrapped tokens
  • Developing strategies
    • Setting up development environment
      • Visual Studio Code Dev Container for Jupyter Notebooks
      • Docker development image
      • Binder development
      • Local Python installation
      • Google Colab
    • Code examples
      • Getting started coding tutorial
      • Drawing DEX prices using OHLCV candle charts
      • Interactive charts
      • Technical analysis
      • Exploring trading pairs
      • Liquidity analysis
      • Price impact estimation
      • Query pool liquidity on a decentralised exchange
      • Dataset download
      • Charts and diagrams (old)
    • Strategy examples
      • Running the strategy backtests and examples
      • EMA crossover strategy
      • EMA cross over strategy with stop loss
      • Portfolio construction model trading strategy example
      • Portfolio construction model example 2 (Trader Joe)
      • Trading pair analysis
      • Alpha model timeline
      • Individual pair analysis
      • Synthetic data backtesting example
      • Synthetic data w/stop loss backtesting example
      • Backtesting fee analysis
      • Generating synthetic trading data
      • Trade execution chart
      • Examining live trading strategy using notebook
      • Debugging live strategy
      • Osmosis ATOM-OSMO mean reversion strategy
      • Backtest template
    • API documentation
      • Market data client
        • client
          • Client
        • chain
          • ChainId
        • exchange
          • Exchange
          • ExchangeType
          • ExchangeUniverse
        • pair
          • DEXPair
          • LegacyPairUniverse
          • PandasPairUniverse
          • StablecoinFilteringMode
          • filter_for_exchanges
          • filter_for_quote_tokens
          • filter_for_stablecoins
          • resolve_pairs_based_on_ticker
        • candle
          • Candle
          • CandleResult
          • GroupedCandleUniverse
          • TradingPairDataAvailability
          • is_candle_green
          • is_candle_red
        • liquidity
          • GroupedLiquidityUniverse
          • LiquidityResult
          • ResampledLiquidityUniverse
          • XYLiquidity
        • timebucket
          • TimeBucket
        • reader
          • read_parquet
        • priceimpact
          • HistoricalXYPriceImpactCalculator
          • LiquiditySampleMeasure
          • PriceImpact
          • estimate_xyk_price_impact
        • stablecoin
          • is_stablecoin_like
        • types
        • portfolioanalyzer
          • AssetSnapshot
          • PortfolioAnalyzer
          • PortfolioSnapshot
          • expand_snapshot_to_row
          • expand_timeline
        • profitdistribution
          • plot_trade_profit_distribution
        • tradeanalyzer
          • AssetTradeHistory
          • SpotTrade
          • TradeAnalyzer
          • TradePosition
          • TradeSummary
          • expand_timeline
        • tradehint
          • TradeHint
          • TradeHintType
        • backtrader
          • DEXFeed
          • DEXStrategy
          • TradeRecorder
          • add_dataframes_as_feeds
          • analyse_strategy_trades
          • convert_backtrader_timestamp
          • prepare_candles_for_backtrader
          • reindex_pandas_for_backtrader
        • qstrader
          • DEXAsset
          • TradingStrategyDataSource
          • analyse_portfolio_development
          • analyse_trade_history
          • create_portfolio_snapshot
          • prepare_candles_for_qstrader
      • Trade execution engine
        • state
          • blockhain_transaction
            • BlockchainTransaction
            • solidity_arg_encoder
          • freeze
            • freeze_position_on_failed_trade
          • identifier
            • AssetIdentifier
            • TradingPairIdentifier
          • metadata
            • Metadata
          • portfolio
            • Portfolio
          • position
            • PositionType
            • TradingPosition
          • repair
            • RepairResult
            • find_trades_to_be_repaired
            • make_counter_trade
            • reconfirm_trade
            • repair_trade
            • repair_trades
            • unfreeze_position
          • reserve
            • ReservePosition
          • revaluation
            • RevalueEvent
          • state
            • State
          • statistics
            • FinalPositionStatistics
            • PortfolioStatistics
            • PositionStatistics
            • Statistics
            • calculate_naive_profitability
          • store
            • JSONFileStore
            • NoneStore
            • StateStore
            • StateStoreModel
          • sync
            • DummmyWalletSyncer
            • apply_sync_events
          • trade
            • TradeExecution
            • TradeStatus
            • TradeType
          • types
          • uptime
            • Uptime
          • validator
            • validate_nested_state_dict
            • validate_state_serialisation
            • validate_state_value
            • walk
          • visualisation
            • Plot
            • PlotKind
            • PlotShape
            • Visualisation
        • strategy
          • alpha_model
            • AlphaModel
            • TradingPairSignal
          • approval
            • ApprovalModel
            • ApprovalType
            • UncheckedApprovalModel
          • bootstrap
            • bootstrap_strategy
            • import_strategy_file
            • make_factory_from_strategy_mod
          • cycle
            • CycleDuration
            • round_datetime_down
            • round_datetime_up
            • snap_to_next_tick
            • snap_to_previous_tick
          • default_routing_options
            • TradeRouting
          • description
            • StrategyExecutionDescription
          • dummy
            • DummyExecutionModel
          • execution_context
            • ExecutionContext
            • ExecutionMode
          • execution_model
            • ExecutionModel
            • TradeExecutionType
          • factory
            • StrategyFactory
          • output
            • format_position
            • format_trade
            • output_positions
            • output_trades
          • pandas_trader
            • decision_trigger
              • UpdatedUniverseResult
              • fetch_availability
              • fetch_data
              • update_universe
              • validate_latest_candles
              • wait_for_universe_data_availability_jsonl
            • position_manager
              • PositionManager
            • rebalance
              • get_existing_portfolio_weights
              • get_weight_diffs
              • rebalance_portfolio_old
            • runner
              • PandasTraderRunner
            • trade_decision
              • TradeDecider
          • pricing_model
            • PricingModel
          • qstrader
            • alpha_model
              • AlphaModel
            • order_sizer
              • CashBufferedOrderSizer
            • portfolio_construction_model
              • PortfolioConstructionModel
            • runner
              • QSTraderRunner
          • reserve_currency
            • ReserveCurrency
          • reverse_universe
            • DataRangeMode
            • reverse_trading_universe_from_state
          • routing
            • RoutingModel
            • RoutingState
          • run_state
            • ExceptionData
            • LatestStateVisualisation
            • RunState
          • runner
            • StrategyRunner
          • stop_loss
            • check_position_triggers
            • report_position_triggered
          • strategy_cycle_trigger
            • StrategyCycleTrigger
          • strategy_module
            • CreateTradingUniverseProtocol
            • DecideTradesProtocol
            • StrategyModuleInformation
            • parse_strategy_module
            • pregenerated_create_trading_universe
            • read_strategy_module
          • strategy_type
            • StrategyType
          • summary
            • StrategySummary
            • StrategySummaryStatistics
          • trade_pricing
            • TradePricing
            • format_fees_dollars
            • format_fees_percentage
          • trading_strategy_universe
            • Dataset
            • DefaultTradingStrategyUniverseModel
            • TradingStrategyUniverse
            • TradingStrategyUniverseModel
            • create_pair_universe_from_code
            • load_all_data
            • load_pair_data_for_single_exchange
            • load_partial_data
            • translate_token
            • translate_trading_pair
          • universe_model
            • StaticUniverseModel
            • StrategyExecutionUniverse
            • UniverseModel
            • UniverseOptions
          • valuation
            • ValuationModel
            • ValuationModelFactory
          • weighting
            • check_normalised_weights
            • clip_to_normalised
            • normalise_weights
            • weight_by_1_slash_n
            • weight_passthrouh
        • analysis
          • alpha_model_analyser
            • construct_event_timeline
            • create_alpha_model_timeline_all_assets
            • render_alpha_model_plotly_table
          • multipair
            • analyse_multipair
            • analyse_pair_trades
            • forma_multipair_summary
          • trade_analyser
            • AssetTradeHistory
            • SpotTrade
            • TimelineRowStylingMode
            • TimelineStyler
            • TradeAnalysis
            • TradePosition
            • TradeSummary
            • avg
            • build_trade_analysis
            • expand_timeline
            • expand_timeline_raw
        • visual
          • benchmark
            • visualise_all_cash
            • visualise_benchmark
            • visualise_buy_and_hold
            • visualise_portfolio_equity_curve
          • equity_curve
            • calculate_aggregate_returns
            • calculate_cumulative_return
            • calculate_equity_curve
            • calculate_returns
            • get_daily_returns
          • image_output
            • render_plotly_figure_as_image_file
          • single_pair
            • export_trade_for_dataframe
            • export_trades_as_dataframe
            • get_position_hover_text
            • visualise_positions_with_duration_and_slippage
            • visualise_single_pair
            • visualise_single_pair_positions_with_duration_and_slippage
            • visualise_trades
          • strategy_state
            • draw_single_pair_strategy_state
          • technical_indicator
            • export_plot_as_dataframe
            • overlay_all_technical_indicators
            • visualise_technical_indicator
        • backtest
          • backtest_execution
            • BacktestExecutionModel
            • fix_sell_token_amount
          • backtest_pricing
            • BacktestSimplePricingModel
            • backtest_pricing_factory
          • backtest_routing
            • BacktestRoutingIgnoredModel
            • BacktestRoutingModel
            • BacktestRoutingState
          • backtest_runner
            • BacktestSetup
            • guess_data_delay_tolerance
            • run_backtest
            • run_backtest_inline
            • setup_backtest
            • setup_backtest_for_universe
          • backtest_sync
            • BacktestSyncer
          • backtest_valuation
            • BacktestValuationModel
            • backtest_valuation_factory
          • data_preload
            • preload_data
          • simulated_wallet
            • SimulatedWallet
        • ethereum
          • eth_pricing_model
            • EthereumPricingModel
          • eth_valuation
            • EthereumPoolRevaluator
          • ethereumtrader
            • EthereumTrader
            • get_base_quote_contracts
            • get_mock_erc20_contract
          • execution
            • EthereumExecutionModel
            • approve_infinity
            • approve_tokens
            • broadcast
            • confirm_approvals
            • get_held_assets
            • get_swap_transactions
            • is_swap_function
            • prepare_swaps
            • report_failure
            • translate_to_naive_swap
            • update_confirmation_status
            • wait_trades_to_complete
          • hot_wallet_sync
            • EthereumHotWalletReserveSyncer
          • routing_data
            • RoutingData
            • create_compatible_routing
            • create_uniswap_v2_compatible_routing
            • create_uniswap_v3_compatible_routing
            • get_backtest_routing_model
            • get_pancake_default_routing_parameters
            • get_quickswap_default_routing_parameters
            • get_routing_model
            • get_trader_joe_default_routing_parameters
            • get_uniswap_v2_compatible_routing_types
            • get_uniswap_v2_default_routing_parameters
            • get_uniswap_v3_compatible_routing_types_eth
            • get_uniswap_v3_compatible_routing_types_poly
            • get_uniswap_v3_ethereum_default_routing_parameters
            • get_uniswap_v3_polygon_default_routing_parameters
            • validate_reserve_currency
          • routing_model
            • EthereumRoutingModel
          • routing_state
            • EthereumRoutingState
            • get_base_quote
            • get_base_quote_intermediary
            • get_token_for_asset
            • route_tokens
          • tx
            • TransactionBuilder
          • uniswap_v2_execution
            • UniswapV2ExecutionModel
            • get_current_price
          • uniswap_v2_execution_v0
            • UniswapV2ExecutionModelVersion0
            • UniswapV2RoutingInstructions
            • broadcast_and_resolve
            • resolve_trades
          • uniswap_v2_live_pricing
            • UniswapV2LivePricing
            • uniswap_v2_live_pricing_factory
          • uniswap_v2_routing
            • UniswapV2RoutingState
            • UniswapV2SimpleRoutingModel
            • get_uniswap_for_pair
          • uniswap_v2_valuation
            • UniswapV2PoolRevaluator
            • uniswap_v2_sell_valuation_factory
          • uniswap_v2_valuation_v0
            • UniswapV2PoolValuationMethodV0
            • uniswap_v2_sell_valuation_factory
          • uniswap_v3_execution
            • UniswapV3ExecutionModel
            • get_current_price
          • uniswap_v3_live_pricing
            • UniswapV3LivePricing
            • uniswap_v3_live_pricing_factory
          • uniswap_v3_routing
            • UniswapV3RoutingState
            • UniswapV3SimpleRoutingModel
            • get_uniswap_for_pair
          • uniswap_v3_valuation
            • UniswapV3PoolRevaluator
            • uniswap_v3_sell_valuation_factory
          • universe
            • create_exchange_universe
            • create_pair_universe
          • wallet
            • ReserveUpdateEvent
            • sync_reserves
            • update_wallet_balances
          • web3config
            • Web3Config
        • cli
          • approval
            • CLIApprovalModel
          • commands
            • app
            • check_universe
              • check_universe
            • check_wallet
              • check_wallet
            • console
              • console
              • launch_console
            • hello
              • hello
            • perform_test_trade
              • perform_test_trade
            • repair
              • repair
            • start
              • start
            • version
              • version
          • discord
            • get_discord_logging_handler
            • post_logging_discord_image
          • env
            • EnvVarDescription
            • get_available_env_vars
          • init
            • create_approval_model
            • create_metadata
            • create_state_store
            • create_trade_execution_model
            • create_web3_config
            • monkey_patch
            • prepare_cache
            • prepare_executor_id
            • validate_executor_id
          • latest_release
            • main
          • log
            • get_ring_buffer_handler
            • setup_custom_log_levels
            • setup_discord_logging
            • setup_file_logging
            • setup_in_memory_logging
            • setup_logging
            • setup_logstash_logging
            • setup_notebook_logging
            • setup_pytest_logging
          • loop
            • ExecutionLoop
          • main
          • result
            • display_backtesting_results
          • testtrade
            • make_test_trade
          • version_info
            • VersionInfo
          • watchdog
            • WatchdogMode
            • check_hung_workers
            • create_watchdog_registry
            • get_last_ping
            • get_timeout
            • get_watched_workers
            • mark_alive
            • register_worker
            • start_background_watchdog
            • suicide
        • utils
          • accuracy
            • setup_decimal_accuracy
            • sum_decimal
          • blockchain
            • get_latest_block_timestamp
          • dataclass
            • EthereumAddress
            • UTCFriendlyDataClassJsonMixin
          • format
            • calculate_percentage
          • fullname
            • get_object_full_name
          • price
            • is_legit_price_value
          • python_module_loader
            • extract_module_members
            • import_python_source_file
          • ring_buffer_logging_handler
            • ExportedRecord
            • RingBufferHandler
          • timer
            • timed_task
          • timestamp
            • convert_and_validate_timestamp
            • convert_and_validate_timestamp_as_float
            • convert_and_validate_timestamp_as_int
            • json_decode_timedelta
            • json_encode_timedelta
          • typing
          • url
            • get_url_domain
            • redact_url_password
        • webhook
          • api
            • web_home
            • web_logs
            • web_metadata
            • web_notify
            • web_ping
            • web_source
            • web_state
            • web_status
            • web_visulisation
          • app
            • Root
            • create_pyramid_app
            • forbidden_view
            • init_web_api
          • error
            • convert_to_api_error_response
            • error_tween_factory
            • exception_response
            • exception_view
          • events
            • add_cors_headers
          • server
            • WebhookServer
            • create_webhook_server
        • testing
          • backtest_trader
            • BacktestTrader
          • dummy_trader
            • DummyTestTrader
          • ethereumtrader_uniswap_v2
            • UniswapV2TestTrader
          • ethereumtrader_uniswap_v3
            • UniswapV3TestTrader
          • pairuniversetrader
            • PairUniverseTestTrader
          • simulated_execution_loop
            • set_up_simulated_execution_loop_uniswap_v2
            • set_up_simulated_execution_loop_uniswap_v3
          • simulated_trader
            • SimulatedTestTrader
          • synthetic_ethereum_data
            • generate_random_ethereum_address
          • synthetic_exchange_data
            • generate_exchange
            • generate_simple_routing_model
          • synthetic_price_data
            • generate_fixed_price_candles
            • generate_ohlcv_candles
            • load_ohlcv_parquet_file
        • monkeypatch
          • dataclasses_json
            • patch_dataclasses_json
      • Technical analysis
        • Statistics
          • entropy
          • kurtosis
          • mad
          • median
          • skew
          • stdev
          • tos_stdevall
          • variance
          • zscore
        • Overlap and moving averages
          • alma
          • dema
          • ema
          • fwma
          • hilo
          • hl2
          • hlc3
          • hma
          • hwma
          • ichimoku
          • jma
          • kama
          • linreg
          • ma
          • mcgd
          • midpoint
          • midprice
          • ohlc4
          • pwma
          • rma
          • sinwma
          • sma
          • ssf
          • supertrend
          • swma
          • t3
          • tema
          • trima
          • vidya
          • vwap
          • vwma
          • wcp
          • wma
          • zlma
        • Trend indicators
          • adx
          • amat
          • aroon
          • chop
          • cksp
          • decay
          • decreasing
          • dpo
          • increasing
          • long_run
          • psar
          • qstick
          • short_run
          • tsignals
          • ttm_trend
          • vhf
          • vortex
          • xsignals
        • Momentum indicators
          • ao
          • apo
          • bias
          • bop
          • brar
          • cci
          • cfo
          • cg
          • cmo
          • coppock
          • cti
          • dm
          • er
          • eri
          • fisher
          • inertia
          • kdj
          • kst
          • macd
          • mom
          • pgo
          • ppo
          • psl
          • pvo
          • qqe
          • roc
          • rsi
          • rsx
          • rvgi
          • slope
          • smi
          • squeeze
          • squeeze_pro
          • stc
          • stoch
          • stochrsi
          • td_seq
          • trix
          • tsi
          • uo
          • willr
        • Volatility indicators
          • aberration
          • accbands
          • atr
          • bbands
          • donchian
          • hwc
          • kc
          • massi
          • natr
          • pdist
          • rvi
          • thermo
          • true_range
          • ui
        • Volume based indicators
          • ad
          • adosc
          • aobv
          • cmf
          • efi
          • eom
          • kvo
          • mfi
          • nvi
          • obv
          • pvi
          • pvol
          • pvr
          • pvt
          • vp
        • Candle pattern indicators
          • cdl_doji
          • cdl_inside
          • cdl_pattern
          • cdl_z
          • ha
        • Market cycles
          • ebsw
        • Portfolio performance
          • drawdown
          • log_return
          • percent_return
      • Web3 Ethereum DeFi
    • Market data format details
      • Market data client
      • OHLCV Candle format
      • Tracked trading pairs and tokens
      • US dollar price conversion
      • Trading pair naming conventions
      • Internal ids
      • Token tax and deflationary tokens
      • Good trading pairs to start with
    • Troubleshooting
    • Internal development process
    • Old example strategies
      • Entropy Monkey (flip the coin)
      • Ape in (buy the latest token)
      • Double 7
      • Double 7 (advanced)
  • Running strategies
    • Architecture
    • Live trading
    • Command line application
    • Webhook server
    • Strategy types
    • Serialisation
    • Unit testing
    • Live strategy deployment
    • Repairing frozen trading positions
  • Protocol
    • Overview
    • Comparison
  • Learn algorithmic trading
    • Developing portfolio construction trading strategies
    • Conference presentations and videos
    • Books on algorithmic trading
    • Online courses on algorithmic trading
    • Tutorials on algorithmic trading
    • Papers about algorithmic trading
    • Jupyter Notebook learning material
    • Algorithmic trading frameworks for Python
    • Communities around algorithmic trading
    • Develop tools and Jupyter Notebook environments
    • Charting solutions for Python
    • Additional algorithmic trading links
  • Glossary
Back to top
Edit this page

Old example strategies#

This section contains old example algorithmic trading strategies. These were written for Backtrader and QSTrader backtesting engines. However, they have been phased oun in the favour of our internal tradeexecutor engine. The examples are here for a historical reference and might not run.

  • Entropy Monkey (flip the coin)
  • Ape in (buy the latest token)
  • Double 7
  • Double 7 (advanced)
Next
Entropy Monkey (flip the coin)
Previous
Internal development process

Trading Strategy is in beta and still under development. Any documentation is preliminary and not final.