Available translations

Common Metrics - Hits, Fails, Hit Ratio, Profit Loss, ROI, Annualized Rate of Return

foundations.png
Summary: These metrics are available in different contexts, for instance, at the level of the Episode, the Position or the Position, and both for the base and quoted assets.
Hits
Foundations->Node->Hits->Definition
hits.png
Hits counts the number of positions that closed with a positive profit loss, in the context of the parent node.
Foundations->Node->Hits->Content
In the context of the quoted asset or the base asset, hits are calculated relative to the asset in question. That is, if the base asset profit loss is positive, then a hit is counted for the base asset.
However, when the context of the asset is not specified—such as under the statistics node—then hits are calculated in a consolidated manner, converting the respective balances to perform the calculations.
Fails
Foundations->Node->Fails->Definition
fails.png
Fails counts the number of positions that closed with a negative profit loss, in the context of the parent node.
Foundations->Node->Fails->Content
Hit Ratio
Foundations->Node->Hit Ratio->Definition
hit-ratio.png
Hit ratio is the percentage of positions that closed with a positive profit loss, in the context of the parent node.
Foundations->Node->Hit Ratio->Content
Hit ratio results from multiplying the number of hits by 100 and dividing it by the number of positions: hit ratio = hits * 100 / positions.
Profit Loss
Foundations->Node->Profit Loss->Definition
profit-loss.png
Profit loss is the difference between the balance at the end and the balance at the beginning of a certain period, given by the context.
Foundations->Node->Profit Loss->Content
In the context of the base asset or the quoted asset, the calculation is done by subtracting the balances in the corresponding assets, using the variable appropriate to the larger context (i.e.: episode, position, etc.).
In general terms:
 base asset profit loss = base asset end balance - base asset begin balance
 quoted asset profit loss = quoted asset end balance - quoted asset begin balance
In the case of the Episode Base Asset and Episode Quoted Asset:
 tradingEngine.tradingCurrent.tradingEpisode.episodeBaseAsset.profitLoss.value =
    tradingEngine.tradingCurrent.tradingEpisode.episodeBaseAsset.balance.value -
    sessionParameters.sessionBaseAsset.config.initialBalance
    
tradingEngine.tradingCurrent.tradingEpisode.episodeQuotedAsset.profitLoss.value =
    tradingEngine.tradingCurrent.tradingEpisode.episodeQuotedAsset.balance.value -
    sessionParameters.sessionQuotedAsset.config.initialBalance
In the case of the Position Base Asset and Position Quoted Asset:
 tradingEngine.tradingCurrent.position.positionBaseAsset.profitLoss.value =
    tradingEngine.tradingCurrent.tradingEpisode.episodeBaseAsset.balance.value -
    tradingEngine.tradingCurrent.position.positionBaseAsset.beginBalance
    
tradingEngine.tradingCurrent.position.positionQuotedAsset.profitLoss.value =
    tradingEngine.tradingCurrent.tradingEpisode.episodeQuotedAsset.balance.value -
    tradingEngine.tradingCurrent.position.positionQuotedAsset.beginBalance
In the context of the episode statistics or the position statistics, the calculation is done consolidating the profits of both assets.
In the context of the episode statistics:
 tradingEngine.tradingCurrent.tradingEpisode.tradingEpisodeStatistics.profitLoss.value =
    tradingEngine.tradingCurrent.tradingEpisode.episodeBaseAsset.profitLoss.value * 
    tradingEngine.tradingCurrent.tradingEpisode.candle.close.value +
    tradingEngine.tradingCurrent.tradingEpisode.episodeQuotedAsset.profitLoss.value
In the context of the position statistics:
 tradingEngine.tradingCurrent.position.positionStatistics.profitLoss.value =
    tradingEngine.tradingCurrent.tradingEpisode.episodeBaseAsset.profitLoss.value * 
    tradingEngine.tradingCurrent.position.endRate.value +
    tradingEngine.tradingCurrent.tradingEpisode.episodeQuotedAsset.profitLoss.value
ROI
Foundations->Node->ROI->Definition
roi.png
ROI is a ratio that compares the profit loss with the cost of the investment, expressed as a percentage.
Foundations->Node->ROI->Content
In general financial terms, ROI is equal to the Net Return on Investment divided by the Cost of Investment, expressed as a percentage.
In Superalgos, the Net Return on Investment is the profit loss, as defined elsewhere. The Cost of Investment is solely the begin balance, as the fees are subtracted from the balance to calculate the profit loss, so we don’t need to account for them in the divisor side of the ratio.
That is:
 ROI = profit loss / begin balance * 100
In the context of the episode base asset and episode quoted asset, the calculation is done relative to the corresponding assets, and the overall context.
The formula:
 tradingEngine.tradingCurrent.tradingEpisode.episodeBaseAsset.ROI.value =
    tradingEngine.tradingCurrent.tradingEpisode.episodeBaseAsset.profitLoss.value /
    tradingEngine.tradingCurrent.tradingEpisode.episodeBaseAsset.beginBalance.value * 100 
    
tradingEngine.tradingCurrent.tradingEpisode.episodeQuotedAsset.ROI.value =
    tradingEngine.tradingCurrent.tradingEpisode.episodeQuotedAsset.profitLoss.value /
    tradingEngine.tradingCurrent.tradingEpisode.episodeQuotedAsset.beginBalance.value * 100
In the context of the position base asset and position quoted asset, the size filled is used instead of the balance, so that ROI may be properly calculated for complex execution algorithms.
The formula:
 tradingEngine.tradingCurrent.position.positionBaseAsset.ROI.value =
    tradingEngine.tradingCurrent.position.positionBaseAsset.profitLoss.value * 100 /
    tradingEngine.tradingCurrent.strategyOpenStage.stageBaseAsset.sizeFilled.value
    
