示例#1
0
        public BacktestSession CreateSession(Guid accountId, TickerType tickerType, BarItemType barType, string barDataFile, Guid cacheId)
        {
            if (backtestSessions == null)
            {
                backtestSessions = new Dictionary <Guid, BacktestSession>();
            }

            this.cacheId = cacheId;

            //this line should raise an exception if file is invalid
            BarItemFile.ValidateFile(barDataFile);

            BacktestSession backtestSession = new BacktestSession(accountId, tickerType, barDataFile, cacheId);

            //backtestSession.SignalClosePosition += OnSignalClosePosition;
            //backtestSession.SignalOpenPosition += OnSignalOpenPosition;

            backtestSession.StrategyClosePosition += OnStrategyClosePosition;
            backtestSession.StrategyOpenPosition  += OnStrategyOpenPosition;

            backtestSessions.Add(backtestSession.SessionId, backtestSession);

            brokerAccounts[accountId].Orders.Initialize(barType, backtestSession.SessionId);

            return(backtestSession);
        }
示例#2
0
        public IBacktestSession CreateSession(CurrencyPairOption currencyPair, string barDataFile)
        {
            if (backtestSessions == null)
            {
                backtestSessions = new Dictionary <Guid, BacktestSession>();
            }

            //this line should raise an exception if file is invalid
            BarItemFile.ValidateFile(barDataFile);

            BacktestSession backtestSession = new BacktestSession(currencyPair, barDataFile);

            backtestSessions.Add(backtestSession.SessionId, backtestSession);

            return(backtestSession);
        }