Esempio n. 1
0
        public void SymbolUpdate(PriceRow row)
        {
            string legFormula = m_legs[row.Symbol];
            // TODO: SUPER inefficient to loop through all spreads here!

            /*foreach (var leg in m_legs.Values)
             * {
             *  string expressionToEvaluate = ReplaceSymbolWithValue(legFormula, row.Symbol, row.LastTradePrice);
             * }
             * m_legValues[row.Symbol] = Eval(expressionToEvaluate);*/

            string expressionToEvaluate = ReplaceSymbolWithValue(legFormula, row.Symbol, row.LastTradePrice);

            m_legValues[row.Symbol] = Eval(expressionToEvaluate);

            // TODO: if all leg values are valid, assign values to each of the member values
            if (!m_legValues.Values.Contains(double.NaN))
            {
                m_lastTradePrice = 0.0;
                foreach (var value in m_legValues.Values)
                {
                    m_lastTradePrice += value;
                }
                m_bid           = 0.0;
                m_ask           = 0.0;
                m_lastTradeSize = 0;
                m_bidSize       = 0;
                m_askSize       = 0;
            }
            //cout("SymbolUpdate: {0} {1} {2}", row.Symbol, m_legs[row.Symbol], row.LastTradePrice);
        }
Esempio n. 2
0
 private void UpdateSpreads(PriceRow row)
 {
     //cout("UPDATE SPREADS: {0}", row.Symbol);
     if (m_updateSpreadRows.ContainsKey(row.Symbol))
     {
         var li = m_updateSpreadRows[row.Symbol];
         foreach (var spreadRow in li)
         {
             spreadRow.SymbolUpdate(row);
             m_spreadGrid.UpdateRow(spreadRow);
         }
     }
 }
Esempio n. 3
0
        public void SymbolUpdate(PriceRow row)
        {
            // Update the latest price for this row's symbol
            m_latestPrices[row.Symbol] = row;

            // Ensure that we have price values for ALL symbols used in this spread formula
            if (m_formulaSymbols.Distinct().Count() != m_latestPrices.Keys.Count())
            {
                return;
            }

            string legFormula = m_legs[row.Symbol];
            // TODO: SUPER inefficient to loop through all spreads here!

            /*foreach (var leg in m_legs.Values)
             * {
             *  string expressionToEvaluate = ReplaceSymbolWithValue(legFormula, row.Symbol, row.LastTradePrice);
             * }
             * m_legValues[row.Symbol] = Eval(expressionToEvaluate);*/

            string formula = Formula;

            foreach (string symbol in m_latestPrices.Keys)
            {
                formula = ReplaceSymbolWithValue(formula, symbol, m_latestPrices[symbol].LastTradePrice);
            }
            //string expressionToEvaluate = ReplaceSymbolWithValue(legFormula, row.Symbol, row.LastTradePrice);
            //m_legValues[row.Symbol] = Eval(expressionToEvaluate);
            m_lastTradePrice = Eval(formula);
            return;

            // TODO: if all leg values are valid, assign values to each of the member values
            if (!m_legValues.Values.Contains(double.NaN))
            {
                m_lastTradePrice = 0.0;
                foreach (var value in m_legValues.Values)
                {
                    m_lastTradePrice += value;
                }
                m_bid           = 0.0;
                m_ask           = 0.0;
                m_lastTradeSize = 0;
                m_bidSize       = 0;
                m_askSize       = 0;
            }
            //cout("SymbolUpdate: {0} {1} {2}", row.Symbol, m_legs[row.Symbol], row.LastTradePrice);
        }
Esempio n. 4
0
 // TODO: WHAT IF WE SUBSCRIBE TO A PRICE FIRST IN THE SPREAD GRID? WE NEED TO CHECK FOR EXISTING m_updatePriceRows ENTRY AND USE IF EXISTS
 private void AddPriceRow(string symbol)
 {
     if (m_updatePriceRows.ContainsKey(symbol))      // if the symbol is already "subscribed"...
     {
         var row = m_updatePriceRows[symbol];        // use the existing PriceRow
         //row.AddNotifyGrid(m_level1Grid);            // add m_level1Grid to the grids that should be notified of updates
         m_level1Grid.AddRow(row);                   // display the row in the "Price" grid
     }
     else
     {
         var row = new PriceRow(symbol);             // create a new PriceRow for this symbol
         //row.AddNotifyGrid(m_level1Grid);
         m_updatePriceRows[symbol] = row;
         m_level1Grid.AddRow(row);
         m_prices.SubscribePrices(symbol);
     }
 }
Esempio n. 5
0
        // Reload the SPREADS file into the "Spreads" grid
        private void ReloadSpreads()
        {
            m_spreadGrid.ClearRows();

            // If our symbols text file exists, then read it and request price updates on the symbols in the file
            var df = dfReadSpreads();
            foreach (var row in df.Rows)
            {
                //string group = row[0];
                string symbol = row[1];
                string formula = row[8];
                var spreadRow = new SpreadRow(symbol, formula);
                m_spreadGrid.AddRow(spreadRow);

                foreach (var sym in spreadRow.FormulaSymbols)
                {
                    cout("Formula Symbol: {0}", sym);
                    if (m_updatePriceRows.ContainsKey(sym))
                    {
                        var priceRow = m_updatePriceRows[sym];
                        //priceRow.AddNotifyGrid(m_spreadGrid);
                        AddSpreadRow(sym, spreadRow);
                    }
                    else
                    {
                        var priceRow = new PriceRow(sym);
                        //priceRow.AddNotifyGrid(m_spreadGrid);
                        m_updatePriceRows[sym] = priceRow;
                        AddSpreadRow(sym, spreadRow);
                        //m_level1Grid.AddRow(row);
                        m_prices.SubscribePrices(sym);
                    }
                }

                //SubscribePrices(symbol1);
                //SubscribePrices(symbol2);
            }
        }
Esempio n. 6
0
 public void SymbolUpdate(PriceRow row)
 {
     m_spreadFormula.SymbolUpdate(row);
 }