Example #1
0
        private void startSymbol()
        {
            string     sSymbol;
            Instrument instrument = null;

            if (bSymbolsDone)
            {
                // do nothing
            }
            else
            {
                if (!bAbort && sdr.Read())
                {
                    sSymbol = sdr.GetString(0); // get next symbol in list
                    cntSymbols++;

                    try {
                        instrument                  = new Instrument(sSymbol, st);
                        instrument.Currency         = "USD";
                        instrument.SecurityExchange = "SMART";
                        //instrument.Exchange = "SMART";

                        FIXSecurityAltIDGroup altid;

                        altid = new FIXSecurityAltIDGroup();
                        altid.SecurityAltID       = sSymbol;
                        altid.SecurityAltIDSource = "IB";
                        instrument.AddGroup(altid);
                        altid = null;

                        altid = new FIXSecurityAltIDGroup();
                        altid.SecurityAltID       = sSymbol;
                        altid.SecurityAltIDSource = "IQFeed";
                        instrument.AddGroup(altid);
                        altid = null;

                        instrument.Save();
                    }
                    catch {
                        //Console.WriteLine( "Caught:  Symbol {0} already exists", sSymbol );
                        instrument = InstrumentManager.Instruments[sSymbol];
                    }

                    Console.WriteLine("Starting {0}, {1}", sSymbol, cntSymbols);
                    //Console.WriteLine("Starting {0}, {1} {2} {3}", sSymbol, cntSymbols, hs.intUseCount, hs.intPlaceInQ);

                    if (bTick)
                    {
                        Send(sSymbol, "Trade", instrument, "HT," + sSymbol + "," + cntTick + ";", cntTick);
                    }

                    if (b1min)
                    {
                        Send(sSymbol, "Bar", instrument, "HM," + sSymbol + "," + cnt1min + ",1;", 60, cnt1min);
                    }

                    if (b3min)
                    {
                        Send(sSymbol, "Bar", instrument, "HM," + sSymbol + "," + cnt3min + ",3;", 180, cnt3min);
                    }

                    if (b10min)
                    {
                        Send(sSymbol, "Bar", instrument, "HM," + sSymbol + "," + cnt10min + ",10;", 600, cnt10min);
                    }

                    if (b30min)
                    {
                        Send(sSymbol, "Bar", instrument, "HM," + sSymbol + "," + cnt30min + ",30;", 1800, cnt30min);
                    }

                    if (b2hr)
                    {
                        Send(sSymbol, "Bar", instrument, "HM," + sSymbol + "," + cnt2hr + ",120;", 7200, cnt2hr);
                    }

                    if (bDaily)
                    {
                        //Console.WriteLine( "Starting {0}, {1} {2} {3}", sSymbol, cntSymbols, hs.intUseCount, hs.intPlaceInQ );
                        Send(sSymbol, "Daily", instrument, "HD," + sSymbol + "," + cntDaily + ";", cntDaily);
                    }
                }
                else
                {
                    Console.WriteLine("All {0} symbols requested", cntSymbols);
                    bSymbolsDone = true;
                    sdr.Close();
                    db.Close();
                }
            }
        }