cleanup and fixed initial capital / commision / splippage
This commit is contained in:
parent
70da2c68e5
commit
d14380d740
19 changed files with 1344 additions and 33 deletions
|
|
@ -202,8 +202,9 @@ export abstract class BaseStrategy extends EventEmitter {
|
|||
}
|
||||
|
||||
protected getEquity(): number {
|
||||
// Simplified - in reality would calculate based on positions and market values
|
||||
return 100000 + this.performance.totalPnl; // Assuming 100k starting capital
|
||||
// Get initial capital from config parameters or default
|
||||
const initialCapital = this.config.parameters?.initialCapital || 100000;
|
||||
return initialCapital + this.performance.totalPnl;
|
||||
}
|
||||
|
||||
protected async signalToOrder(signal: Signal): Promise<OrderRequest | null> {
|
||||
|
|
|
|||
|
|
@ -272,13 +272,14 @@ export class SimpleMovingAverageCrossover extends BaseStrategy {
|
|||
}
|
||||
|
||||
// Try to get account balance from trading engine
|
||||
let accountBalance = 100000; // Default
|
||||
// Use initial capital from config parameters if available
|
||||
let accountBalance = this.config.parameters?.initialCapital || 100000;
|
||||
try {
|
||||
if (tradingEngine.getAccountBalance) {
|
||||
accountBalance = tradingEngine.getAccountBalance();
|
||||
} else if (tradingEngine.getTotalPnl) {
|
||||
const [realized, unrealized] = tradingEngine.getTotalPnl();
|
||||
accountBalance = 100000 + realized + unrealized; // Assuming 100k initial
|
||||
accountBalance = (this.config.parameters?.initialCapital || 100000) + realized + unrealized;
|
||||
}
|
||||
} catch (error) {
|
||||
logger.warn('Could not get account balance:', error);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue