void api_OnFill(Instrument instrument, TTFill fill)
 {
     //cross thread - so you don't get the cross theading exception
     if (this.InvokeRequired)
     {
         this.BeginInvoke((MethodInvoker) delegate
         {
             api_OnFill(instrument, fill);
         });
         return;
     }
 }
Exemple #2
0
        private TTFill NewTTFill(Fill fill)
        {
            // Create a simpler TTFill object from the Fill object.
            TTFill ttf;
            string key = fill.FillKey;

            if (_ttFills.ContainsKey(key))
            {
                ttf = _ttFills[key];
            }
            else
            {
                ttf = new TTFill(fill);
                _ttFills.Add(key, ttf);
            }
            // Initialize any TTFill fields here:
            ttf.Instrument = _ttInstruments[fill.InstrumentKey];
            ttf.Key        = key;

            return(ttf);
        }
Exemple #3
0
        void processFill(FillOriginator originator, FillAction action, Fill fill, params Fill[] fills)
        {
            TTFill newFill = null;

            /*
             * fill.BuySell;
             * fill.FFT2;
             * fill.FFT3;
             * fill.FillKey;
             * fill.FillType;
             * fill.InstrumentKey;
             * fill.IsHedge;   // autospreader hedge order
             * fill.IsQuoting; // autospreader quoting order
             * fill.MatchPrice;
             * fill.Quantity;
             * fill.SpreadId;
             * fill.TransactionDateTime;
             */

            // If this is the first fill for this instrument, then add it to our list and
            // subscribe to the instrument updates if AutoSubscribeInstruments is true.
            if (!_ttInstruments.ContainsKey(fill.InstrumentKey))
            {
                if (AutoSubscribeInstruments)
                {
                    //TODO: Make the subscribe to instrument work
                    //SubscribeToInstrument(fill.InstrumentKey);

                    /*InstrumentLookupSubscription ils = new InstrumentLookupSubscription(apiSession, Dispatcher.Current, fill.InstrumentKey);
                     * ils.Update += new EventHandler<InstrumentLookupSubscriptionEventArgs>(ils_Update);
                     * ils.Start();*/
                }

                TTInstrument tti = new TTInstrument(fill.InstrumentKey);
                _ttInstruments.Add(fill.InstrumentKey, tti);
            }

            TTFill ttf = NewTTFill(fill);

            #region LOOK FOR '#' IN THE FFT FIELDS
            // See if this fill contains our '#' hashtag in either FFT field.
            string hashField = null;
            if (fill.FFT2.StartsWith("#"))
            {
                hashField = fill.FFT2;
            }
            if (fill.FFT3.StartsWith("#"))
            {
                hashField = fill.FFT3;
            }

            // If we found a valid '#' hashtag value, then put it in our dropdown combo box.
            if (hashField != null)
            {
                // Add this fill to our list of fills with this same hashsymbol
                if (!_hashSymbols.ContainsKey(hashField))
                {
                    _hashSymbols.Add(hashField, new List <Fill>());
                }
                List <Fill> hashFills = _hashSymbols[hashField];
                hashFills.Add(fill);
            }
            #endregion

            // There are definitely times when the fill key already exists in the dictionary. In those
            // cases I am just overwriting the previous fill with the new one (asuming it is an updated
            // fill or whatever).
            _currentTTFills[fill.FillKey] = ttf;

            if (OnFill != null)
            {
                OnFill(originator, action, _ttInstruments[fill.InstrumentKey], ttf, newFill);
            }
        }