Ejemplo n.º 1
0
        // For a specific strike and maturity, we use the option(call or put) which is out of the money
        // this methode is in charge to retreive the current option ric out of the money
        private double GetOutTheMoneyOptionPrice(Instrument pos, string optionType)
        {
            // build option tt code
            string targetOptionTtCode = Option.GetOptionTtCode(pos.ProductId, optionType, pos.MaturityDate, pos.Strike.Value);
            // get or suscribe option price
            double targetOptionPrice;

            if (!_instrumentPriceSafeDico.TryGetValue(targetOptionTtCode, out targetOptionPrice))
            {
                _marketFeed.SuscribeToInstrumentPrice(targetOptionTtCode, pos.Product.ProductType, pos.ProductId, pos.Product.Market, "Mid");
                _instrumentPriceSafeDico.TryAdd(targetOptionTtCode, 0);
            }

            return(targetOptionPrice);
        }
Ejemplo n.º 2
0
        private void SuscribeToInstrumentPrices()
        {
            foreach (var instru in _instruInfoDico.Values)
            {
                string instruType = "";
                if (instru.ProductId == "FESX")
                {
                    instruType = "FUTURE";
                }
                else if (instru.ProductId == "OESX")
                {
                    instruType = "OPTION";
                }
                else
                {
                    continue;
                }

                _marketFeed.SuscribeToInstrumentPrice(instru.TtCode, instruType, instru.ProductId, "Eurex", "Mid");
                _instrumentPriceSafeDico.TryAdd(instru.TtCode, 0);

                if (!string.IsNullOrEmpty(instru.RefForwardId) && !_instrumentPriceSafeDico.ContainsKey(instru.RefForwardId))
                {
                    if (instru.MaturityDate >= DateTime.Today)
                    {
                        DateTime previousDay       = Option.PreviousWeekDay(DateTime.Today);
                        double   futureClose       = _dbManager.GetSpotClose(previousDay, instru.RefFutureId);
                        double   forwardClose      = Option.GetForwardClose(instru.RefForwardId, instru.MaturityDate, futureClose);
                        double   forwardBaseOffset = forwardClose - futureClose;
                        _fwdBaseOffsetDico.Add(instru.RefForwardId, forwardBaseOffset);
                        _instrumentPriceSafeDico.TryAdd(instru.RefForwardId, 0);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void ConnectionStatusHandler(IMarketFeed sender, string connectionState)
        {
            if (connectionState == "Connection_Down")
            {
                IsRunning = false;
            }
            else if (connectionState == "Connection_Succeed")
            {
                _delay            = DateTime.Now.AddSeconds(_delayTime);
                _instruCollection = _dbManager.GetAllInstruments(Option.PreviousWeekDay(DateTime.Today));

                foreach (var instru in _instruCollection)
                {
                    _marketFeed.SuscribeToInstrumentPrice(instru.TtCode, instru.Product.ProductType, instru.ProductId, instru.Product.Market, "Close");
                }
            }
        }