kernc / kernc/backtesting.py

SQN calculation not using expectancy?

Open
#558 1 comment 0 reactions 0 assignees View on GitHub
help wanted
Dominant language
Python
Stars
9k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

Hi,

It's good to see the stats include SQN. According to https://evilspeculator.com/tools-section/concepts/:

SQN = root(n) * expectancy / stdev(R)

but I suspect it's not correctly calculated:

https://github.com/kernc/backtesting.py/blob/77f4c46b82169c2689e1c4ad5994765556179eb2/backtesting/_stats.py#L139

as it's not using the result of expectancy:

https://github.com/kernc/backtesting.py/blob/77f4c46b82169c2689e1c4ad5994765556179eb2/backtesting/_stats.py#L138

Unless I am missing something?

Thanks!

Contributor guide

Open the contributing guide

Research direction

Start in backtesting/_stats.py at the referenced lines 138-139 and compare the SQN calculation with the linked expectancy formula. Confirm whether the computed expectancy is omitted, then verify that the corrected SQN result matches the documented definition and the project's relevant checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
fintech-quant
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.