Exemplo n.º 1
0
 public StrategyLauncher(IbClient wrapper, MyAppSettings settings, bool useMatlab = false)
 {
     if (useMatlab)
     {
         //InitMatlabStrategy();
     }
     else
     {
         InitNetStrategy(wrapper, settings);
     }
 }
Exemplo n.º 2
0
        private static void ConnectToIb()
        {
            RequestsClient client = new RequestsClient(
                MyAppSettings.PushSocketPort, MyAppSettings.RequestSocketPort);

            client.Connect();



            wrapper = new IbClient(client, MyAppSettings);
            EClientSocket clientSocket = wrapper.ClientSocket;
            EReaderSignal readerSignal = wrapper.Signal;

            clientSocket.eConnect(MyAppSettings.InteractiveBrokersIP, MyAppSettings.InteractiveBrokersPort, 0);

            //Create a reader to consume messages from the TWS. The EReader will consume the incoming messages and put them in a queue
            var reader = new EReader(clientSocket, readerSignal);

            reader.Start();
            //Once the messages are in the queue, an additional thread need to fetch them
            new Thread(() =>
            {
                while (clientSocket.IsConnected())
                {
                    readerSignal.waitForSignal();
                    reader.processMsgs();
                }
            })
            {
                IsBackground = true
            }.Start();

            while (wrapper.NextOrderId <= 0)
            {
            }
        }
Exemplo n.º 3
0
 private void InitNetStrategy(IbClient wrapper, MyAppSettings settings)
 {
     strategy = new SimplestNetStrategy(wrapper, settings);
     strategy.StartTrading();
 }