tradingstrategy-ai / trade-executor

A Python framework for managing positions and trades in DeFi
https://tradingstrategy.ai
Other
107 stars 29 forks source link

time in market from quantstats differs #978

Closed AlexTheLion123 closed 4 months ago

AlexTheLion123 commented 4 months ago

Summary

Time in market calculated using quantstats library e.g. through

from tradeexecutor.analysis.multi_asset_benchmark import compare_strategy_backtest_to_multiple_assets

compare_strategy_backtest_to_multiple_assets(
    state,
    strategy_universe,
    display=True,
)

can differ substantially from the time in market calculation calculated in our code:

from tradeexecutor.analysis.trade_analyser import build_trade_analysis

analysis = build_trade_analysis(state.portfolio)
summary = analysis.calculate_summary_statistics()
display(summary.to_dataframe())

Investigate and found out which is erroneous.