Пример #1
0
        public void GetSampleDataTest()
        {
            var data = SampleDataGenerator.GetSampleData(100, DateTimeOffset.Now.AddDays(-19), DateTimeOffset.Now,
                                                         TimeSpan.FromDays(1));

            Assert.IsTrue(data.Count == 20);
            Assert.IsTrue(data[0].Close == data[1].Open);
        }
Пример #2
0
        public GridOptimizerTests()
        {
            var startTime = DateTimeOffset.Now.AddDays(-10);
            var endTime   = DateTimeOffset.Now;

            _optimizerSettings = new OptimizerSettings
            {
                AccountBalance       = 10000,
                AccountLeverage      = 500,
                BacktesterType       = typeof(OhlcBacktester),
                BacktestSettingsType = typeof(BacktestSettings),
            };

            var data = SampleDataGenerator.GetSampleData(200, startTime, endTime, TimeSpan.FromDays(1));

            var symbol = new OhlcSymbol(new TimeBasedBars(TimeSpan.FromDays(1)))
            {
                Name = "Main"
            };
            var symbolData = new SymbolBacktestData(symbol, data);

            _optimizerSettings.SymbolsData = new List <ISymbolBacktestData> {
                symbolData
            };
            _optimizerSettings.BacktestSettingsParameters = new List <object>
            {
                startTime,
                endTime,
            }.ToArray();
            _optimizerSettings.TradeEngineType    = typeof(BacktestTradeEngine);
            _optimizerSettings.TimerContainerType = typeof(TimerContainer);
            _optimizerSettings.ServerType         = typeof(Server);
            _optimizerSettings.RobotSettingsType  = typeof(RobotParameters);
            _optimizerSettings.RobotType          = typeof(SampleBot);
            _optimizerSettings.Parameters         = new List <OptimizeParameter>()
            {
                new OptimizeParameter("Periods", 30, 50, 10),
                new OptimizeParameter("Deviation", 2),
                new OptimizeParameter("Range", 2000, 6000, 2000)
            };
            _optimizerSettings.BacktesterInterval = TimeSpan.FromHours(1);

            _optimizer = new GridOptimizer(_optimizerSettings);
        }
Пример #3
0
        public OptimizerTests()
        {
            var startTime = DateTimeOffset.Now.AddDays(-10);
            var endTime   = DateTimeOffset.Now;

            _optimizerSettings = new OptimizerSettings
            {
                AccountBalance       = 10000,
                AccountLeverage      = 500,
                BacktesterType       = typeof(OhlcBacktester),
                BacktestSettingsType = typeof(BacktestSettings),
            };

            var data = SampleDataGenerator.GetSampleData(200, startTime, endTime, TimeSpan.FromDays(1));

            var symbol = new OhlcSymbol(new Mock <IBars>().Object)
            {
                Name = "Main"
            };
            var symbolData = new SymbolBacktestData(symbol, data);

            _optimizerSettings.SymbolsData = new List <ISymbolBacktestData> {
                symbolData
            };
            _optimizerSettings.BacktestSettingsParameters = new List <object>
            {
                startTime,
                endTime,
            }.ToArray();
            _optimizerSettings.TradeEngineType          = typeof(BacktestTradeEngine);
            _optimizerSettings.TimerContainerType       = typeof(TimerContainer);
            _optimizerSettings.TimerContainerParameters = new object[] { Mode.Backtest };
            _optimizerSettings.ServerType        = typeof(Server);
            _optimizerSettings.RobotSettingsType = typeof(RobotParameters);
            _optimizerSettings.RobotType         = typeof(SampleBot);

            _optimizerMock = new Mock <Optimizer>(_optimizerSettings);
        }
Пример #4
0
        private List <IBar> GetData(double startPrice, DateTimeOffset startTime, DateTimeOffset endTime)
        {
            var interval = TimeSpan.FromDays(1);

            return(SampleDataGenerator.GetSampleData(startPrice, startTime, endTime, interval));
        }