tradingstrategy-ai / frontend

Web frontend for TradingStrategy.ai
https://tradingstrategy.ai
131 stars 23 forks source link

Hide flagged strategy positions #812

Closed kenkunz closed 2 months ago

kenkunz commented 2 months ago

Goal

As a strategy admin, I want to be able to hide specific positions from frontend, in order to prevent users from being confused by erroneous data.

Background

See discord thread.

The following position was identified as problematic: https://tradingstrategy.ai/strategies/enzyme-polygon-eth-btc-rsi/closed-positions/4

This position shows a 40.2% loss. The actual trade impact was a slight gain, but the data is not reflected correctly due to some failed / repaired trades and some missing or incorrect data.

Since the total value of this position is so low, the recommended solution is to just hide the position. This requires flagging the position as hidden on the backend.

How to flag position as hidden?

It is not clear how we can currently flag the position as hidden. Positions don't currently have flags (trades do).

Recommendation: add flags property to TradingPosition class in trade-executor and include hidden as one of the enumerated flag options.

Alternative: a quick-and-dirty alternative would be to use the existing notes property. In order to denote a flag within the notes field, we may wish to use a standard convention, such as: Flags: foo, bar, hidden on it's own line within notes. This feels hack-y, though … much preferred to go with a real flags field.

Acceptance criteria

Given: a position that has been flagged as hidden on the backend (method tbd).

  1. For non-admin users
    1. the position is hidden on the strategy positions table
    2. the route for the position details returns a 404 Not found
  2. For admin users
    1. the position is included on the strategy positions table with a hidden badge shown and reduced opacity on the table row to indicate that this position would be hidden for non-admin users
    2. the route for the position details displays the position, with a hidden badge
kenkunz commented 2 months ago

Per discussion at backlog dig-through – for short term, we will hide the one problematic position in frontend by hard-coding this, and open a ticket to remove the "hack" code once we have agreement on the right way to flag positions as "hidden" (more scalable solution).