Tester Stats
EntriesCalculator
Calculates entry counts by hour, weekday, and month based on the deals data.
Source code in strategytester5\stats.py
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 | |
by_hour()
Returns a Series with the count of entries for each hour of the day (0-23).
Source code in strategytester5\stats.py
532 533 534 | |
by_month()
Returns a Series with the count of entries for each month (1-12).
Source code in strategytester5\stats.py
540 541 542 | |
by_weekday()
Returns a Series with the count of entries for each weekday (0=Monday, 6=Sunday).
Source code in strategytester5\stats.py
536 537 538 | |
PLCalculator
Calculates profit and loss statistics by hour, weekday, and month based on the deals data.
Source code in strategytester5\stats.py
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 | |
__init__(deals_df)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deals_df
|
DataFrame
|
DataFrame containing deal records with columns like 'entry', 'type', 'profit', 'commission', and 'time'. |
required |
Source code in strategytester5\stats.py
548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 | |
loss_by_hour()
Returns a Series with the total loss for each hour of the day (0-23).
Source code in strategytester5\stats.py
566 567 568 | |
loss_by_month()
Returns a Series with the total loss for each month (1-12).
Source code in strategytester5\stats.py
583 584 585 | |
loss_by_weekday()
Returns a Series with the total loss for each weekday (0=Monday, 6=Sunday).
Source code in strategytester5\stats.py
574 575 576 577 | |
profit_by_hour()
Returns a Series with the total profit for each hour of the day (0-23).
Source code in strategytester5\stats.py
570 571 572 | |
profit_by_month()
Returns a Series with the total profit for each month (1-12).
Source code in strategytester5\stats.py
587 588 589 | |
profit_by_weekday()
Returns a Series with the total profit for each weekday (0=Monday, 6=Sunday).
Source code in strategytester5\stats.py
579 580 581 | |
TesterStats
Computes various statistics from the tester results, including trade performance metrics, drawdowns, and more.
This class is responsible fo calculating all the stats you see in the HTML report
Source code in strategytester5\stats.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 | |
ahpr_factor
property
AHPR = (1 + r1) * (1 + r2) * ... * (1 + rn)^(1/n) - 1, where r_i are per-trade returns in fraction (e.g., 0.01 = +1%)
ahpr_percent
property
AHPR in percent form.
average_consecutive_losses
property
Average loss from consecutive losing trades.
average_consecutive_wins
property
Average profit from consecutive winning trades.
average_loss_trade
property
Average loss from unprofitable trades.
average_profit_trade
property
Average profit from profitable trades.
balance_drawdown_absolute
property
Absolute drawdown for balance curve.
balance_drawdown_maximal
property
MT5 maximal drawdown uses local-high, next local low definition, which can be different from absolute drawdown.
balance_drawdown_relative
property
MT5 relative drawdown uses local high, next local low (max %)
equity_drawdown_absolute
property
Absolute drawdown for equity curve.
equity_drawdown_maximal
property
MT5 maximal drawdown uses local-high, next local low definition, which can be different from absolute drawdown.
equity_drawdown_relative
property
MT5 relative drawdown uses local high, next local low (max %)
expected_payoff
property
Expected payoff (net profit / total trades).
ghpr_factor
property
GHPR = ((1 + r1) * (1 + r2) * ... * (1 + rn))^(1/n) - 1, where r_i are per-trade returns in fraction (e.g., 0.01 = +1%)
ghpr_percent
property
GHPR in percent form.
gross_loss
property
Total loss from all unprofitable trades.
gross_profit
property
Total profit from all profitable trades.
largest_loss_trade
property
Largest loss from a single trade.
largest_profit_trade
property
Largest profit from a single trade.
long_trades_won
property
Number of long (BUY) trades that were profitable (profit > 0) at closing.
loss_trades
property
Number of trades that were not profitable (profit <= 0) at closing.
lr_correlation
property
Correlation coefficient (r-value) from linear regression of balance curve over time.
lr_standard_error
property
Standard error of the estimate from linear regression of balance curve over time.
margin_level
property
Minimum margin level (%) during the test.
maximal_consecutive_loss_count
property
Maximum number of consecutive losing trades.
maximal_consecutive_loss_money
property
Maximum money lost from consecutive losing trades.
maximal_consecutive_profit_count
property
Maximum number of consecutive profitable trades.
maximal_consecutive_profit_money
property
Maximum money won from consecutive profitable trades.
maximum_consecutive_losses_count
property
Maximum number of consecutive losing trades.
maximum_consecutive_losses_money
property
Maximum money lost from consecutive losing trades.
maximum_consecutive_wins_count
property
Maximum number of consecutive winning trades.
maximum_consecutive_wins_money
property
Maximum money won from consecutive winning trades.
net_profit
property
Net profit (gross profit - gross loss).
profit_factor
property
Profit factor (gross profit / gross loss).
profit_trades
property
Number of trades that were profitable (profit > 0) at closing.
recovery_factor
property
Recovery factor (net profit / maximal equity drawdown).
sharpe_ratio
property
(Return - 0) / std(Return)
short_trades_won
property
Number of short (SELL) trades that were profitable (profit > 0) at closing.
total_deals
property
The total number of deal records, including both entries and exits. Note that the first deal is usually the initial deposit and is not a real trade.
total_long_trades
property
Total number of long (BUY) trades closed during the test.
total_short_trades
property
Total number of short (SELL) trades closed during the test.
total_trades
property
Total number of trades opened and closed during the test.
z_score
property
Build win/loss sequence from CLOSED trades:
__init__(deals, initial_deposit, balance_curve, equity_curve, margin_level_curve, ticks, symbols)
Initializes the TesterStats object with the provided data and computes all statistics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deals
|
list
|
List of deal records from the tester. |
required |
initial_deposit
|
float
|
The initial deposit amount used in the test. |
required |
balance_curve
|
ndarray
|
Array representing the balance curve over time. |
required |
equity_curve
|
ndarray
|
Array representing the equity curve over time. |
required |
margin_level_curve
|
ndarray
|
Array representing the margin level curve over time. |
required |
ticks
|
int
|
Total number of ticks processed during the test. |
required |
symbols
|
int
|
Total number of unique symbols traded during the test. |
required |
Source code in strategytester5\stats.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
holding_time_calculator(entry_time, exit_time)
staticmethod
Calculates holding time statistics (min, max, average) for trades based on entry and exit times of positions.
Source code in strategytester5\stats.py
503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 | |