Exemplo n.º 1
0
        public IbClient(RequestsClient client, MyAppSettings settings)
        {
            Client = client;

            Signal        = new EReaderMonitorSignal();
            ClientSocket  = new EClientSocket(this, Signal);
            AccountNumber = settings.AccountNumber;
            AccountID     = settings.AccountID;
            InstrumentID  = settings.InstrumentID;
        }
Exemplo n.º 2
0
 private void InitialiseClients()
 {
     client = new DataRequestClient.DataRequestClient(settings.AccountNumber, settings.Host,
                                                      settings.RealTimeDataServerRequestPort, settings.RealTimeDataServerPublishPort,
                                                      settings.HistoricalServerPort);
     client.Connect();
     client.HistoricalDataReceived += HistoricalDataReceived;
     requestClient = new RequestsClient(settings.AccountID,
                                        settings.InstrumentUpdateRequestSocketPort);
     wrapper.ClientSocket.reqAccountUpdates(true, settings.AccountNumber);
 }
Exemplo n.º 3
0
        private static void GetAccountNumberAndAccountID()
        {
            var requestClient = new RequestsClient(
                MyAppSettings.PushSocketPort, MyAppSettings.RequestSocketPort);
            var acc = requestClient.RequestAccount(MyAppSettings.AccountID);

            if (acc == null)
            {
                throw new ArgumentNullException("No account info received.");
            }
            requestClient.Dispose();

            ConfigurationRoot.GetSection("AccountNumber").Value = acc.AccountNumber;
            ConfigurationRoot.GetSection("AccountID").Value     = acc.ID.ToString();
            ConfigurationRoot.Reload();
            MyAppSettings = JsonConvert.DeserializeObject <MyAppSettings>(ConfigurationRoot.GetSection("MyAppSettings").Value);
        }
Exemplo n.º 4
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.º 5
0
 protected internal FollowingClient(MisskeyClient client) : base(client, "following")
 {
     Requests = new RequestsClient(client);
 }