private void updateList(List <ModelEntry> model, DataGridView bookEntries, int baseRow)
        {
            double totalSize = 0.0;
            int    cumSize   = 0;

            if (baseRow > 0)
            {
                var modelEntry = model[checked (baseRow - 1)];
                cumSize   = model[checked (baseRow - 1)].CumSize;
                totalSize = model[checked (baseRow - 1)].TotalPrice;
            }

            for (var i = baseRow; i < model.Count; i++)
            {
                ModelEntry modelEntry = model[i];
                checked { cumSize += modelEntry.Size; }
                modelEntry.CumSize    = cumSize;
                totalSize            += modelEntry.Price * (double)modelEntry.Size;
                modelEntry.TotalPrice = totalSize;

                double avgPrice = totalSize / (double)cumSize;

                if (i > checked (bookEntries.Rows.Count - 1))
                {
                    bookEntries.Rows.Add();
                }
                var row = bookEntries.Rows[i];
                row.Cells[(int)Cell.MarketMaker].Value = modelEntry.MarketMaker;
                row.Cells[(int)Cell.Price].Value       = PriceFormatter.FormatPrice(modelEntry.Price, mSecType, mTickSize);
                row.Cells[(int)Cell.Size].Value        = modelEntry.Size;
                row.Cells[(int)Cell.CumSize].Value     = cumSize;
                row.Cells[(int)Cell.AvgPrice].Value    = avgPrice;
            }
        }
Exemple #2
0
        public void tickPrice(int tickerId, int tickType, double price, TickAttrib attribs)
        {
            var cd = mTickers[tickerId].ContractDetails;

            switch (tickType)
            {
            case IBApi.TickType.ASK:
                showTickerValue(tickerId, TickerColumnAsk, PriceFormatter.FormatPrice(price, cd.Contract.SecType, cd.MinTick * cd.PriceMagnifier));
                break;

            case IBApi.TickType.BID:
                showTickerValue(tickerId, TickerColumnBid, PriceFormatter.FormatPrice(price, cd.Contract.SecType, cd.MinTick * cd.PriceMagnifier));
                break;

            case IBApi.TickType.LAST:
                showTickerValue(tickerId, TickerColumnLast, PriceFormatter.FormatPrice(price, cd.Contract.SecType, cd.MinTick * cd.PriceMagnifier));
                break;
            }
        }