Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annual return values in metadata and state don't match #1031

Open
kenkunz opened this issue Aug 26, 2024 · 0 comments
Open

Annual return values in metadata and state don't match #1031

kenkunz opened this issue Aug 26, 2024 · 0 comments
Labels
bug Something isn't working priority: P1 An important issue that must be fixed before the next release, but does nto require immediate focus. size: S A small task that can be completed in less than a day

Comments

@kenkunz
Copy link

kenkunz commented Aug 26, 2024

Issue

A strategy's annual return percent value is available from both metadata and state endpoints, but the values don't match.

Background

See item "B" in this discord thread.

The annual return percent is displayed in multiple places on frontend:

  • on the strategy index tiles and the overview page, the data comes from metadata endpoint's key_metrics.cagr property
  • on the performance page, the value comes from the state endpoint's long_short_metrics_latestannualised_return_percent property

Why two different data sources?

The data displayed on strategy tiles and overview page needs to be available fast and without massive data overhead, so it is included in the metadata endpoint.

The metrics table shown on the Performance page includes a lot more statistics, and is therefore included in the state endpoint (to avoid overloading metadata with too much data). The display of this data (order of elements, value formatting, labels, etc.) is fully controlled by the API – the only role that frontend plays is the table styling.

Steps to reproduce

The following steps can be reproduced for any strategy. Note that some strategies currently use live data for the metadata cagr value, while others use backtested data. When comparing the metadata and state values, be sure to compare the same source – the long_short_metrics_latest data includes both live_stats and backtested_stats. The example below uses live data for cagr, so it is compared the the live_stats data from the state endpoint.

  1. Request the cagr data from metadata endpoint:
    curl 'https://enzyme-polygon-matic-eth-usdc.tradingstrategy.ai/metadata' | jq '.summary_statistics.key_metrics.cagr'
    response
    {
      "kind": "cagr",
      "source": "live_trading",
      "value": 0.052799913985317914,
      "calculation_window_start_at": 1710974716,
      "calculation_window_end_at": 1724659698,
      "calculation_method": "historical_data",
      "unavailability_reason": null,
      "help_link": "https://tradingstrategy.ai/glossary/compound-annual-growth-rate-cagr",
      "name": null
    }
  2. Request the annualised_return_percent data from state endpoint:
    curl 'https://enzyme-polygon-matic-eth-usdc.tradingstrategy.ai/state' | jq '.stats.long_short_metrics_latest.live_stats.rows.annualised_return_percent'
    
    response
    {
      "kind": "annualised_return_percent",
      "source": "live_trading",
      "value": {
        "All": "5.19%",
        "Long": "5.19%",
        "Short": "-"
      },
      "calculation_window_start_at": 1710974716,
      "calculation_window_end_at": 1724659686,
      "calculation_method": null,
      "unavailability_reason": null,
      "help_link": null,
      "name": "Annualised return %"
    }
  3. Note the values from each of the endpoints.
    • expected: the values match (though the metadata value is a decimal value and the state value is a formatted percent)
    • actual: the values differ – in the above example: 0.05299… = 5.3% from metadata vs. 5.19% from state
@kenkunz kenkunz added bug Something isn't working priority: P1 An important issue that must be fixed before the next release, but does nto require immediate focus. size: S A small task that can be completed in less than a day labels Aug 26, 2024
@github-staff github-staff deleted a comment from masooddahmedd Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority: P1 An important issue that must be fixed before the next release, but does nto require immediate focus. size: S A small task that can be completed in less than a day
Projects
None yet
Development

No branches or pull requests

5 participants
@kenkunz @AlexTheLion123 and others