Пример #1
0
 protected void OnContractDetails(int reqId, IBContractDetails contract)
 {
   if (ContractDetails != null)
     ContractDetails(this, new TWSContractDetailsEventArgs(this) {
       RequestId = reqId,
       ContractDetails = contract
     });
 }
Пример #2
0
 protected void OnScannerData(int reqId, int rank, IBContractDetails contract, string s, string distance, string benchmark, string projection)
 {
   if (ScannerData == null)
     return;
   ScannerData(this, new TWSScannerDataEventArgs(this) {
       RequestId = reqId,
       Contract = contract,
       Rank = rank,
       Distance = distance,
       Benchmark = benchmark,
       Projection = projection,
     });
 }
Пример #3
0
 private void ProcessScannerData()
 {
   var version = _enc.DecodeInt();
   var reqId = _enc.DecodeInt();
   var numberOfElements = _enc.DecodeInt();
   for (var i = 0; i < numberOfElements; i++) {
     var rank = _enc.DecodeInt();
     var contract = new IBContractDetails
       {
         Summary =
           {
             ContractId = version >= 3 ? _enc.DecodeInt() : 0,
             Symbol = _enc.DecodeString(),
             SecurityType = _enc.DecodeEnum<IBSecurityType>(),
             Expiry = DecodeIBExpiry(_enc),
             Strike = _enc.DecodeDouble(),
             Right = _enc.DecodeString(),
             Exchange = _enc.DecodeString(),
             Currency = _enc.DecodeString(),
             LocalSymbol = _enc.DecodeString()
           },
         MarketName = _enc.DecodeString(),
         TradingClass = _enc.DecodeString()
       };
     var distance = _enc.DecodeString();
     var benchmark = _enc.DecodeString();
     var projection = _enc.DecodeString();
     string legStr = null;
     if (version >= 2)
       legStr = _enc.DecodeString();
     OnScannerData(reqId, rank, contract, distance, benchmark, projection, legStr);
   }
 }
Пример #4
0
 protected void OnBondContractDetails(int reqId, IBContractDetails contract)
 {
   if (BondContractDetails != null)
     BondContractDetails(this, new TWSContractDetailsEventArgs(this) { ContractDetails = contract });
 }
Пример #5
0
    private void ProcessContractData()
    {
#if NET_4_5
      ProgressiveTaskCompletionSource<List<IBContractDetails>> completion = null;

      try
      {
#endif
        var version = _enc.DecodeInt();
        var reqId = -1;
        if (version >= 3)
          reqId = _enc.DecodeInt();
#if NET_4_5
        IFaultable tmp;
        if (_asyncCalls.TryGetValue(reqId, out tmp))
          completion = (ProgressiveTaskCompletionSource<List<IBContractDetails>>)tmp;
#endif
        var contractDetails = new IBContractDetails {
          Summary = {
            Symbol = _enc.DecodeString(),
            SecurityType = _enc.DecodeEnum<IBSecurityType>(),
            Expiry = DecodeIBExpiry(_enc),
            Strike = _enc.DecodeDouble(),
            Right = _enc.DecodeString(),
            Exchange = _enc.DecodeString(),
            Currency = _enc.DecodeString(),
            LocalSymbol = _enc.DecodeString()
          },
          MarketName = _enc.DecodeString(),
          TradingClass = _enc.DecodeString(),
          ContractId = _enc.DecodeInt(),
          MinTick = _enc.DecodeDouble(),
          Multiplier = _enc.DecodeString(),
          OrderTypes = _enc.DecodeString(),
          ValidExchanges = _enc.DecodeString()
        };
        if (version >= 2)
          contractDetails.PriceMagnifier = _enc.DecodeInt();

        if (version >= 4)
          contractDetails.UnderlyingContractId = _enc.DecodeInt();

        if (version >= 5) {
          contractDetails.LongName = _enc.DecodeString();
          contractDetails.Summary.PrimaryExchange = _enc.DecodeString();
        }
        if (version >= 6) {
          contractDetails.ContractMonth = _enc.DecodeString();
          contractDetails.Industry = _enc.DecodeString();
          contractDetails.Category = _enc.DecodeString();
          contractDetails.Subcategory = _enc.DecodeString();
          contractDetails.TimeZoneId = _enc.DecodeString();
          contractDetails.TradingHours = _enc.DecodeString();
          contractDetails.LiquidHours = _enc.DecodeString();
        }
        if (version >= 8) {
          contractDetails.EvRule = _enc.DecodeString();
          contractDetails.EvMultiplier = _enc.DecodeDouble();
        }
        if (version >= 7) {
          var secIdListCount = _enc.DecodeInt();
          if (secIdListCount > 0) {
            contractDetails.SecIdList = new List<IBTagValue>(secIdListCount);
            for (var i = 0; i < secIdListCount; ++i)
              contractDetails.SecIdList.Add(new IBTagValue { Tag = _enc.DecodeString(), Value = _enc.DecodeString() });
          }
        }
#if NET_4_5
        if (completion != null)
          completion.Value.Add(contractDetails);
        else
#endif
          OnContractDetails(reqId, contractDetails);
#if NET_4_5
      } catch (Exception e) {
        if (completion != null)
          completion.SetException(e);
        throw;
      }
#endif
    }
