Replies: 3 comments
-
I note that the test for NormalizeActions expects that outcome. But it does seem to give some confusing effects in the charts. |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm traveling so sorry for the late response. Yes, the NormalizeActions function ensures that an asset is first bought before it can be sold. So let's look at the examples again:
The input suggests holding, selling, and buying. Hold moves as is, but as the asset is not yet being bought, NormalizeAction replaces the Sell action with Hold.
This is already correctly ordered, so the function makes no changes to it.
Same here, as the asset is not yet being bought, it can't be sold, so the function replaces the first Sell action with an Hold. It helps removing the repeated Buy and Sell actions from the strategies when annotating the charts, also makes the actions aligned with how the outcome gets calculated. However I do see your point. I believe the Outcome function is already keeping track of its Buy/Sell ordering, so perhaps a small change here can make the earlier Sell actions visible on the chart without impacting the Outcome calculation. Once I am back, I can check to see if I can make this change. |
Beta Was this translation helpful? Give feedback.
-
I believe we resolved this, but please reopen if you need to. |
Beta Was this translation helpful? Give feedback.
-
I notice that the comment for strategy.NormalizeActions mentions that it will “ensure the order follows a pattern of Hold, Buy, Hold, Sell”.
A side effect of maintaining that pattern is that the output from it is not superficially intuitive. For example calling it with the sequences below (on the left) give rise to the following outputs (on the right):
They don’t quite ensure the pattern of Hold, Buy, Hold, Sell but what is quite surprising is that any initial Sell action is lost.
This caught me out when looking at the annotations on a strategy chart which was displaying a set of actions that happened to start with a Sell action - the result was that there was no Sell annotation displayed on the chart.
This will happen in all charts that use action.ActionsToAnnotations for generating their annotations as it calls NormalizeActions.
NormalizeAction looks like this:
My initial thought was that it should simply begin by initialising ‘last’ to Hold (just like DenormalizeAction does) but I wondered if there was a subtle reason for its behaviour?
Beta Was this translation helpful? Give feedback.
All reactions