Skip to content

⚙️ Backtesting

Tomás Gaudino edited this page Aug 7, 2023 · 11 revisions

Description

Backtest strategies

Scope

  • ⚙️ Backtesting page
  • Integration with Optuna framework

Maintainers

Tasks

  • Adapt the page to the standards for all pages
  • Design UI
    • Other edge cases?
  • Improve date time filter (now is dynamic so probably will be good to wrap all the filters in an st.form
  • Candles graph: once we load the data based on the initial filter, we have to show the candles. The problem is that streamlit gets really slow when it’s displaying more than x candles. The solution will be adding a limit of candles to show and pagination to move all over the time available.
  • The text annotations of PNL and base inventory change were removed since in a lower timeframe and as we don’t have maximum candles to display it was impossible to read. We should add them again and also evaluate the frequency that we are going to use to display the updates in the PNL and Base inventory change
  • Adapt the page to the standards for all pages

Page structure:

  • Page 1: Create

    • Select strategy type: according to selected option should fetch different type of templates
      • Directional (starting point)
      • Market making (not now)
      • Grid (not now)
      • Etc..
    • Set strategy name
    • Press "Create" button
    • A code editor should appear with a specialized script
    • At this point you can edit the strategy code and...
      • Manage (edit, delete) via file explorer all the experiments
      • Edit your code in a VS Code editor with multiple tabs
      • Save your changes
  • Page 2: Optimize

    • Create a study from an existing script (with optimization version label included)
    • Run n trials with Optuna from an existing study
    • Open Optuna dashboard
    • At this point you can edit the study code and...
      • Manage (edit, delete) via file explorer all the studies
      • Edit your code in a VS Code editor with multiple tabs
      • Save your changes
  • Page 3: Analyze

    • Select Optuna database from "data/backtesting"
    • Choose a study from the selected database
    • Compare visually different trials depending on how much you can win/loss (net pnl pct vs max drawdown)
      • User can see through a hover label the experiment results
      • User can see through a hover label the strategy / backtesting configs
    • Choose a trial (every param will be set automatically)
    • Change (if necessary) trial strategy parameters
    • Set candlestick config:
      • Add positions
      • Add volume
      • Add PnL
    • Change (if necessary) trial backtesting parameters
      • Order amount
      • Leverage
      • Initial portfolio
      • Time limit
      • Take profit multiplier
      • Stop loss multiplier
    • Press "Run backtesting button"
      • Show visualizations (strongly based in trading view)
        • Market info: exchange, trading pair
        • General stats: start/end date, duration (hours), price change
        • Performance metrics: net pnl, total positions, % profitable, profit factor, max drawdown, avg profit, avg minutes, sharpe ratio
        • More metrics? (brainstorming)
          • Total volume
        • PnL Over Time
        • Candlestick
          • Paginated candlestick
        • Long vs Short analysis
        • Exit types
        • Transactions table --> Export to csv?
        • All metrics table --> Export to csv?
  • Page 4: Analyze (TBD)

Clone this wiki locally