void api_OnSpreadFound(TTSpread spread, bool success)
        {
            #region Thread Safety
            //cross thread - so you don't get the cross theading exception
            if (this.InvokeRequired)
            {
                this.BeginInvoke((MethodInvoker) delegate
                {
                    api_OnSpreadFound(spread, success);
                });
                return;
            }
            #endregion

            if (success)
            {
            }
            else
            {
                string errorMsg = "";

                /*if (e.Error != null)
                 *  errorMsg = e.Error.Message;*/

                // Instrument not found and TTAPI has given up looking for it
                //MessageBox.Show(this, "Could not find spread:\n\n" + spread.Name + "\n\n" + errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                MessageBox.Show(this, "An error occurred attempting to find the spread.\n\n" + errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
示例#2
0
        private TTSpread NewTTSpread(Instrument instrument)
        {
            TTSpread tts;

            if (_ttInstruments.ContainsKey(instrument.Key))
            {
                tts = _ttInstruments[instrument.Key] as TTSpread;
            }
            else
            {
                tts = new TTSpread(instrument);
                _ttInstruments.Add(instrument.Key, tts);
            }
            // Initialize any TTSpread fields here:
            tts.TTAPI_Instrument = instrument;
            tts.Name             = instrument.Name;

            return(tts);
        }
示例#3
0
        TTSpread processSpreadFound(Instrument instrument)
        {
            PriceSubscription priceSub = new PriceSubscription(instrument, Dispatcher.Current);

            priceSub.Settings       = new PriceSubscriptionSettings(PriceSubscriptionType.InsideMarket);
            priceSub.FieldsUpdated += new FieldsUpdatedEventHandler(priceSub_FieldsUpdated);
            priceSub.Start();

            ASInstrumentTradeSubscription its = new ASInstrumentTradeSubscription(_apiSession, Dispatcher.Current, instrument as AutospreaderInstrument);

            its.EnablePNL          = true;
            its.ProfitLossChanged += new EventHandler <ProfitLossChangedEventArgs>(its_ProfitLossChanged);
            its.Start();

            TTSpread tts = NewTTSpread(instrument);

            tts.TradeSubscription = its;

            tts.OrderRoute = OrderRoute.GetOrderRoute(tts, instrument.Product.Market.Name);

            return(tts);
        }