messy work. backtests / mock-data
This commit is contained in:
parent
4e4a048988
commit
fa70ada2bb
51 changed files with 2576 additions and 887 deletions
|
|
@ -1,6 +1,8 @@
|
|||
import { logger } from '@stock-bot/logger';
|
||||
import { EventEmitter } from 'events';
|
||||
import { IServiceContainer } from '@stock-bot/di';
|
||||
import { OrderRequest, Position } from '../types';
|
||||
import { StorageService } from '../services/StorageService';
|
||||
import { MarketDataService } from '../services/MarketDataService';
|
||||
import { ExecutionService } from '../services/ExecutionService';
|
||||
|
||||
interface VirtualAccount {
|
||||
|
|
@ -49,12 +51,17 @@ export class PaperTradingManager extends EventEmitter {
|
|||
private marketPrices = new Map<string, { bid: number; ask: number }>();
|
||||
private readonly COMMISSION_RATE = 0.001; // 0.1%
|
||||
private readonly MARGIN_REQUIREMENT = 0.25; // 25% margin requirement
|
||||
private container: IServiceContainer;
|
||||
|
||||
constructor(
|
||||
container: IServiceContainer,
|
||||
private storageService: StorageService,
|
||||
private marketDataService: MarketDataService,
|
||||
private executionService: ExecutionService,
|
||||
initialBalance: number = 100000
|
||||
) {
|
||||
super();
|
||||
this.container = container;
|
||||
|
||||
this.account = {
|
||||
balance: initialBalance,
|
||||
|
|
@ -362,6 +369,6 @@ export class PaperTradingManager extends EventEmitter {
|
|||
marginUsed: 0
|
||||
};
|
||||
|
||||
logger.info('Paper trading account reset');
|
||||
this.container.logger.info('Paper trading account reset');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue