Contents Menu Expand Light mode Dark mode Auto light/dark mode
Trading Strategy documentation
  • Documention home
  • Getting started
  • Overview
    • About Trading Strategy
    • Vault data
    • Supported markets and venues
    • Accessing market data
    • Tooling
    • Oracles
  • Developing strategies
    • Setting up development environment
      • Github Codespaces
      • Visual Studio Code Dev Container for Jupyter Notebooks
      • Docker development image
      • PyCharm
      • Local Python installation
      • Google Colab
      • Binder development
    • Trading strategy examples
    • Code examples
      • Getting started coding tutorial (old)
      • Drawing DEX prices using OHLCV candle charts
      • Interactive charts
      • Technical analysis
      • Exploring trading pairs
      • Finding low fee trading pairs
      • Preface
      • Liquidity analysis
      • Price impact estimation
      • Query pool liquidity on a decentralised exchange
      • Dataset download
      • Charts and diagrams (old)
      • Lending protocols and short/long leverage data
      • Loading exchange, pair, and candlestick data for Uniswap V3
      • Streaming JSONL data
    • 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
      • Wrapped tokens
      • Profitability calculations
    • Troubleshooting
    • Internal development process
  • Architecture
    • Architecture overview
    • Command line application
    • Webhook server
    • Strategy types
    • Serialisation
    • Unit testing
  • Deploying live trading strategies
    • Trade-executor command
    • Live trading modes
    • Strategy metadata
    • Hot wallet deployment
    • Vault deployment
    • Website and monitoring
    • Managing Docker images
    • Turning backtest to an executable live trading strategy
    • Troubleshooting live trade execution deployments
    • Repairing frozen trading positions
    • Vault manual transactions
  • Learn algorithmic trading
    • Momentum
    • Trend Following
    • Mean Reversion
    • Statistical Arbitrage
    • Carry Trade
    • Technical Indicators
    • Order Flow
    • Market Microstructure
    • Market Regimes
    • Volatility Modeling
    • Time Series Forecasting
    • Signal Decomposition
    • Machine Learning
    • Reinforcement Learning
    • Portfolio Construction
    • Risk Management
    • Backtesting & Research Methodology
    • Algorithmic Trading
    • Cryptocurrency
    • Equity Factors
    • DeFi & AMMs
    • To follow
    • Conference presentations and videos
    • Books on algorithmic trading
    • Online courses on algorithmic trading
    • Tutorials on algorithmic trading
    • Python
    • Jupyter Notebook learning material
    • Algorithmic trading frameworks for Python
    • Code repositories
    • Communities around algorithmic trading
    • Develop tools and Jupyter Notebook environments
    • Charting solutions for Python
    • Additional algorithmic trading links
    • Developing portfolio construction trading strategies
  • Glossary
  • API reference
    • Market data client
      • client
        • BaseClient
        • Client
      • chain
        • ChainId
      • exchange
        • Exchange
        • ExchangeType
        • ExchangeUniverse
      • pair
        • DEXPair
        • LegacyPairUniverse
        • PandasPairUniverse
        • generate_address_columns
        • resolve_pairs_based_on_ticker
      • candle
        • Candle
        • CandleResult
        • GroupedCandleUniverse
        • TradingPairDataAvailability
        • is_candle_green
        • is_candle_red
      • liquidity
        • GroupedLiquidityUniverse
        • LiquidityResult
        • ResampledLiquidityUniverse
        • XYLiquidity
      • trade
        • Trade
      • timebucket
        • TimeBucket
      • token
        • Token
      • reader
        • read_parquet
      • priceimpact
        • HistoricalXYPriceImpactCalculator
        • LiquiditySampleMeasure
        • PriceImpact
        • estimate_xyk_price_impact
      • stablecoin
        • is_derivative
        • is_stablecoin_like
      • types
      • utils
        • columnar
          • iterate_columnar_dicts
        • df_index
          • flatten_dataframe_datetime_index
          • get_timestamp_index
        • format
          • format_duration_days_hours_mins
          • format_percent
          • format_percent_2_decimals
          • format_price
          • format_value
          • string_to_eth_address
        • forward_fill
          • forward_fill
        • groupeduniverse
          • PairGroupedUniverse
          • filter_for_pairs
          • filter_for_single_pair
          • resample_candles
          • resample_dataframe
          • resample_price_series
          • resample_rolling
          • resample_series
        • jupyter
          • JupyterOutputMode
          • display_with_styles
          • format_links_for_html_output
          • get_notebook_output_mode
          • is_pyodide
          • make_clickable
        • liquidity_filter
          • build_liquidity_summary
          • get_liquidity_today
          • get_somewhat_realistic_max_liquidity
        • mapper
        • schema
          • append_to_columnar_work_buffer
          • create_columnar_work_buffer
          • create_pyarrow_schema_for_dataclass
          • map_field_to_arrpw
          • unmappable
        • time
          • assert_compatible_timestamp
          • floor_pandas_month
          • floor_pandas_week
          • generate_monthly_timestamps
          • get_prior_timestamp
          • is_compatible_timestamp
          • naive_utcfromtimestamp
          • naive_utcnow
          • to_int_unix_timestamp
        • token_filter
          • StablecoinFilteringMode
          • filter_for_base_tokens
          • filter_for_blacklisted_tokens
          • filter_for_chain
          • filter_for_derivatives
          • filter_for_exchange
          • filter_for_exchange_ids
          • filter_for_exchanges
          • filter_for_nonascii_tokens
          • filter_for_quote_tokens
          • filter_for_rebases
          • filter_for_stablecoins
          • filter_for_trading_fee
          • filter_pairs_default
          • is_derivative
          • is_rebase
        • wrangle
          • filter_bad_wicks
          • fix_bad_wicks
          • fix_dex_price_data
          • remove_zero_candles
      • transport
        • base
          • BaseTransport
        • cache
          • CacheStatus
          • CachedHTTPTransport
          • wait_other_writers
        • data_trigger
          • wait_for_data
        • jsonl
          • load_candles_jsonl
          • load_trading_strategy_like_jsonl_data
        • pyodide
      • charting
        • candle_chart
          • VolumeBarMode
          • create_label
          • make_candle_labels
          • validate_ohclv_dataframe
          • validate_plot_info
          • visualise_ohlcv
      • testing
        • mock_client
          • MockClient
        • uniswap_v2_mock_client
          • UniswapV2MockClient
      • binance
        • constants
          • split_binance_symbol
        • downloader
          • BinanceDownloader
          • clean_time_series_data
          • get_binance_interval
          • get_indices_of_uneven_intervals
        • utils
          • add_info_columns_to_ohlc
          • generate_exchange_for_binance
          • generate_exchange_universe_for_binance
          • generate_lending_reserve_for_binance
          • generate_pair_for_binance
          • generate_pairs_for_binance
      • direct_feed
        • candle_feed
          • CandleFeed
          • prepare_raw_candle_data
        • conversion
          • CurrencyConversion
          • convert_to_float
        • dash
        • direct_feed_pair
        • ohlcv_aggregate
          • OHLCVCandle
          • get_feed_for_pair
          • resample_trades_into_ohlcv
          • truncate_ohlcv
        • store
          • DirectFeedStore
        • synthetic_feed
          • SyntheticTradeFeed
        • timeframe
          • Timeframe
        • trade_feed
          • SaveHook
          • Trade
          • TradeDelta
          • TradeFeed
        • trade_store
          • ParquetFileStore
          • TradeFeedStore
        • uniswap_v2
          • SwapKind
          • UniswapV2TradeFeed
          • calculate_reserve_price_in_quote_token_decimal
          • decode_swap
          • decode_sync
        • warn
          • disable_pandas_warnings
    • Trade execution engine
      • state
        • balance_update
          • BalanceUpdate
          • BalanceUpdateCause
          • BalanceUpdatePositionType
        • blockhain_transaction
          • BlockchainTransaction
          • BlockchainTransactionType
          • JSONAssetDelta
          • solidity_arg_encoder
        • generic_position
          • GenericPosition
        • identifier
          • AssetIdentifier
          • AssetType
          • AssetWithTrackedValue
          • ExchangeType
          • TradingPairIdentifier
          • TradingPairKind
        • interest
          • Interest
        • interest_distribution
          • AssetInterestData
          • InterestDistributionEntry
          • InterestDistributionOperation
        • loan
          • Loan
          • LoanSide
        • pickle_over_json
          • decode_pickle_over_json
          • encode_pickle_over_json
        • portfolio
          • Portfolio
        • position
          • TradingPosition
          • TriggerPriceUpdate
        • reserve
          • ReservePosition
        • revaluation
          • RevalueEvent
        • sync
          • Accounting
          • BalanceEventRef
          • Deployment
          • InterestSync
          • Sync
          • Treasury
        • trade
          • TradeExecution
          • TradeFlag
          • TradeStatus
          • TradeType
        • trigger
          • Trigger
          • TriggerCondition
          • TriggerType
        • types
        • uptime
          • Uptime
        • valuation
          • ValuationUpdate
        • visualisation
          • Plot
          • PlotKind
          • PlotLabel
          • PlotShape
          • RecordingTime
          • Visualisation
      • strategy
        • cycle
          • CycleDuration
          • round_datetime_down
          • round_datetime_up
          • snap_to_next_tick
          • snap_to_previous_tick
        • default_routing_options
          • TradeRouting
        • dust
          • get_dust_epsilon_for_asset
          • get_dust_epsilon_for_pair
          • get_relative_epsilon_for_asset
          • get_relative_epsilon_for_pair
        • engine_version
        • execution_context
          • ExecutionContext
          • ExecutionMode
        • lending_protocol_leverage
          • create_credit_supply_loan
          • create_short_loan
          • reset_credit_supply_loan
          • update_credit_supply_loan
          • update_short_loan
        • output
          • format_position
          • format_trade
          • output_positions
          • output_trades
        • pandas_trader
          • alternative_market_data
            • get_resample_frequency
            • load_candle_universe_from_dataframe
            • load_candle_universe_from_parquet
            • load_candles_from_dataframe
            • load_candles_from_parquet
            • replace_candles
            • resample_multi_pair
            • resample_single_pair
          • decision_trigger
            • UpdatedUniverseResult
            • fetch_availability
            • fetch_lending_data
            • fetch_price_data
            • update_universe
            • validate_latest_candles
            • wait_for_universe_data_availability_jsonl
          • indicator
            • CreateIndicatorsProtocolV1
            • CreateIndicatorsProtocolV2
            • DiskIndicatorStorage
            • IndicatorDefinition
            • IndicatorDependencyResolver
            • IndicatorKey
            • IndicatorResult
            • IndicatorSet
            • IndicatorSource
            • IndicatorStorage
            • MemoryIndicatorStorage
            • calculate_and_load_indicators
            • calculate_indicators
            • call_create_indicators
            • group_indicators
            • load_indicators
            • prepare_indicators
            • setup_indicator_multiprocessing
            • validate_function_kwargs
            • warm_up_indicator_cache
            • wrap_nones
          • token_mapper
            • TokenTuple
            • create_trading_universe_for_tokens
            • find_best_pairs_for_tokens
        • parameters
          • CoreStrategyParameters
          • StrategyParameters
          • dump_parameters
        • qstrader
        • reserve_currency
          • ReserveCurrency
        • strategy_cycle_trigger
          • StrategyCycleTrigger
        • strategy_type
          • StrategyType
        • tag
          • StrategyTag
        • 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
          • load_trading_and_lending_data
          • translate_credit_reserve
          • translate_token
          • translate_trading_pair
        • universe_model
          • StaticUniverseModel
          • StrategyExecutionUniverse
          • UniverseModel
          • UniverseOptions
        • weighting
          • check_normalised_weights
          • clip_to_normalised
          • normalise_weights
          • weight_by_1_slash_n
          • weight_by_1_slash_signal
          • weight_equal
          • weight_passthrouh
      • analysis
        • curve
          • CurveType
        • position
          • display_positions
          • display_reserve_position_events
        • regime
          • Regime
          • RegimeRegion
          • get_regime_signal_regions
        • slippage
          • display_slippage
        • timemap
          • ScoringMethod
          • visualise_weekly_time_heatmap
        • universe
          • analyse_long_short_universe
      • visual
        • bullbear
          • visualise_market_regime_filter
          • visualise_raw_market_regime_indicator
        • custom_indicators
          • calculate_on_balance_volume
        • image_output
          • open_bytes_in_browser
          • open_plotly_figure_in_browser
          • render_plotly_figure_as_image_file
        • qs_wrapper
          • import_quantstats_wrapped
        • technical_indicator
          • export_plot_as_dataframe
          • overlay_all_technical_indicators
          • visualise_technical_indicator
      • backtest
        • notebook
        • simulated_wallet
          • SimulatedWallet
      • ethereum
        • aave_v3
          • analysis
            • analyse_credit_trade_by_receipt
        • enzyme
          • asset
            • EnzymeAsset
            • EnzymeAssetType
            • load_enzyme_asset_list
          • tx
            • EnzymeTransactionBuilder
        • one_delta
          • analysis
            • analyse_credit_trade_by_receipt
            • analyse_leverage_trade_by_receipt
            • analyse_one_delta_trade
            • decode_path
        • revert
          • clean_revert_reason_message
        • token
          • fetch_token_as_asset
          • translate_token_details
        • tx
          • HotWalletTransactionBuilder
          • TransactionBuilder
        • uniswap_v2
        • uniswap_v3
        • universe
          • create_exchange_universe
          • create_pair_universe
        • web3config
          • Web3Config
      • cli
        • commands
          • shared_options
            • required_option
        • discord
          • get_discord_logging_handler
          • post_logging_discord_image
        • guard
          • generate_whitelist
          • get_enzyme_deployment
        • 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
          • setup_strategy_logging
        • 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
          • stop_watchdog
          • suicide
      • utils
        • accuracy
          • ensure_exact_zero
          • setup_decimal_accuracy
          • snap_to_epsilon
          • sum_decimal
        • binance
          • create_binance_universe
          • fetch_binance_dataset
        • blockchain
          • get_block_timestamp
          • get_latest_block_timestamp
        • cpu
          • get_safe_max_workers_count
        • crossover
          • contains_cross_over
          • contains_cross_under
        • dataclass
          • EthereumAddress
          • UTCFriendlyDataClassJsonMixin
        • default_strategies
          • get_default_strategies_path
        • format
          • calculate_percentage
        • fullname
          • get_object_full_name
        • increasing
          • is_monotonically_decreasing
          • is_monotonically_increasing
        • jupyter_notebook_folder
          • get_strategies_folder
        • jupyter_notebook_name
          • get_notebook_name
          • path
        • leverage_calculations
          • LeverageEstimate
          • calculate_liquidation_price
          • calculate_sizes_for_leverage
        • list
          • get_linearly_sampled_items
        • notebook
          • OutputMode
          • setup_charting_and_output
        • price
          • is_legit_price_value
        • profile
          • profiled
        • python_function
          • hash_function
        • python_module_loader
          • extract_module_members
          • import_python_source_file
        • ring_buffer_logging_handler
          • ExportedRecord
          • RingBufferHandler
        • sort
          • unique_sort
        • summarydataframe
          • Format
          • Value
          • as_bars
          • as_decimal
          • as_dollar
          • as_duration
          • as_integer
          • as_missing
          • as_percent
          • create_summary_table
          • format_value
          • format_values
        • 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
        • token
        • typing
        • url
          • get_url_domain
          • redact_url_password
      • webhook
        • error
          • convert_to_api_error_response
          • error_tween_factory
          • exception_response
          • exception_view
        • events
          • add_cors_headers
        • http_log
          • configure_http_request_logging
          • log_tween_factory
      • testing
        • pytest_helpers
          • is_failed_test
        • synthetic_ethereum_data
          • generate_random_ethereum_address
        • synthetic_price_data
          • generate_fixed_price_candles
          • generate_multi_pair_candles
          • generate_ohlcv_candles
          • load_ohlcv_parquet_file
        • synthetic_universe_data
          • create_synthetic_single_pair_universe
      • monkeypatch
        • cloudpickle_patch
          • reducer_override
        • dataclasses_json
          • patch_dataclasses_json
        • web3
          • construct_sign_and_send_raw_middleware
    • 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
Back to top
Edit this page

testing#

API documentation for tradingstrategy.testing Python module in Trading Strategy.

Module description#

Unit and integration testing helpers.

Submodules#

tradingstrategy.testing.mock_client

Mock client implementations that reads data from JSON files.

tradingstrategy.testing.uniswap_v2_mock_client

Client implementation that only uses Uniswap v2 on-chain data to generate datasets.

Next
mock_client
Previous
visualise_ohlcv

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

Contents
  • testing
    • Module description
    • Submodules