Beispiel #1
0
        static void Main()
        {
            // Do not spam console when used as a dependency and use Trace
            Trace.Listeners.Clear();
            Trace.Listeners.Add(new ConsoleTraceListener());
            // Some biolerplate to react to close window event, CTRL-C, kill, etc
            _handler += Handler;
            SetConsoleCtrlHandler(_handler, true);

            ServiceManager.StartServices();

            _quik = new Quik();
            //Console.WriteLine("Running in Quik? : " + _quik.Debug.IsQuik().Result);

            _quik.Events.OnAllTrade += Events_OnAllTrade;
            _quik.Events.OnQuote    += Events_OnQuote;
            _quik.Events.OnOrder    += Events_OnOrder;
            _quik.Events.OnStop     += Events_OnStop;
            _quik.Events.OnClose    += Events_OnClose;

            // hold the console so it doesn’t run off the end
            while (!_exitSystem)
            {
                Thread.Sleep(100);
            }
        }
Beispiel #2
0
        public void Dispose()
        {
            try
            {
                if (QuikLua != null && QuikLua.Service.IsConnected().Result)
                {
                    QuikLua.Service.QuikService.Stop();
                }
            }
            catch (Exception error)
            {
                SendLogMessage(error.ToString(), LogMessageType.Error);
            }

            if (QuikLua != null)
            {
                QuikLua.Events.OnConnected            -= EventsOnOnConnected;
                QuikLua.Events.OnDisconnected         -= EventsOnOnDisconnected;
                QuikLua.Events.OnConnectedToQuik      -= EventsOnOnConnectedToQuik;
                QuikLua.Events.OnDisconnectedFromQuik -= EventsOnOnDisconnectedFromQuik;
                QuikLua.Events.OnTrade -= EventsOnOnTrade;
                QuikLua.Events.OnOrder -= EventsOnOnOrder;
                QuikLua.Events.OnQuote -= EventsOnOnQuote;
                QuikLua.Events.OnFuturesClientHolding -= EventsOnOnFuturesClientHolding;
                QuikLua.Events.OnFuturesLimitChange   -= EventsOnOnFuturesLimitChange;
            }

            ServerStatus = ServerConnectStatus.Disconnect;
            DisconnectEvent?.Invoke();
            subscribedBook = new List <string>();
            QuikLua        = null;
        }
Beispiel #3
0
        public void Connect()
        {
            if (QuikLua == null)
            {
                QuikLua = new QuikSharp.Quik(QuikSharp.Quik.DefaultPort, new InMemoryStorage());
                QuikLua.Events.OnConnected            += EventsOnOnConnected;
                QuikLua.Events.OnDisconnected         += EventsOnOnDisconnected;
                QuikLua.Events.OnConnectedToQuik      += EventsOnOnConnectedToQuik;
                QuikLua.Events.OnDisconnectedFromQuik += EventsOnOnDisconnectedFromQuik;
                QuikLua.Events.OnTrade += EventsOnOnTrade;
                QuikLua.Events.OnOrder += EventsOnOnOrder;
                QuikLua.Events.OnQuote += EventsOnOnQuote;
                QuikLua.Events.OnFuturesClientHolding += EventsOnOnFuturesClientHolding;
                QuikLua.Events.OnFuturesLimitChange   += EventsOnOnFuturesLimitChange;

                QuikLua.Service.QuikService.Start();
                ServerStatus = ServerConnectStatus.Connect;
                ConnectEvent?.Invoke();
            }
        }
Beispiel #4
0
        private static void Main()
        {
            // Do not spam console when used as a dependency and use Trace
            //Trace.Listeners.Clear();
            //Trace.Listeners.Add(new ConsoleTraceListener());
            //// Some biolerplate to react to close window event, CTRL-C, kill, etc
            //_handler += Handler;
            //SetConsoleCtrlHandler(_handler, true);

            //ServiceManager.StartServices();

            //_quik = new Quik();
            ////Console.WriteLine("Running in Quik? : " + _quik.Debug.IsQuik().Result);

            //_quik.Events.OnAllTrade += Events_OnAllTrade;
            //_quik.Events.OnQuote += Events_OnQuote;
            //_quik.Events.OnOrder += Events_OnOrder;
            //_quik.Events.OnStop += Events_OnStop;
            //_quik.Events.OnClose += Events_OnClose;

            // ************************************************************************************

            string securityCode = "RIZ5";

            // Do not spam console when used as a dependency and use Trace
            Trace.Listeners.Clear();
            Trace.Listeners.Add(new ConsoleTraceListener());

            // Some biolerplate to react to close window event, CTRL-C, kill, etc
            _handler += Handler;
            SetConsoleCtrlHandler(_handler, true);

            ServiceManager.StartServices();

            _quik = new Quik();
            //Console.WriteLine("Running in Quik? : " + _quik.Debug.IsQuik().Result);

            // _quik.Events.OnAllTrade += Events_OnAllTrade;
            _quik.Events.OnStop  += Events_OnStop;
            _quik.Events.OnClose += Events_OnClose;
            string time = _quik.Service.GetInfoParam(InfoParams.SERVERTIME).Result;

            DateTime time2 = Convert.ToDateTime(time);

            Console.WriteLine(time2);

            #region Example

            double bestBidPrice   = 0;
            double bestOfferPrice = 0;

            _quik.Events.OnQuote += (orderBook) =>
            {
                if (orderBook.sec_code == securityCode)
                {
                    bestBidPrice   = orderBook.bid.OrderByDescending(o => o.price).First().price;
                    bestOfferPrice = orderBook.offer.OrderByDescending(o => o.price).Last().price;
                }
            };

            var n  = 0;
            var sw = new Stopwatch();
            sw.Start();
            while (n <= 200)
            {
                Console.Write("Best bid: " + bestBidPrice);
                Console.WriteLine(" Best offer: " + bestOfferPrice);

                // this line caused threading issues with CJSON, when two threads were calling ToJson at the same time
                time = _quik.Service.GetInfoParam(InfoParams.SERVERTIME).Result;

                Thread.Sleep(50);

                n++;
            }

            sw.Stop();
            Console.WriteLine("Elapsed: " + sw.ElapsedMilliseconds);
            Console.WriteLine("Per call: " + (sw.ElapsedMilliseconds / n));
            Console.WriteLine("While Exit");

            #endregion Example

            // hold the console so it doesn’t run off the end
            while (!_exitSystem)
            {
                Thread.Sleep(100);
            }
        }
 public StopOrderFunctions(int port, Quik quik, string host)
 {
     QuikService = QuikService.Create(port, host);
     Quik        = quik;
 }
