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

Strategy performance chart color indicator error #858

Closed
kenkunz opened this issue Dec 3, 2024 · 0 comments · Fixed by #859
Closed

Strategy performance chart color indicator error #858

kenkunz opened this issue Dec 3, 2024 · 0 comments · Fixed by #859
Assignees
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
Contributor

kenkunz commented Dec 3, 2024

Issue

The strategy performance chart color indicator (green = profit, red = loss) displays the wrong color in specific edge cases (see investigation below).

Background

This was reported by @tsorro in discord. The issue is currently occurring on the Memecoin index strategy for the following timeframes: 3M, Max.

image

Steps to reproduce

  1. Open Memecoin index strategy
  2. Change timeframe to 3M
  3. Note the mismatch between the period performance summary value ▲ 1.3% and the chart color (red)
    • expected: performance summary value and chart color match (positive performance = green)
    • actual: performance summary value and chart color don't match (positive performance, red)

Investigation

The logic to determine the chart color used the rolled-up timeframe data for the roll-up grain (1h, 4h, 1d) that is used for a given selected timeframe (1W, 1M, 3M, Max). For a given summary "tick", the first closing value is subtracted from the last closing value; if positive, the color is set to green; if negative, red.

The bug occurs for the following edge case:

  • the chart timeframe is longer than the age of the strategy
  • the first rolled-up timeframe of the strategy has an opening value that is lower than the final closing value
  • the first rolled-up timeframe of the strategy has a closing value that is higher than the final closing value

The same issue occurs in reverse when:

  • the first rolled-up timeframe of the strategy has an opening value that is higher than the final closing value
  • the first rolled-up timeframe of the strategy has a closing value that is lower than the final closing value

Potential solutions

This could be fixed by subtracting the opening value from the first tick from the last closing value. However, the chart could then be green but with a downward slope (since the ticks are plotted based on closing value).

An alternative would be to include an extra tick at the beginning of the roll-up that represents a close value that matches the first roll-up tick's open value. For example, if the chart data starts mid-day on 2024-11-02, the first tick in a daily roll-up is (currently) that same date, with the final data point from that date serving as the close value. The modified roll-up would include an additional daily tick for 2024-11-01 with a close value equal to the earliest value from 2024-11-02. This seems like a reasonable way to summarize the data when rolling up to a day grain (with analogs for hourly or other gains), and has the benefit of having the chart slope match the color.

@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 Dec 3, 2024
@kenkunz kenkunz self-assigned this Dec 3, 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

Successfully merging a pull request may close this issue.

1 participant