Beispiel #1
0
        public void Start()
        {
            BarItemFile barItemFile = new BarItemFile(barDataFile);

            navigator = barItemFile.GetReader();

            lastPrice = navigator.ReadBarItem();

            Initialize(lastPrice);

            if (cachingEnabled)
            {
                OpenCache();
            }

            ForwardDataFeed(lastPrice);

            while (!navigator.EOF() && !paused)
            {
                lastPrice = navigator.ReadBarItem();
                //WriteBarItem2(barItem);
                ForwardDataFeed(lastPrice);
            }

            if (cachingEnabled)
            {
                CloseCache();
            }
        }
Beispiel #2
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);
        }
Beispiel #3
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);
        }