Inheritance: FastQuant.InstrumentStrategy
Ejemplo n.º 1
0
        public override void Run()
        {
            // Get synthetic trading instrument.
            Instrument instrument1 = InstrumentManager.Instruments["NQ"];

            // Init roll info - leg index, symbol and maturity date.
            List <RollInfo> rollInfo = new List <RollInfo>()
            {
                new RollInfo(0, "NQZ3", new DateTime(2013, 12, 20)),
                new RollInfo(1, "NQH4", new DateTime(2014, 03, 21)),
            };

            // Add legs.
            for (var i = 0; i < rollInfo.Count; i++)
            {
                instrument1.Legs.Add(new Leg(InstrumentManager.Instruments[rollInfo[i].Symbol]));
            }

            // Main strategy.
            strategy = new Strategy(framework, "Roll");

            // Create BuySide strategy and add trading instrument.
            MyStrategy buySide = new MyStrategy(framework, "BuySide");

            buySide.Instruments.Add(instrument1);

            // Create SellSide strategy.
            RollSellSide sellSide = new RollSellSide(framework, "SellSide");

            sellSide.Global[RollSellSide.barSizeCode]  = barSize;
            sellSide.Global[RollSellSide.rollInfoCode] = rollInfo;

            // Set SellSide as data and execution provider for BuySide strategy.
            buySide.DataProvider      = sellSide;
            buySide.ExecutionProvider = sellSide;

            // Add strategies to main.
            strategy.AddStrategy(buySide);
            strategy.AddStrategy(sellSide);

            // Set DataSimulator's dates.
            DataSimulator.DateTime1 = new DateTime(2013, 01, 01);
            DataSimulator.DateTime2 = new DateTime(2013, 12, 31);

            // Add 4 hours bars (14400 seconds) for ins1.
            BarFactory.Add(instrument1, BarType.Time, barSize);

            // Run.
            StartStrategy();
        }
Ejemplo n.º 2
0
        public override void Run()
        {
            // Synthetic instrument.
            Instrument instrument1 = InstrumentManager.Instruments["NQ"];

            // Init roll info - leg index, symbol and maturity date.
            List <RollInfo> rollInfo = new List <RollInfo>()
            {
                new RollInfo(0, "NQZ3", new DateTime(2013, 12, 20)),
                new RollInfo(1, "NQH4", new DateTime(2014, 03, 21)),
            };

            // Add legs.
            for (var i = 0; i < rollInfo.Count; i++)
            {
                instrument1.Legs.Add(new Leg(InstrumentManager.Instruments[rollInfo[i].Symbol]));
            }

            // Main strategy.
            strategy = new Strategy(framework, "Roll");

            // Create BuySide strategy and add trading instrument.
            MyStrategy buySide = new MyStrategy(framework, "BuySide");

            buySide.Instruments.Add(instrument1);

            // Create SellSide strategy.
            RollSellSide sellSide = new RollSellSide(framework, "SellSide");

            sellSide.Global[RollSellSide.barSizeCode]  = barSize;
            sellSide.Global[RollSellSide.rollInfoCode] = rollInfo;

            // Set SellSide as data and execution provider for BuySide strategy.
            buySide.DataProvider      = sellSide;
            buySide.ExecutionProvider = sellSide;

            // Add strategies to main.
            strategy.AddStrategy(buySide);
            strategy.AddStrategy(sellSide);

            // Get provider for realtime.
            Provider quantRouter = framework.ProviderManager.Providers["QuantRouter"] as Provider;

            if (quantRouter.Status == ProviderStatus.Disconnected)
            {
                quantRouter.Connect();
            }

            if (StrategyManager.Mode == StrategyMode.Paper)
            {
                // Set QuantRouter as data provider.
                strategy.DataProvider = quantRouter as IDataProvider;
            }
            else if (StrategyManager.Mode == StrategyMode.Live)
            {
                // Set QuantRouter as data and execution provider.
                strategy.DataProvider      = quantRouter as IDataProvider;
                strategy.ExecutionProvider = quantRouter as IExecutionProvider;
            }

            BarFactory.Add(instrument1, BarType.Time, barSize);

            // Run.
            StartStrategy();
        }
