示例#1
0
 /**
  * Process market data snapshots, taking from each message the instrument update and adding to the
  * internal map
  */
 public override void onMessage(QuickFix44.MarketDataSnapshotFullRefresh snapshot, QuickFix.SessionID session)
 {
     // fire an event that an instrument has updated
     if (this.messageRecieved != null && !exampleRunning)
     {
         this.messageRecieved(snapshot);
     }
 }
示例#2
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));
        }
示例#3
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());
        }
示例#4
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
        }
示例#5
0
        public void update(QuickFix44.MarketDataSnapshotFullRefresh snapshot)
        {
            if (grdRates.InvokeRequired)
            {
                updateCallback d = new updateCallback(update);
                this.Invoke(d, new object[] { snapshot });
            }
            else
            {
                QuickFix.Symbol instrument = snapshot.getSymbol();
                double          minQty     = 0D;

                // if the currency is already in the DataGridView
                if (map.ContainsKey(instrument))
                {
                    // update only the cells of the row that have changed
                    DataGridViewRow row = grdRates.Rows[map[instrument]];
                    row.Cells["Updated"].Value     = getClose(snapshot);
                    row.Cells["Bid"].Value         = getPrice(snapshot, "0", Convert.ToDouble(row.Cells["Bid"].Value));
                    row.Cells["Ask"].Value         = getPrice(snapshot, "1", Convert.ToDouble(row.Cells["Ask"].Value));
                    row.Cells["MinQuantity"].Value = minQty;
                }
                else // otherwise add it to the DataGridView
                {
                    map.Add(instrument, map.Count);
                    grdRates.Rows.Add(
                        instrument,
                        getClose(snapshot),
                        getPrice(snapshot, "0", 0D),
                        getPrice(snapshot, "1", 0D),
                        minQty
                        );
                }
                // force the interface to refresh
                //Application.DoEvents();
            }
        }