messy work. backtests / mock-data
This commit is contained in:
parent
4e4a048988
commit
fa70ada2bb
51 changed files with 2576 additions and 887 deletions
|
|
@ -1,4 +1,6 @@
|
|||
import { logger } from '@stock-bot/logger';
|
||||
import { getLogger } from '@stock-bot/logger';
|
||||
|
||||
const logger = getLogger('PerformanceAnalyzer');
|
||||
import * as stats from 'simple-statistics';
|
||||
|
||||
export interface Trade {
|
||||
|
|
@ -168,6 +170,19 @@ export class PerformanceAnalyzer {
|
|||
analyzeDrawdowns(): DrawdownAnalysis {
|
||||
const drawdowns: number[] = [];
|
||||
const underwaterCurve: Array<{ date: Date; drawdown: number }> = [];
|
||||
|
||||
// Handle empty equity curve
|
||||
if (this.equityCurve.length === 0) {
|
||||
return {
|
||||
maxDrawdown: 0,
|
||||
averageDrawdown: 0,
|
||||
maxDrawdownDuration: 0,
|
||||
underwaterTime: 0,
|
||||
drawdownPeriods: [],
|
||||
currentDrawdown: 0
|
||||
};
|
||||
}
|
||||
|
||||
let peak = this.equityCurve[0].value;
|
||||
let maxDrawdown = 0;
|
||||
let currentDrawdownStart: Date | null = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue