Example #1
0
        private void ProcessMarketDataRequest()
        {
            int reqId = -1;

            try {
                int reqVersion = _enc.DecodeInt();
                reqId = _enc.DecodeInt();

                var contract = new IBContract();
                contract.Symbol  = _enc.DecodeString();
                contract.SecType = _enc.DecodeSecType();
                contract.Expiry  = _enc.DecodeExpiryDate();
                contract.Strike  = _enc.DecodeDouble();
                contract.Right   = _enc.DecodeString();
                if (ServerInfo.Version >= 15)
                {
                    contract.Multiplier = _enc.DecodeInt();
                }
                contract.Exchange = _enc.DecodeString();
                if (ServerInfo.Version >= 14)
                {
                    contract.PrimaryExch = _enc.DecodeString();
                }
                contract.Currency = _enc.DecodeString();
                if (ServerInfo.Version >= 2)
                {
                    contract.LocalSymbol = _enc.DecodeString();
                }
                if (ServerInfo.Version >= 8 && (contract.SecType == IBSecType.BAG))
                {
                    int comboLegCount = _enc.DecodeInt();
                    for (var i = 0; i < comboLegCount; i++)
                    {
                        IBComboLeg leg = new IBComboLeg();
                        leg.ConId    = _enc.DecodeInt();
                        leg.Ratio    = _enc.DecodeInt();
                        leg.Action   = _enc.DecodeAction();
                        leg.Exchange = _enc.DecodeString();
                        contract.ComboLegs.Add(leg);
                    }
                }

                if (ServerInfo.Version >= 31)
                {
                    string genericTickList = _enc.DecodeString();
                    if (genericTickList != null && genericTickList.Length > 0)
                    {
                        var list = new List <IBGenericTickType>();
                        foreach (var s in genericTickList.Split(','))
                        {
                            list.Add((IBGenericTickType)Enum.Parse(typeof(IBGenericTickType), s));
                        }
                    }
                }

                OnMarketDataRequest(reqId, contract);
            }
            catch (Exception e) {
                OnError(reqId, TWSErrors.FAIL_SEND_REQMKT);
                OnError(e.Message);
                Disconnect();
            }
        }
    private void ProcessMarketDataRequest()
    {
      int reqId = -1;
      try {
        int reqVersion = _enc.DecodeInt();
        reqId = _enc.DecodeInt();
        var contract = new IBContract {
                                        Symbol = _enc.DecodeString(),
                                        SecurityType = _enc.DecodeEnum<IBSecurityType>(),
                                        Expiry = _enc.DecodeExpiryDate(),
                                        Strike = _enc.DecodeDouble(),
                                        Right = _enc.DecodeString()
                                      };
        if (ServerInfo.Version >= 15)
          contract.Multiplier = _enc.DecodeString();
        contract.Exchange = _enc.DecodeString();
        if (ServerInfo.Version >= 14)
          contract.PrimaryExchange = _enc.DecodeString();
        contract.Currency = _enc.DecodeString();
        if (ServerInfo.Version >= 2)
          contract.LocalSymbol = _enc.DecodeString();
        if (ServerInfo.Version >= 8 && (contract.SecurityType == IBSecurityType.Bag)) {
          int comboLegCount = _enc.DecodeInt();
          for (int i = 0; i < comboLegCount; i++) {
            var leg = new IBComboLeg {
                                       ContractId = _enc.DecodeInt(),
                                       Ratio = _enc.DecodeInt(),
                                       Action = _enc.DecodeEnum<IBAction>(),
                                       Exchange = _enc.DecodeString()
                                     };
            contract.ComboLegs.Add(leg);
          }
        }

        if (ServerInfo.Version >= 31) {
          string genericTickList = _enc.DecodeString();
          if (!string.IsNullOrEmpty(genericTickList)) {
            var list = new List<IBGenericTickType>();
            foreach (string s in genericTickList.Split(','))
              list.Add((IBGenericTickType) Enum.Parse(typeof (IBGenericTickType), s));
          }
        }

        OnMarketDataRequest(reqId, contract);
      }
      catch (Exception e) {
        OnError(reqId, TWSErrors.FAIL_SEND_REQMKT);
        OnError(e.Message);
        Disconnect();
      }
    }
Example #3
0
        private void ProcessMarketDataRequest()
        {
            int reqId = -1;

            try {
                int reqVersion = _enc.DecodeInt();
                reqId = _enc.DecodeInt();
                var contract = new IBContract {
                    Symbol       = _enc.DecodeString(),
                    SecurityType = _enc.DecodeEnum <IBSecurityType>(),
                    Expiry       = _enc.DecodeExpiryDate(),
                    Strike       = _enc.DecodeDouble(),
                    Right        = _enc.DecodeString()
                };
                if (ServerInfo.Version >= 15)
                {
                    contract.Multiplier = _enc.DecodeString();
                }
                contract.Exchange = _enc.DecodeString();
                if (ServerInfo.Version >= 14)
                {
                    contract.PrimaryExchange = _enc.DecodeString();
                }
                contract.Currency = _enc.DecodeString();
                if (ServerInfo.Version >= 2)
                {
                    contract.LocalSymbol = _enc.DecodeString();
                }
                if (ServerInfo.Version >= 8 && (contract.SecurityType == IBSecurityType.Bag))
                {
                    int comboLegCount = _enc.DecodeInt();
                    for (int i = 0; i < comboLegCount; i++)
                    {
                        var leg = new IBComboLeg {
                            ContractId = _enc.DecodeInt(),
                            Ratio      = _enc.DecodeInt(),
                            Action     = _enc.DecodeEnum <IBAction>(),
                            Exchange   = _enc.DecodeString()
                        };
                        contract.ComboLegs.Add(leg);
                    }
                }

                if (ServerInfo.Version >= 31)
                {
                    string genericTickList = _enc.DecodeString();
                    if (!string.IsNullOrEmpty(genericTickList))
                    {
                        var list = new List <IBGenericTickType>();
                        foreach (string s in genericTickList.Split(','))
                        {
                            list.Add((IBGenericTickType)Enum.Parse(typeof(IBGenericTickType), s));
                        }
                    }
                }

                OnMarketDataRequest(reqId, contract);
            }
            catch (Exception e) {
                OnError(reqId, TWSErrors.FAIL_SEND_REQMKT);
                OnError(e.Message);
                Disconnect();
            }
        }