Пример #1
0
        private DateTime getClose(QuickFix44.MarketDataSnapshotFullRefresh mds)
        {
            DateTime close = new DateTime(0L);

            try
            {
                DateTime last = new DateTime(0L);
                QuickFix44.MarketDataSnapshotFullRefresh.NoMDEntries group = new QuickFix44.MarketDataSnapshotFullRefresh.NoMDEntries();
                for (uint i = 1; i < mds.getNoMDEntries().getValue(); i++)
                {
                    group = (QuickFix44.MarketDataSnapshotFullRefresh.NoMDEntries)mds.getGroup(i, group);
                    if (group.getMDEntryTime().getValue() != null)
                    {
                        last  = new DateTime(group.getMDEntryDate().getValue().Ticks + group.getMDEntryTime().getValue().Ticks);
                        close = ((close.Ticks > last.Ticks) ? close : last);
                    }
                }
            }
            catch (Exception e) { }
            return(TimeZoneInfo.ConvertTime(close, TimeZoneInfo.Utc, TimeZoneInfo.Local));
        }
Пример #2
0
        public override void onMessage(QuickFix44.MarketDataSnapshotFullRefresh message, SessionID session)
        {
            // getting attributes

            Symbol      symbol      = message.getSymbol();
            SendingTime sendingTime = new SendingTime(message.getHeader().getUtcTimeStamp(SendingTime.FIELD));
            NoMDEntries noMDEntries = message.getNoMDEntries();

            decimal ask     = 0m;
            decimal bid     = 0m;
            decimal askSize = 0m;
            decimal bidSize = 0m;

            for (int i = 0; i < noMDEntries.getValue(); i++)
            {
                QuickFix44.MarketDataSnapshotFullRefresh.NoMDEntries group = new QuickFix44.MarketDataSnapshotFullRefresh.NoMDEntries();
                message.getGroup((uint)i + 1, group);
                MDEntryType mdEntryType = group.getMDEntryType();
                MDEntryPx   mdEntryPx   = group.getMDEntryPx();
                MDEntrySize mdEntrySize = group.getMDEntrySize();

                if (mdEntryType.getValue() == MDEntryType.BID)
                {
                    bid     = (decimal)mdEntryPx.getValue();
                    bidSize = (decimal)mdEntrySize.getValue();
                }
                else if (mdEntryType.getValue() == MDEntryType.OFFER)
                {
                    ask     = (decimal)mdEntryPx.getValue();
                    askSize = (decimal)mdEntrySize.getValue();
                }
            }

            // firing event

            Console.WriteLine("QuickFix44.MarketDataSnapshotFullRefresh: {0}, {1}/{2}, {3}/{4}, {5}", symbol, ask, bid, askSize, bidSize, sendingTime);

            this.fixServices.NotifyQuote(Counterpart.Dukascopy, symbol.getValue(), ask, askSize, bid, bidSize, sendingTime.getValue());
        }
Пример #3
0
        private double getPrice(QuickFix44.MarketDataSnapshotFullRefresh mds, String p, double previous)
        {
            double price = previous;

            try
            {
                // grab the market data entries from the snapshot
                QuickFix44.MarketDataSnapshotFullRefresh.NoMDEntries group = new QuickFix44.MarketDataSnapshotFullRefresh.NoMDEntries();
                // go through the entries
                for (uint i = 1; i <= mds.getNoMDEntries().getValue(); i++)
                {
                    group = (QuickFix44.MarketDataSnapshotFullRefresh.NoMDEntries)mds.getGroup(i, group);
                    //if the entry type is the price requested, set the price to the value of the entry price
                    if (group.getMDEntryType().getValue().Equals(p[0]))
                    {
                        price = group.getMDEntryPx().getValue();
                    }
                }
            }
            catch (Exception e) { } // ignore errors
            return(price); // if not found, return the previous rate
        }