Пример #6
0
    private void ProcessBondContractData()
    {
      var version = _enc.DecodeInt();
      var reqId = version >= 3 ? _enc.DecodeInt() : -1;

      var contract = new IBContractDetails {
        Summary = {
          Symbol = _enc.DecodeString(),
          SecurityType = _enc.DecodeEnum<IBSecurityType>(),
          Cusip = _enc.DecodeString(),
          Coupon = _enc.DecodeDouble(),
          Maturity = _enc.DecodeString(),
          IssueDate = _enc.DecodeString(),
          Ratings = _enc.DecodeString(),
          BondType = _enc.DecodeString(),
          CouponType = _enc.DecodeString(),
          Convertible = _enc.DecodeBool(),
          Callable = _enc.DecodeBool(),
          Putable = _enc.DecodeBool(),
          DescAppend = _enc.DecodeString(),
          Exchange = _enc.DecodeString(),
          Currency = _enc.DecodeString()
        },
        MarketName = _enc.DecodeString(),
        TradingClass = _enc.DecodeString(),
        ContractId = _enc.DecodeInt(),
        MinTick = _enc.DecodeDouble(),
        OrderTypes = _enc.DecodeString(),
        ValidExchanges = _enc.DecodeString()
      };

      if (version >= 2) {
        contract.Summary.NextOptionDate = _enc.DecodeString();
        contract.Summary.NextOptionType = _enc.DecodeString();
        contract.Summary.NextOptionPartial = _enc.DecodeBool();
        contract.Summary.Notes = _enc.DecodeString();
      }

      if (version >= 4)
        contract.LongName = _enc.DecodeString();

      if (version >= 6) {
        contract.EvRule = _enc.DecodeString();
        contract.EvMultiplier = _enc.DecodeDouble();
      }
      if (version >= 5) {
        var secIdListCount = _enc.DecodeInt();
        if (secIdListCount > 0) {
          contract.SecIdList = new List<IBTagValue>(secIdListCount);
          for (var i = 0; i < secIdListCount; ++i)
            contract.SecIdList.Add(new IBTagValue {
                Tag = _enc.DecodeString(),
                Value = _enc.DecodeString(),
              });
          }
      }
      OnBondContractDetails(reqId, contract);
    }
Пример #7
0
 public TWSContractDetailsEventArgs(TWSClient client, IBContractDetails contractDetails) : base(client)
 {
     ContractDetails = contractDetails;
 }
Пример #8
0
 public TWSContractDetailsEventArgs(TWSClient client, IBContractDetails contractDetails)
     : base(client)
 {
     ContractDetails = contractDetails;
 }
