Skip to content

Commit

Permalink
chore: success messages
Browse files Browse the repository at this point in the history
  • Loading branch information
simoneb committed Nov 28, 2023
1 parent e8dd819 commit f1cdd0c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 deletions.
24 changes: 24 additions & 0 deletions src/parsers/performance-report.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ const rules = [
)}. It should be at least 10`
}
}

return {
type: 'success',
message: `Return on Max Strategy Drawdown is ${value.toFixed(2)}`
}
},
function percentInTheMarket({ strategyAnalysis }) {
if (!strategyAnalysis) return
Expand All @@ -51,6 +56,13 @@ const rules = [
message: `The strategy spends more than 50% of the time in the market`
}
}

return {
type: 'success',
message: `The strategy spends ${value.toFixed(
2
)}% of the time in the market`
}
},
function numberOfTrades({ tradeAnalysis, settings }) {
if (!tradeAnalysis || !settings) return
Expand Down Expand Up @@ -78,6 +90,11 @@ const rules = [
message: `The strategy does more than 10 trades per month`
}
}

return {
type: 'success',
message: `The strategy does ${tradesPerYear.toFixed(2)} trades per year`
}
},
function tradeDuration({ listOfTrades }) {
if (!listOfTrades) return
Expand All @@ -96,6 +113,11 @@ const rules = [
}
}
}

return {
type: 'success',
message: `All trades last less than 10 days`
}
}
]

Expand All @@ -109,6 +131,8 @@ const columns = [
return '❌'
case 'warning':
return '⚠️'
case 'success':
return '✅'
default:
return 'ℹ️'
}
Expand Down
27 changes: 21 additions & 6 deletions test/performance-report.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,12 @@ describe('maxDD', () => {
})

test('pass', () => {
expect(runRules({ strategyAnalysis: [[KEYS.returnOnMaxDD, 10]] })).toEqual(
[]
)
expect(runRules({ strategyAnalysis: [[KEYS.returnOnMaxDD, 10]] })).toEqual([
{
type: 'success',
message: 'Return on Max Strategy Drawdown is 10.00'
}
])
})
})

Expand All @@ -96,7 +99,12 @@ describe('percent in the market', () => {
test('pass', () => {
expect(
runRules({ strategyAnalysis: [[KEYS.percentInTheMarket, '4.38%']] })
).toEqual([])
).toEqual([
{
message: 'The strategy spends 4.38% of the time in the market',
type: 'success'
}
])
})
})

Expand Down Expand Up @@ -148,7 +156,12 @@ describe('min trades', () => {
[KEYS.endDate, now]
]
})
).toEqual([])
).toEqual([
{
message: 'The strategy does 100.00 trades per year',
type: 'success'
}
])
})
})

Expand Down Expand Up @@ -204,6 +217,8 @@ describe('trade duration', () => {
[1, 1, 'EntryLong', 'Bias', new Date(2012, 1, 26)]
]
})
).toEqual([])
).toEqual([
{ message: 'All trades last less than 10 days', type: 'success' }
])
})
})

0 comments on commit f1cdd0c

Please sign in to comment.