Ejemplo n.º 3
0
        public override void Run()
        {
            // Synthetic instrument.
            Instrument instrument1 = InstrumentManager.Instruments["NQ"];

            // Init roll info - leg index, symbol and maturity date.
            List<RollInfo> rollInfo = new List<RollInfo>()
            {
                new RollInfo(0, "NQZ3", new DateTime(2013, 12, 20)),
                new RollInfo(1, "NQH4", new DateTime(2014, 03, 21)),
            };

            // Add legs.
            for (var i = 0; i < rollInfo.Count; i++)
                instrument1.Legs.Add(new Leg(InstrumentManager.Instruments[rollInfo[i].Symbol]));

            // Main strategy.
            strategy = new Strategy(framework, "Roll");

            // Create BuySide strategy and add trading instrument.
            MyStrategy buySide = new MyStrategy(framework, "BuySide");
            buySide.Instruments.Add(instrument1);

            // Create SellSide strategy.
            RollSellSide sellSide = new RollSellSide(framework, "SellSide");
            sellSide.Global[RollSellSide.barSizeCode] = barSize;
            sellSide.Global[RollSellSide.rollInfoCode] = rollInfo;

            // Set SellSide as data and execution provider for BuySide strategy.
            buySide.DataProvider = sellSide;
            buySide.ExecutionProvider = sellSide;

            // Add strategies to main.
            strategy.AddStrategy(buySide);
            strategy.AddStrategy(sellSide);

            // Get provider for realtime.
            Provider quantRouter = framework.ProviderManager.Providers["QuantRouter"] as Provider;

            if (quantRouter.Status == ProviderStatus.Disconnected)
                quantRouter.Connect();

            if (StrategyManager.Mode == StrategyMode.Paper)
            {
                // Set QuantRouter as data provider.
                strategy.DataProvider = quantRouter as IDataProvider;
            }
            else if (StrategyManager.Mode == StrategyMode.Live)
            {
                // Set QuantRouter as data and execution provider.
                strategy.DataProvider = quantRouter as IDataProvider;
                strategy.ExecutionProvider = quantRouter as IExecutionProvider;
            }

            BarFactory.Add(instrument1, BarType.Time, barSize);

            // Run.
            StartStrategy();
        }
Ejemplo n.º 4
0
        public override void Run()
        {
            // Get synthetic trading instrument.
            Instrument instrument1 = InstrumentManager.Instruments["NQ"];

            // Init roll info - leg index, symbol and maturity date.
            List<RollInfo> rollInfo = new List<RollInfo>()
            {
                new RollInfo(0, "NQZ3", new DateTime(2013, 12, 20)),
                new RollInfo(1, "NQH4", new DateTime(2014, 03, 21)),
            };

            // Add legs.
            for (var i = 0; i < rollInfo.Count; i++)
                instrument1.Legs.Add(new Leg(InstrumentManager.Instruments[rollInfo[i].Symbol]));

            // Main strategy.
            strategy = new Strategy(framework, "Roll");

            // Create BuySide strategy and add trading instrument.
            MyStrategy buySide = new MyStrategy(framework, "BuySide");
            buySide.Instruments.Add(instrument1);

            // Create SellSide strategy.
            RollSellSide sellSide = new RollSellSide(framework, "SellSide");
            sellSide.Global[RollSellSide.barSizeCode] = barSize;
            sellSide.Global[RollSellSide.rollInfoCode] = rollInfo;

            // Set SellSide as data and execution provider for BuySide strategy.
            buySide.DataProvider = sellSide;
            buySide.ExecutionProvider = sellSide;

            // Add strategies to main.
            strategy.AddStrategy(buySide);
            strategy.AddStrategy(sellSide);

            // Set DataSimulator's dates.
            DataSimulator.DateTime1 = new DateTime(2013, 01, 01);
            DataSimulator.DateTime2 = new DateTime(2013, 12, 31);

            // Add 4 hours bars (14400 seconds) for ins1.
            BarFactory.Add(instrument1, BarType.Time, barSize);

            // Run.
            StartStrategy();
        }