Пример #9
0
 private void ProcessScannerData()
 {
     IBContractDetails contract = new IBContractDetails();
     int version = _enc.DecodeInt();
     int reqId = _enc.DecodeInt();
     int numberOfElements = _enc.DecodeInt();
     for (int i = 0; i < numberOfElements; i++) {
         int rank = _enc.DecodeInt();
         contract.Summary.Symbol = _enc.DecodeString();
         contract.Summary.SecType = _enc.DecodeSecType();
         contract.Summary.Expiry = DateTime.ParseExact(_enc.DecodeString(), IB_EXPIRY_DATE_FORMAT, CultureInfo.InvariantCulture);
         contract.Summary.Strike = _enc.DecodeDouble();
         contract.Summary.Right = _enc.DecodeString();
         contract.Summary.Exchange = _enc.DecodeString();
         contract.Summary.Currency = _enc.DecodeString();
         contract.Summary.LocalSymbol = _enc.DecodeString();
         contract.MarketName = _enc.DecodeString();
         contract.TradingClass = _enc.DecodeString();
         string distance = _enc.DecodeString();
         string benchmark = _enc.DecodeString();
         string projection = _enc.DecodeString();
         //_ibtws.OnScannerData(reqId, rank, contract, distance, benchmark, projection);
     }
 }
Пример #10
0
 private void ProcessContractData()
 {
     int version = _enc.DecodeInt();
     IBContractDetails contractDetails = new IBContractDetails();
     contractDetails.Summary.Symbol = _enc.DecodeString();
     contractDetails.Summary.SecType = _enc.DecodeSecType();
     contractDetails.Summary.Expiry = DateTime.ParseExact(_enc.DecodeString(), IB_EXPIRY_DATE_FORMAT, CultureInfo.InvariantCulture);
     contractDetails.Summary.Strike = _enc.DecodeDouble();
     contractDetails.Summary.Right = _enc.DecodeString();
     contractDetails.Summary.Exchange = _enc.DecodeString();
     contractDetails.Summary.Currency = _enc.DecodeString();
     contractDetails.Summary.LocalSymbol = _enc.DecodeString();
     contractDetails.MarketName = _enc.DecodeString();
     contractDetails.TradingClass = _enc.DecodeString();
     contractDetails.Conid = _enc.DecodeInt();
     contractDetails.MinTick = _enc.DecodeDouble();
     contractDetails.Multiplier = _enc.DecodeString();
     contractDetails.OrderTypes = _enc.DecodeString();
     contractDetails.ValidExchanges = _enc.DecodeString();
     if (version >= 2)
         contractDetails.PriceMagnifier = _enc.DecodeInt();
     OnContractDetails(contractDetails);
 }
Пример #11
0
        private void ProcessBondContractData()
        {
            int version = _enc.DecodeInt();
            IBContractDetails contract = new IBContractDetails();

            contract.Summary.Symbol = _enc.DecodeString();
            contract.Summary.SecType = _enc.DecodeSecType();
            contract.Summary.Cusip = _enc.DecodeString();
            contract.Summary.Coupon = _enc.DecodeDouble();
            contract.Summary.Maturity = _enc.DecodeString();
            contract.Summary.IssueDate = _enc.DecodeString();
            contract.Summary.Ratings = _enc.DecodeString();
            contract.Summary.BondType = _enc.DecodeString();
            contract.Summary.CouponType = _enc.DecodeString();
            contract.Summary.Convertible = _enc.DecodeBool();
            contract.Summary.Callable = _enc.DecodeBool();
            contract.Summary.Putable = _enc.DecodeBool();
            contract.Summary.DescAppend = _enc.DecodeString();
            contract.Summary.Exchange = _enc.DecodeString();
            contract.Summary.Currency = _enc.DecodeString();
            contract.MarketName = _enc.DecodeString();
            contract.TradingClass = _enc.DecodeString();
            contract.Conid = _enc.DecodeInt();
            contract.MinTick = _enc.DecodeDouble();
            contract.OrderTypes = _enc.DecodeString();
            contract.ValidExchanges = _enc.DecodeString();

            if (version >= 2) {
                contract.Summary.NextOptionDate = _enc.DecodeString();
                contract.Summary.NextOptionType = _enc.DecodeString();
                contract.Summary.NextOptionPartial = _enc.DecodeBool();
                contract.Summary.Notes = _enc.DecodeString();
            }
            OnBondContractDetails(contract);
        }
Пример #12
0
 protected void OnScannerData(int reqId, int rank, IBContractDetails contract, 
     string distance, string benchmark, string projection)
 {
 }
Пример #13
0
 protected void OnContractDetails(IBContractDetails contract)
 {
     if (ContractDetails != null)
         ContractDetails(this, new TWSContractDetailsEventArgs(this, contract));
 }