Example #1
0
        public void GetContractDetails(ContractDetails contractdetails)
        {
            ConcurrentContract<Contract> tmpContract = new ConcurrentContract<Contract>(contractdetails.Summary);
            _contractCOL.AddOrUpdate(contractdetails.Summary.ConId, tmpContract, (key, oldValue) => oldValue);
            if (contractdetails.Summary.SecType == SecTypRef.GetType(SecTypRef.OPT))
            {
                if (contractdetails.Summary.Right == SecRightRef.C || contractdetails.Summary.Right == SecRightRef.CALL)
                {
                    _repo.RequestMktData(this, contractdetails.Summary.ConId, contractdetails.Summary, "", false);
                    _priceCOL.AddOrUpdate(
                        contractdetails.Summary.Strike,
                        (key) => new BoxEntry() { CallContract = tmpContract },
                        (key, oldEntry) =>
                        {
                            oldEntry.CallContract = tmpContract; return oldEntry;
                        });
                }
                else
                {
                    _repo.RequestMktData(this, contractdetails.Summary.ConId, contractdetails.Summary, "", false);
                    _priceCOL.AddOrUpdate(
                        contractdetails.Summary.Strike,
                        (key) => new BoxEntry() { PutContract = tmpContract },
                        (key, oldEntry) =>
                        {
                            oldEntry.PutContract = tmpContract; return oldEntry;
                        });
                }
            }

            if (contractdetails.Summary.SecType == SecTypRef.GetType(SecTypRef.STK))
            {
                UdlyContract = contractdetails;
            }
        }
Example #2
0
        //! [openorderend]

        //! [contractdetails]
        public virtual void contractDetails(int reqId, ContractDetails contractDetails)
        {
            Console.WriteLine("ContractDetails begin. ReqId: " + reqId);
            //  printContractMsg(contractDetails.Contract);
            //   printContractDetailsMsg(contractDetails);
            contract_ID = contractDetails.Contract.ConId;
            // Console.WriteLine("ContractDetails end. ReqId: " + reqId);
        }
        public ContractDetailsMesage(int reqId, ContractDetails cd)
        {
            this.MessageType = MessageType.ContractDetails;
            this.DateTime = DateTime.Now;
            RequestId = reqId;
            ContractDetails = cd;

        }
Example #4
0
 public override void contractDetails(int reqId, ContractDetails contractDetails)
 {
     Console.WriteLine("/*******Incoming Contract Details - RequestId "+reqId+"************/");
     Console.WriteLine(contractDetails.Summary.Symbol + " " + contractDetails.Summary.SecType + " @ " + contractDetails.Summary.Exchange);
     Console.WriteLine("Expiry: " + contractDetails.Summary.Expiry + ", Right: " + contractDetails.Summary.Right);
     Console.WriteLine("Strike: " + contractDetails.Summary.Strike + ", Multiplier: " + contractDetails.Summary.Multiplier);
     Console.WriteLine("/*******     End     *************/\n");
 }