Beispiel #6
0
 public StopOrderFunctions(int port, Quik quik)
 {
     QuikService = QuikService.Create(port);
     Quik        = quik;
 }
Beispiel #7
0
 /// <summary>
 /// Конструктор.
 /// </summary>
 public OrderFunctions(int port, Quik quik)
 {
     QuikService = QuikService.Create(port);
     Quik = quik;
 }
Beispiel #8
0
 public OrderFunctions(Quik quik)
 {
     Quik = quik;
 }
Beispiel #9
0
        static void Main()
        {
            // Do not spam console when used as a dependency and use Trace
            //Trace.Listeners.Clear();
            //Trace.Listeners.Add(new ConsoleTraceListener());
            //// Some biolerplate to react to close window event, CTRL-C, kill, etc
            //_handler += Handler;
            //SetConsoleCtrlHandler(_handler, true);

            //ServiceManager.StartServices();

            //_quik = new Quik();
            ////Console.WriteLine("Running in Quik? : " + _quik.Debug.IsQuik().Result);

            //_quik.Events.OnAllTrade += Events_OnAllTrade;
            //_quik.Events.OnQuote += Events_OnQuote;
            //_quik.Events.OnOrder += Events_OnOrder;
            //_quik.Events.OnStop += Events_OnStop;
            //_quik.Events.OnClose += Events_OnClose;

            // ************************************************************************************

            string securityCode = "RIM5";

            // Do not spam console when used as a dependency and use Trace
            Trace.Listeners.Clear();
            Trace.Listeners.Add(new ConsoleTraceListener());

            // Some biolerplate to react to close window event, CTRL-C, kill, etc
            _handler += Handler;
            SetConsoleCtrlHandler(_handler, true);

            ServiceManager.StartServices();

            _quik = new Quik();
            //Console.WriteLine("Running in Quik? : " + _quik.Debug.IsQuik().Result);

            // _quik.Events.OnAllTrade += Events_OnAllTrade;
            _quik.Events.OnStop += Events_OnStop;
            _quik.Events.OnClose += Events_OnClose;
            string time = _quik.Service.GetInfoParam(InfoParams.SERVERTIME).Result;

            DateTime time2 = Convert.ToDateTime(time);

            Console.WriteLine(time2);

            #region Example

            double bestBidPrice = 0;
            double bestOfferPrice = 0;

            _quik.Events.OnQuote += (orderBook) => {
                    if (orderBook.sec_code == securityCode) {
                        bestBidPrice = orderBook.bid.OrderByDescending(o => o.price).First().price;
                        bestOfferPrice = orderBook.offer.OrderByDescending(o => o.price).Last().price;
                    }
                };

            var n = 0;
            var sw = new Stopwatch();
            sw.Start();
            while (n <= 200) {

                Console.Write("Best bid: " + bestBidPrice);
                Console.WriteLine(" Best offer: " + bestOfferPrice);

                // this line caused threading issues with CJSON, when two threads were calling ToJson at the same time
                time = _quik.Service.GetInfoParam(InfoParams.SERVERTIME).Result;

                Thread.Sleep(50);

                n++;
            }

            sw.Stop();
            Console.WriteLine("Elapsed: " + sw.ElapsedMilliseconds);
            Console.WriteLine("Per call: " + (sw.ElapsedMilliseconds / n));
            Console.WriteLine("While Exit");

            #endregion

            // hold the console so it doesn’t run off the end
            while (!_exitSystem) {
                Thread.Sleep(100);
            }
        }