Exemple #1
0
        static void Main(string[] args)
        {
            SqlConnection connection = new SqlConnection("Data Source=WIN-K69N1L1NJDB;Initial Catalog=smartcom;User ID=sa;Password=WaNo11998811mssql;Asynchronous Processing=True;ConnectRetryInterval=5");
            //connection.Open();
            SmartCom sc = new SmartCom("mx.ittrade.ru", 8443, "BP12800", "8GVZ7Z");

            Console.WriteLine(sc.Login);
            sc.SmartC.Connected += () => { Console.WriteLine("CONNECTED3!!!!"); sc.SmartC.GetSymbols(); };
            sc.SmartC.AddSymbol += (int row, int nrows, string symbol, string short_name, string long_name, string type, int decimals, int lot_size, double punkt, double step, string sec_ext_id, string sec_exch_name, DateTime expiry_date, double days_before_expiry, double strike)
                                   => {
                if (symbol.ToUpper().StartsWith("RTS-9.14_FT"))
                {
                    Console.WriteLine("{0} => {1}", row, symbol);
                    sc.SmartC.AddTick += (string symbol1, DateTime datetime, double price, double volume, string tradeno, StOrder_Action action)
                                         => {
                        DateTime dt      = DateTime.Now;
                        string   nowTime = dt.Hour.ToString() + ":" + dt.Minute.ToString() + ":" + dt.Second.ToString() + "." + dt.Millisecond.ToString();
                        Console.WriteLine("{0} => {1} => {2} => {3}", price, volume, allCount += (int)volume, nowTime);
                    };
                    sc.SmartC.ListenTicks(symbol);
                }
            };
            sc.ConnectDataSource();
            Console.ReadLine();
        }
Exemple #2
0
        private void timer_callback(object ot, ElapsedEventArgs e)
        {
            TimeSpan currentTime = DateTime.Now.TimeOfDay;

            if (currentTime < timeOfStart && OnBeforeStart != null)
            {
                OnBeforeStart(currentTime.Subtract(timeOfStart));
            }
            else
            {
                timer.Stop();
                SmartWindow.Dispatcher.BeginInvoke(DispatcherPriority.Normal,
                                                   (ThreadStart) delegate()
                {
                    SmartWindow.Label1.Content = "Старт! " + DateTime.Now.TimeOfDay.ToString();
                    smartCom = new SmartCom("mx.ittrade.ru", 8443, login, password);
                    //smartCom = new SmartCom("st1.ittrade.ru", 8090, login, password);
                    smartCom.SmartC.Connected    += new SmartCOM3Lib._IStClient_ConnectedEventHandler(this.ShowConnected);
                    smartCom.SmartC.Disconnected += new SmartCOM3Lib._IStClient_DisconnectedEventHandler(this.ShowDisconnected);
                    smartCom.SmartC.AddSymbol    += new SmartCOM3Lib._IStClient_AddSymbolEventHandler(this.AddSymbol);
                    smartCom.ConnectDataSource();
                }
                                                   );
            }
        }
Exemple #3
0
 private void ShowDisconnected(string _reason)
 {
     SmartWindow.Dispatcher.BeginInvoke(DispatcherPriority.Normal,
                                        (ThreadStart) delegate()
     {
         SmartWindow.textBox1.AppendText(DateTime.Now.TimeOfDay.ToString() + "  Отключение. Причина: " + _reason + "\r\n");
         SmartWindow.textBox1.AppendText("Переподключение в ... " + DateTime.Now.TimeOfDay.Add(new TimeSpan(TimeSpan.TicksPerMillisecond * 10000)) + "\r\n");
     }
                                        );
     smartCom.SmartC               = new SmartCOM3Lib.StServerClass();
     smartCom.SmartC.Connected    += new SmartCOM3Lib._IStClient_ConnectedEventHandler(this.ShowConnected);
     smartCom.SmartC.Disconnected += new SmartCOM3Lib._IStClient_DisconnectedEventHandler(this.ShowDisconnected);
     smartCom.SmartC.AddSymbol    += new SmartCOM3Lib._IStClient_AddSymbolEventHandler(this.AddSymbol);
     Thread.Sleep(10000);
     smartCom.ConnectDataSource();
 }