tradingEngine.tradingCurrent.position.positionQuotedAsset.ROI.value =
    tradingEngine.tradingCurrent.position.positionQuotedAsset.profitLoss.value * 100 /
    tradingEngine.tradingCurrent.strategyOpenStage.stageQuotedAsset.sizeFilled.value
In the context of the episode statistics, the calculation is done using the consolidated balance, as explained in the profit loss definition.
Note: When the context does not refer to either of the assets in particular, then both asset balances are consolidated, and denominated in the quoted asset.
The formula:
 tradingEngine.tradingCurrent.tradingEpisode.tradingEpisodeStatistics.ROI.value =
    (
        tradingEngine.tradingCurrent.tradingEpisode.episodeBaseAsset.profitLoss.value * 
        tradingEngine.tradingCurrent.tradingEpisode.endRate.value +
        tradingEngine.tradingCurrent.tradingEpisode.episodeQuotedAsset.profitLoss.value
    ) / (
        tradingEngine.tradingCurrent.tradingEpisode.episodeBaseAsset.beginBalance.value * 
        tradingEngine.tradingCurrent.tradingEpisode.beginRate.value +
        tradingEngine.tradingCurrent.tradingEpisode.episodeQuotedAsset.beginBalance.value
    ) * 100
Annualized Rate Of Return
Foundations->Node->Annualized Rate Of Return->Definition
annualized-rate-of-return.png
Annualized rate of return is the equivalent ROI scaled to one year.
Foundations->Node->Annualized Rate Of Return->Content
In other words, it is the equivalent annual return received over a given period.
The formula:
 annualized rate of return = 
(((investment + profits) / investments) ^ (365 / days)) - 1
In the context of the episode base asset and episode quoted asset, the calculation is done relative to the corresponding assets, and the overall context.
The formulas:
 tradingEngine.tradingCurrent.tradingEpisode.episodeBaseAsset.annualizedRateOfReturn.value = 
((( tradingEngine.tradingCurrent.tradingEpisode.episodeBaseAsset.beginBalance.value +
tradingEngine.tradingCurrent.tradingEpisode.episodeBaseAsset.profitLoss.value ) / 
tradingEngine.tradingCurrent.tradingEpisode.episodeBaseAsset.beginBalance.value) ^
(365 / tradingEngine.tradingCurrent.tradingEpisode.tradingEpisodeStatistics.days.value)) - 1

tradingEngine.tradingCurrent.tradingEpisode.episodeQuotedAsset.annualizedRateOfReturn.value = 
((( tradingEngine.tradingCurrent.tradingEpisode.episodeQuotedAsset.beginBalance.value +
tradingEngine.tradingCurrent.tradingEpisode.episodeQuotedAsset.profitLoss.value ) / 
tradingEngine.tradingCurrent.tradingEpisode.episodeQuotedAsset.beginBalance.value) ^
(365 / tradingEngine.tradingCurrent.tradingEpisode.tradingEpisodeStatistics.days.value)) - 1
The JavaScript code:
 tradingEngine.tradingCurrent.tradingEpisode.episodeBaseAsset.annualizedRateOfReturn.value = 
Math.pow(
             ( tradingEngine.tradingCurrent.tradingEpisode.episodeBaseAsset.beginBalance.value +
             tradingEngine.tradingCurrent.tradingEpisode.episodeBaseAsset.profitLoss.value ) / 
             tradingEngine.tradingCurrent.tradingEpisode.episodeBaseAsset.beginBalance.value
             , 
             (365 / tradingEngine.tradingCurrent.tradingEpisode.tradingEpisodeStatistics.days.value)
        ) - 1

tradingEngine.tradingCurrent.tradingEpisode.episodeQuotedAsset.annualizedRateOfReturn.value = 
Math.pow(
             ( tradingEngine.tradingCurrent.tradingEpisode.episodeQuotedAsset.beginBalance.value +
             tradingEngine.tradingCurrent.tradingEpisode.episodeQuotedAsset.profitLoss.value ) / 
             tradingEngine.tradingCurrent.tradingEpisode.episodeQuotedAsset.beginBalance.value
             , 
             (365 / tradingEngine.tradingCurrent.tradingEpisode.tradingEpisodeStatistics.days.value)
        ) - 1
In the context of the episode statistics, the calculation is done using the consolidated balance, as explained in the profit loss definition.
The JavaScript code:
 tradingEngine.tradingCurrent.tradingEpisode.tradingEpisodeStatistics.annualizedRateOfReturn.value =
Math.pow(
            (
                tradingEngine.tradingCurrent.tradingEpisode.episodeBaseAsset.beginBalance.value * 
                tradingEngine.tradingCurrent.tradingEpisode.beginRate.value +
                tradingEngine.tradingCurrent.tradingEpisode.episodeQuotedAsset.beginBalance.value +
                tradingEngine.tradingCurrent.tradingEpisode.episodeBaseAsset.profitLoss.value +
                tradingEngine.tradingCurrent.tradingEpisode.episodeQuotedAsset.profitLoss.value
            ) / 
            (
                tradingEngine.tradingCurrent.tradingEpisode.episodeBaseAsset.beginBalance.value * 
                tradingEngine.tradingCurrent.tradingEpisode.beginRate.value +
                tradingEngine.tradingCurrent.tradingEpisode.episodeQuotedAsset.beginBalance.value 
            ) 
        , 
            (
                365 / tradingEngine.tradingCurrent.tradingEpisode.tradingEpisodeStatistics.days.value
            ) 
        ) - 1
Previous
Balances
Next
Accounts Specific to the Open and Close Stages