Example #5
0
 public double MinTick()
 {
     return(ContractDetails.FromCache(this)
            .Select(cd => cd.MinTick)
            .Where(mt => mt > 0)
            .IfEmpty(() => Legs().SelectMany(c => ContractDetails.FromCache(c.c)).MaxByOrEmpty(cd => cd.MinTick).Select(cd => cd.MinTick).Take(1))
            .Count(1, _ => Debugger.Break(), _ => Debugger.Break())
            .DefaultIfEmpty(0.01)
            .Single());
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ScannerDataEventArgs"/> class
 /// </summary>
 public ScannerDataEventArgs(int reqId, int rank, ContractDetails contractDetails, string distance, string benchmark, string projection, string legsStr)
 {
     RequestId = reqId;
     Rank = rank;
     ContractDetails = contractDetails;
     Distance = distance;
     Benchmark = benchmark;
     Projection = projection;
     LegsStr = legsStr;
 }
 public ScannerMessage(int reqId, int rank, ContractDetails contractDetails, string distance, string benchmark, string projection, string legsStr)
 {
     Type = MessageType.ScannerData;
     RequestId = reqId;
     Rank = rank;
     ContractDetails = contractDetails;
     Distance = distance;
     Benchmark = benchmark;
     Projection = projection;
     LegsStr = legsStr;
 }
        public void ProcessContractDetails(ContractDetails cd)
        {

            Contract c = new Contract();
            var i = cd.Coupon;
            var j = c.GetHashCode();










        }
        public void ProcessContractDetails(int requestId, ContractDetails contractDetails)
        {
            var selectedInstrument = ActiveContracts.Find(x => x.Id == requestId);

            //if (selectedInstrument != null)
            //{
            //    if (selectedInstrument.IBContractDetails. != null)
            //        selectedInstrument.IBContractDetails = contractDetails;
            //    else
            //    {
            //        selectedInstrument.IBContractDetails = new ContractDetails();
            //        selectedInstrument.IBContractDetails = contractDetails;
            //    }
            //}



        }
Example #10
0
        private void ScannerDataEvent()
        {
            ContractDetails conDet           = new ContractDetails();
            int             msgVersion       = ReadInt();
            int             requestId        = ReadInt();
            int             numberOfElements = ReadInt();

            for (int i = 0; i < numberOfElements; i++)
            {
                int rank = ReadInt();
                if (msgVersion >= 3)
                {
                    conDet.Summary.ConId = ReadInt();
                }
                conDet.Summary.Symbol       = ReadString();
                conDet.Summary.SecType      = ReadString();
                conDet.Summary.Expiry       = ReadString();
                conDet.Summary.Strike       = ReadDouble();
                conDet.Summary.Right        = ReadString();
                conDet.Summary.Exchange     = ReadString();
                conDet.Summary.Currency     = ReadString();
                conDet.Summary.LocalSymbol  = ReadString();
                conDet.MarketName           = ReadString();
                conDet.Summary.TradingClass = ReadString();
                string distance   = ReadString();
                string benchmark  = ReadString();
                string projection = ReadString();
                string legsStr    = null;
                if (msgVersion >= 2)
                {
                    legsStr = ReadString();
                }
                parent.Wrapper.scannerData(requestId, rank, conDet, distance,
                                           benchmark, projection, legsStr);
            }
            parent.Wrapper.scannerDataEnd(requestId);
        }
Example #11
0
 public void printBondContractDetailsMsg(ContractDetails contractDetails)
 {
     Console.WriteLine("\tSymbol: " + contractDetails.Contract.Symbol);
     Console.WriteLine("\tSecType: " + contractDetails.Contract.SecType);
     Console.WriteLine("\tCusip: " + contractDetails.Cusip);
     Console.WriteLine("\tCoupon: " + contractDetails.Coupon);
     Console.WriteLine("\tMaturity: " + contractDetails.Maturity);
     Console.WriteLine("\tIssueDate: " + contractDetails.IssueDate);
     Console.WriteLine("\tRatings: " + contractDetails.Ratings);
     Console.WriteLine("\tBondType: " + contractDetails.BondType);
     Console.WriteLine("\tCouponType: " + contractDetails.CouponType);
     Console.WriteLine("\tConvertible: " + contractDetails.Convertible);
     Console.WriteLine("\tCallable: " + contractDetails.Callable);
     Console.WriteLine("\tPutable: " + contractDetails.Putable);
     Console.WriteLine("\tDescAppend: " + contractDetails.DescAppend);
     Console.WriteLine("\tExchange: " + contractDetails.Contract.Exchange);
     Console.WriteLine("\tCurrency: " + contractDetails.Contract.Currency);
     Console.WriteLine("\tMarketName: " + contractDetails.MarketName);
     Console.WriteLine("\tTradingClass: " + contractDetails.Contract.TradingClass);
     Console.WriteLine("\tConId: " + contractDetails.Contract.ConId);
     Console.WriteLine("\tMinTick: " + contractDetails.MinTick);
     Console.WriteLine("\tMdSizeMultiplier: " + contractDetails.MdSizeMultiplier);
     Console.WriteLine("\tOrderTypes: " + contractDetails.OrderTypes);
     Console.WriteLine("\tValidExchanges: " + contractDetails.ValidExchanges);
     Console.WriteLine("\tNextOptionDate: " + contractDetails.NextOptionDate);
     Console.WriteLine("\tNextOptionType: " + contractDetails.NextOptionType);
     Console.WriteLine("\tNextOptionPartial: " + contractDetails.NextOptionPartial);
     Console.WriteLine("\tNotes: " + contractDetails.Notes);
     Console.WriteLine("\tLong Name: " + contractDetails.LongName);
     Console.WriteLine("\tEvRule: " + contractDetails.EvRule);
     Console.WriteLine("\tEvMultiplier: " + contractDetails.EvMultiplier);
     Console.WriteLine("\tAggGroup: " + contractDetails.AggGroup);
     Console.WriteLine("\tMarketRuleIds: " + contractDetails.MarketRuleIds);
     Console.WriteLine("\tLastTradeTime: " + contractDetails.LastTradeTime);
     Console.WriteLine("\tTimeZoneId: " + contractDetails.TimeZoneId);
     printContractDetailsSecIdList(contractDetails.SecIdList);
 }
Example #12
0
 public virtual void bondContractDetails(int requestId, ContractDetails contractDetails)
 {
     addTextToBox("Receiving bond contract details.");
 }
Example #13
0
 public virtual void scannerData(int reqId, int rank, ContractDetails contractDetails, string distance, string benchmark, string projection, string legsStr)
 {
     parentUI.HandleMessage(new ScannerMessage(reqId, rank, contractDetails, distance, benchmark, projection, legsStr));
 }
Example #14
0
 public virtual void contractDetails(int reqId, ContractDetails contractDetails)
 {
     parentUI.HandleMessage(new ContractDetailsMessage(reqId, contractDetails));
 }
Example #15
0
        private void BondContractDetailsEvent()
        {
            int msgVersion = ReadInt();
            int requestId = -1;
            if (msgVersion >= 3)
            {
                requestId = ReadInt();
            }

            ContractDetails contract = new ContractDetails();

            contract.Summary.Symbol = ReadString();
            contract.Summary.SecType = ReadString();
            contract.Cusip = ReadString();
            contract.Coupon = ReadDouble();
            contract.Maturity = ReadString();
            contract.IssueDate = ReadString();
            contract.Ratings = ReadString();
            contract.BondType = ReadString();
            contract.CouponType = ReadString();
            contract.Convertible = ReadBoolFromInt();
            contract.Callable = ReadBoolFromInt();
            contract.Putable = ReadBoolFromInt();
            contract.DescAppend = ReadString();
            contract.Summary.Exchange = ReadString();
            contract.Summary.Currency = ReadString();
            contract.MarketName = ReadString();
            contract.Summary.TradingClass = ReadString();
            contract.Summary.ConId = ReadInt();
            contract.MinTick = ReadDouble();
            contract.OrderTypes = ReadString();
            contract.ValidExchanges = ReadString();
            if (msgVersion >= 2)
            {
                contract.NextOptionDate = ReadString();
                contract.NextOptionType = ReadString();
                contract.NextOptionPartial = ReadBoolFromInt();
                contract.Notes = ReadString();
            }
            if (msgVersion >= 4)
            {
                contract.LongName = ReadString();
            }
            if (msgVersion >= 6)
            {
                contract.EvRule = ReadString();
                contract.EvMultiplier = ReadDouble();
            }
            if (msgVersion >= 5)
            {
                int secIdListCount = ReadInt();
                if (secIdListCount > 0)
                {
                    contract.SecIdList = new List<TagValue>();
                    for (int i = 0; i < secIdListCount; ++i)
                    {
                        TagValue tagValue = new TagValue();
                        tagValue.Tag = ReadString();
                        tagValue.Value = ReadString();
                        contract.SecIdList.Add(tagValue);
                    }
                }
            }
            eWrapper.bondContractDetails(requestId, contract);
        }
 /// <summary>
 /// Returns all contracts matching the requested parameters in reqContractDetails(). For example, you can receive an entire option chain.
 /// </summary>
 /// <param name="reqId">The ID of the data request. Ensures that responses are matched to requests if several requests are in process.</param>
 /// <param name="contractDetails">This structure contains a full description of the contract being looked up.</param>
 public void contractDetails(int reqId, ContractDetails contractDetails)
 {
     OnContractDetails(new ContractDetailsEventArgs(reqId, contractDetails));
 }
Example #17
0
        private void ContractDataEvent()
        {
            int msgVersion = ReadInt();
            int requestId  = -1;

            if (msgVersion >= 3)
            {
                requestId = ReadInt();
            }
            ContractDetails contract = new ContractDetails();

            contract.Summary.Symbol       = ReadString();
            contract.Summary.SecType      = ReadString();
            contract.Summary.Expiry       = ReadString();
            contract.Summary.Strike       = ReadDouble();
            contract.Summary.Right        = ReadString();
            contract.Summary.Exchange     = ReadString();
            contract.Summary.Currency     = ReadString();
            contract.Summary.LocalSymbol  = ReadString();
            contract.MarketName           = ReadString();
            contract.Summary.TradingClass = ReadString();
            contract.Summary.ConId        = ReadInt();
            contract.MinTick            = ReadDouble();
            contract.Summary.Multiplier = ReadString();
            contract.OrderTypes         = ReadString();
            contract.ValidExchanges     = ReadString();
            if (msgVersion >= 2)
            {
                contract.PriceMagnifier = ReadInt();
            }
            if (msgVersion >= 4)
            {
                contract.UnderConId = ReadInt();
            }
            if (msgVersion >= 5)
            {
                contract.LongName            = ReadString();
                contract.Summary.PrimaryExch = ReadString();
            }
            if (msgVersion >= 6)
            {
                contract.ContractMonth = ReadString();
                contract.Industry      = ReadString();
                contract.Category      = ReadString();
                contract.Subcategory   = ReadString();
                contract.TimeZoneId    = ReadString();
                contract.TradingHours  = ReadString();
                contract.LiquidHours   = ReadString();
            }
            if (msgVersion >= 8)
            {
                contract.EvRule       = ReadString();
                contract.EvMultiplier = ReadDouble();
            }
            if (msgVersion >= 7)
            {
                int secIdListCount = ReadInt();
                if (secIdListCount > 0)
                {
                    contract.SecIdList = new List <TagValue>(secIdListCount);
                    for (int i = 0; i < secIdListCount; ++i)
                    {
                        TagValue tagValue = new TagValue();
                        tagValue.tag   = ReadString();
                        tagValue.value = ReadString();
                        contract.SecIdList.Add(tagValue);
                    }
                }
            }

            parent.Wrapper.contractDetails(requestId, contract);
        }
Example #18
0
        private void ContractDataEvent()
        {
            int msgVersion = ReadInt();
            int requestId = -1;
            if (msgVersion >= 3)
                requestId = ReadInt();
            ContractDetails contract = new ContractDetails();
            contract.Summary.Symbol = ReadString();
            contract.Summary.SecType = ReadString();
            contract.Summary.Expiry = ReadString();
            contract.Summary.Strike = ReadDouble();
            contract.Summary.Right = ReadString();
            contract.Summary.Exchange = ReadString();
            contract.Summary.Currency = ReadString();
            contract.Summary.LocalSymbol = ReadString();
            contract.MarketName = ReadString();
            contract.Summary.TradingClass = ReadString();
            contract.Summary.ConId = ReadInt();
            contract.MinTick = ReadDouble();
            contract.Summary.Multiplier = ReadString();
            contract.OrderTypes = ReadString();
            contract.ValidExchanges = ReadString();
            if (msgVersion >= 2)
            {
                contract.PriceMagnifier = ReadInt();
            }
            if (msgVersion >= 4)
            {
                contract.UnderConId = ReadInt();
            }
            if (msgVersion >= 5)
            {
                contract.LongName = ReadString();
                contract.Summary.PrimaryExch = ReadString();
            }
            if (msgVersion >= 6)
            {
                contract.ContractMonth = ReadString();
                contract.Industry = ReadString();
                contract.Category = ReadString();
                contract.Subcategory = ReadString();
                contract.TimeZoneId = ReadString();
                contract.TradingHours = ReadString();
                contract.LiquidHours = ReadString();
            }
            if (msgVersion >= 8)
            {
                contract.EvRule = ReadString();
                contract.EvMultiplier = ReadDouble();
            }
            if (msgVersion >= 7)
            {
                int secIdListCount = ReadInt();
                if (secIdListCount > 0)
                {
                    contract.SecIdList = new List<TagValue>(secIdListCount);
                    for (int i = 0; i < secIdListCount; ++i)
                    {
                        TagValue tagValue = new TagValue();
                        tagValue.tag = ReadString();
                        tagValue.value = ReadString();
                        contract.SecIdList.Add(tagValue);
                    }
                }
            }

            parent.Wrapper.contractDetails(requestId, contract);
        }
Example #19
0
 public virtual void contractDetails(int reqId, ContractDetails contractDetails)
 {
 }
Example #20
0
 public void scannerData(int reqId, int rank, ContractDetails contractDetails, string distance, string benchmark,
     string projection, string legsStr)
 {
     throw new NotImplementedException();
 }
        // This function receives the requested market scanner data results.
        public virtual void scannerData(int reqId, int rank, ContractDetails contractDetails, string distance, string benchmark, string projection, string legsStr)
        {
            String str;
            str = "scanner data @ " + DateTime.Now.ToShortTimeString();

            AddTextToResponseListWindow(str);
        }
        // This function is called only when reqContractDetails function on the EClientSocket object has been called for bonds.
        /* 
        void ibClient_bondContractDetails(int reqId, ContractDetails contract)
        {
            String str;
            str = "Bond Contract Details @ " + DateTime.Now.ToShortTimeString()
                + " long name = " + contract.LongName
                + " cusip = " + contract.Cusip
                + " id = " + contract.Summary.ContractId
                + " symbol = " + contract.Summary.Symbol;

            AddTextToResponseListWindow(str);
        }
        */
        public virtual void bondContractDetails(int reqId, ContractDetails contract)
        {
            String str;
            str = "Bond Contract Details @ " + DateTime.Now.ToShortTimeString()
                + " long name = " + contract.LongName
                + " cusip = " + contract.Cusip
                + " id = " + contract.Summary.ConId
                + " symbol = " + contract.Summary.Symbol;

            AddTextToResponseListWindow(str);
        }
        // triggered by reqContractDetails()
        public virtual void contractDetails(int reqId, ContractDetails contractDetails)
        {
            String str;
            str = "Contract Details @ " + DateTime.Now.ToShortTimeString()
                + " long name = " + contractDetails.LongName
                + " cusip = " + contractDetails.Cusip
                + " id = " + contractDetails.Summary.ConId
                + " symbol = " + contractDetails.Summary.Symbol
                + " multiplier = " + contractDetails.Summary.Multiplier ;

            AddTextToResponseListWindow(str);
        }
 /// <summary>
 /// This method receives the requested market scanner data results.
 /// </summary>
 /// <param name="reqId">The request's identifier.</param>
 /// <param name="rank">The ranking within the response of this bar.</param>
 /// <param name="contractDetails">This structure contains a full description of the contract that was executed.</param>
 /// <param name="distance">Varies based on query.</param>
 /// <param name="benchmark">Varies based on query.</param>
 /// <param name="projection">Varies based on query.</param>
 /// <param name="legsStr">Describes combo legs when scan is returning EFP.</param>
 public void scannerData(int reqId, int rank, ContractDetails contractDetails, string distance, string benchmark, string projection, string legsStr)
 {
     OnScannerData(new ScannerDataEventArgs(reqId, rank, contractDetails, distance, benchmark, projection, legsStr));
 }
Example #25
0
 public virtual void bondContractDetails(int reqId, ContractDetails contract)
 {
 }
Example #26
0
 private void ScannerDataEvent()
 {
     ContractDetails conDet = new ContractDetails();
     int msgVersion = ReadInt();
     int requestId = ReadInt();
     int numberOfElements = ReadInt();
     for (int i = 0; i < numberOfElements; i++)
     {
         int rank = ReadInt();
         if (msgVersion >= 3)
             conDet.Summary.ConId = ReadInt();
         conDet.Summary.Symbol = ReadString();
         conDet.Summary.SecType = ReadString();
         conDet.Summary.Expiry = ReadString();
         conDet.Summary.Strike = ReadDouble();
         conDet.Summary.Right = ReadString();
         conDet.Summary.Exchange = ReadString();
         conDet.Summary.Currency = ReadString();
         conDet.Summary.LocalSymbol = ReadString();
         conDet.MarketName = ReadString();
         conDet.Summary.TradingClass = ReadString();
         string distance = ReadString();
         string benchmark = ReadString();
         string projection = ReadString();
         string legsStr = null;
         if (msgVersion >= 2)
         {
             legsStr = ReadString();
         }
         parent.Wrapper.scannerData(requestId, rank, conDet, distance,
             benchmark, projection, legsStr);
     }
     parent.Wrapper.scannerDataEnd(requestId);
 }
Example #27
0
 public void bondContractDetails(int reqId, ContractDetails contract)
 {
     throw new NotImplementedException();
 }
Example #28
0
 public IEnumerable <ContractDetails> FromDetailsCache() => ContractDetails.FromCache(this);
Example #29
0
        //! [receivefa]

        public virtual void bondContractDetails(int requestId, ContractDetails contractDetails)
        {
            Console.WriteLine("BondContractDetails begin. ReqId: " + requestId);
            printBondContractDetailsMsg(contractDetails);
            Console.WriteLine("BondContractDetails end. ReqId: " + requestId);
        }
Example #30
0
 public virtual void scannerData(int reqId, int rank, ContractDetails contractDetails, string distance, string benchmark, string projection, string legsStr)
 {
     Console.WriteLine("ScannerData. " + reqId + " - Rank: " + rank + ", Symbol: " + contractDetails.Summary.Symbol + ", SecType: " + contractDetails.Summary.SecType + ", Currency: " + contractDetails.Summary.Currency
         + ", Distance: " + distance + ", Benchmark: " + benchmark + ", Projection: " + projection + ", Legs String: " + legsStr);
 }
 /// <summary>
 /// Sends bond contract data when the reqContractDetails() method has been called for bonds.
 /// </summary>
 /// <param name="reqId">The ID of the data request.</param>
 /// <param name="contract">This structure contains a full description of the bond contract being looked up.</param>
 public void bondContractDetails(int reqId, ContractDetails contract)
 {
     OnBondContractDetails(new ContractDetailsEventArgs(reqId, contract));
 }
Example #32
0
        public void contractDetails(int reqId, ContractDetails contractDetails)
        {

         MessageHandler.messageBox.Enqueue(new ContractDetailsMesage{ContractDetails = contractDetails,DateTime = DateTime.Now,RequestId = reqId, MessageType = MessageType.ContractDetails});  
        
        }
Example #33
0
        //! [scannerparameters]

        //! [scannerdata]
        public virtual void scannerData(int reqId, int rank, ContractDetails contractDetails, string distance, string benchmark, string projection, string legsStr)
        {
            Console.WriteLine("ScannerData. " + reqId + " - Rank: " + rank + ", Symbol: " + contractDetails.Contract.Symbol + ", SecType: " + contractDetails.Contract.SecType + ", Currency: " + contractDetails.Contract.Currency
                              + ", Distance: " + distance + ", Benchmark: " + benchmark + ", Projection: " + projection + ", Legs String: " + legsStr);
        }
 public ContractDetailsMessage(int requestId, ContractDetails contractDetails)
 {
     Type = MessageType.ContractData;
     RequestId = requestId;
     ContractDetails = contractDetails;
 }
Example #35
0
 public virtual void contractDetails(int reqId, ContractDetails contractDetails) { }
Example #36
0
 public virtual void scannerData(int reqId, int rank, ContractDetails contractDetails, string distance, string benchmark, string projection, string legsStr)
 {
 }
Example #37
0
 public virtual void scannerData(int reqId, int rank, ContractDetails contractDetails, string distance, string benchmark, string projection, string legsStr) { }
Example #38
0
 public virtual void contractDetails(int reqId, ContractDetails contractDetails)
 {
     Console.WriteLine("ContractDetails. ReqId: " + reqId + " - " + contractDetails.Summary.Symbol + ", " + contractDetails.Summary.SecType + ", ConId: " + contractDetails.Summary.ConId + " @ " + contractDetails.Summary.Exchange);
 }
Example #39
0
 public virtual void bondContractDetails(int reqId, ContractDetails contract) { }
Example #40
0
 public virtual void bondContractDetails(int requestId, ContractDetails contractDetails)
 {
     Console.WriteLine("Bond. Symbol " + contractDetails.Summary.Symbol + ", " + contractDetails.Summary);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ContractDetailsEventArgs"/> class
 /// </summary>
 public ContractDetailsEventArgs(int requestId, ContractDetails contractDetails)
 {
     RequestId = requestId;
     ContractDetails = contractDetails;
 }