Exemple #1
0
        /// <summary>
        /// Возвращает заявку по номеру.
        /// </summary>
        public async Task <Order> GetOrder_by_Number(long order_num)
        {
            var             message  = new Message <string>(order_num.ToString(), "getOrder_by_Number");
            Message <Order> response = await QuikService.Send <Message <Order> >(message).ConfigureAwait(false);

            return(response.Data);
        }
Exemple #2
0
        /// <summary>
        /// Возвращает заявку из хранилища терминала по её номеру.
        /// На основе: http://help.qlua.org/ch4_5_1_1.htm
        /// </summary>
        /// <param name="classCode">Класс инструмента.</param>
        /// <param name="orderId">Номер заявки.</param>
        /// <returns></returns>
        public async Task <Order> GetOrder(string classCode, long orderId)
        {
            var             message  = new Message <string>(classCode + "|" + orderId, "get_order_by_number");
            Message <Order> response = await QuikService.Send <Message <Order> >(message).ConfigureAwait(false);

            return(response.Data);
        }
        /// <summary>
        /// Возвращает список всех стоп-заявок.
        /// </summary>
        /// <returns></returns>
        public async Task <List <StopOrder> > GetStopOrders()
        {
            var message = new Message <string>("", "get_stop_orders");
            Message <List <StopOrder> > response = await QuikService.Send <Message <List <StopOrder> > >(message).ConfigureAwait(false);

            return(response.Data);
        }
Exemple #4
0
        /// <summary>
        /// Возвращает заявку для заданного инструмента по ID.
        /// </summary>
        public async Task <Order> GetOrder_by_transID(string classCode, string securityCode, long trans_id)
        {
            var             message  = new Message <string>(classCode + "|" + securityCode + "|" + trans_id, "getOrder_by_ID");
            Message <Order> response = await QuikService.Send <Message <Order> >(message).ConfigureAwait(false);

            return(response.Data);
        }
Exemple #5
0
        /// <summary>
        /// Возвращает список всех стоп-заявок.
        /// </summary>
        /// <returns></returns>
        public async Task <List <StopOrder> > GetStopOrders()
        {
            var message = new Message <string>("", "GetStopOrders");
            Message <List <StopOrder> > response = await QuikService.Send <Message <List <StopOrder> > >(message);

            return(response.Data);
        }
        /// <summary>
        /// Возвращает список стоп-заявок для заданного инструмента.
        /// </summary>
        public async Task <List <StopOrder> > GetStopOrders(string classCode, string securityCode)
        {
            var message = new Message <string>(classCode + "|" + securityCode, "get_stop_orders");
            Message <List <StopOrder> > response = await QuikService.Send <Message <List <StopOrder> > >(message).ConfigureAwait(false);

            return(response.Data);
        }
Exemple #7
0
 /// <summary>
 /// Quik interface in .NET constructor
 /// </summary>
 public Quik(int port = DefaultPort, IPersistentStorage storage = null)
 {
     if (storage == null)
     {
         Storage = new InMemoryStorage();
     }
     else
     {
         Storage = storage;
     }
     QuikService = QuikService.Create(port);
     // poor man's DI
     QuikService.Storage = Storage;
     Events                    = QuikService.Events;
     Debug                     = new DebugFunctions(port);
     Service                   = new ServiceFunctions(port);
     Class                     = new ClassFunctions(port);
     OrderBook                 = new OrderBookFunctions(port);
     Trading                   = new TradingFunctions(port);
     StopOrders                = new StopOrderFunctions(port, this);
     Orders                    = new OrderFunctions(port, this);
     Candles                   = new CandleFunctions(port);
     QuikService.Candles       = Candles;
     QuikService.StopOrders    = StopOrders;
     QuikService.WorkingFolder = Service.GetWorkingFolder().Result;
 }
Exemple #8
0
        /// <summary>
        /// For each port only one instance of QuikService
        /// </summary>
        public static QuikService Create(int port, string host)
        {
            lock (StaticSync)
            {
                QuikService service;
                if (Services.ContainsKey(port))
                {
                    service = Services[port];
                    service.Start();
                }
                else
                {
                    service = new QuikService(port, host);
                    Services.Add(port, service);
                }

                service.Serializer = new JsonSerializer
                {
                    TypeNameHandling  = TypeNameHandling.None,
                    NullValueHandling = NullValueHandling.Ignore
                };
                service.Serializer.Converters.Add(new MessageConverter(service));
                return(service);
            }
        }
Exemple #9
0
 internal static IMessage FromJson(this string json, QuikService service)
 {
     using (var reader = new JsonTextReader(new StringReader(json))) {
         // reader will get buffer from array pool
         reader.ArrayPool = JsonArrayPool.Instance;
         var value = service.Serializer.Deserialize <IMessage>(reader);
         return(value);
     }
 }
Exemple #10
0
 /// <summary>
 /// For each port only one instance of QuikService
 /// </summary>
 public static QuikService Create(int port)
 {
     lock (StaticSync) {
         QuikService service;
         if (_services.ContainsKey(port))
         {
             service = _services[port];
             service.Start();
         }
         else
         {
             service = new QuikService(port);
             _services.Add(port, service);
         }
         return(service);
     }
 }
Exemple #11
0
 /// <summary>
 /// Quik interface in .NET constructor
 /// </summary>
 public Quik(int port = DefaultPort, IPersistentStorage storage = null)
 {
     if (storage == null)
     {
         Storage = new EsentStorage();
     }
     else
     {
         Storage = storage;
     }
     QuikService = QuikService.Create(port);
     // poor man's DI
     QuikService.Storage = Storage;
     Events    = QuikService.Events;
     Debug     = new DebugFunctions(port);
     Service   = new ServiceFunctions(port);
     Class     = new ClassFunctions(port);
     OrderBook = new OrderBookFunctions(port);
     Trading   = new TradingFunctions(port);
 }
Exemple #12
0
 /// <summary>
 /// Quik interface in .NET constructor
 /// </summary>
 public Quik(int port = DefaultPort, IPersistentStorage storage = null, string host = DefaultHost)
 {
     Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
     Storage     = storage == null ? new InMemoryStorage() : storage;
     QuikService = QuikService.Create(port, host);
     // poor man's DI
     QuikService.Storage = Storage;
     Events                    = QuikService.Events;
     Debug                     = new DebugFunctions(port, host);
     Service                   = new ServiceFunctions(port, host);
     Class                     = new ClassFunctions(port, host);
     OrderBook                 = new OrderBookFunctions(port, host);
     Trading                   = new TradingFunctions(port, host);
     StopOrders                = new StopOrderFunctions(port, this, host);
     Orders                    = new OrderFunctions(port, this, host);
     Candles                   = new CandleFunctions(port, host);
     QuikService.Candles       = Candles;
     QuikService.StopOrders    = StopOrders;
     QuikService.WorkingFolder = Service.GetWorkingFolder().Result;
 }
 public TradingFunctions(int port)
 {
     QuikService = QuikService.Create(port);
 }
 public CandleFunctions(int port)
 {
     QuikService = QuikService.Create(port);
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="port"></param>
 public OrderBookFunctions(int port)
 {
     QuikService = QuikService.Create(port);
 }
Exemple #16
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="port"></param>
 /// <param name="host"></param>
 public OrderBookFunctions(int port, string host)
 {
     QuikService = QuikService.Create(port, host);
 }
Exemple #17
0
 public static void StartServices()
 {
     quikService = QuikService.Create(Quik.DefaultPort);
 }
Exemple #18
0
 // Если запуск "сервиса" (потоков работы с Lua) происходит в конструкторе Quik, то возможности остановить "сервис" нет.
 // QuikService объявлен как private.
 public void StopService()
 {
     QuikService.Stop();
 }
Exemple #19
0
 public ClassFunctions(int port)
 {
     QuikService = QuikService.Create(port);
 }
Exemple #20
0
 public TradingFunctions(int port, string host)
 {
     QuikService = QuikService.Create(port, host);
 }
Exemple #21
0
 public CandleFunctions(int port, string host)
 {
     QuikService = QuikService.Create(port, host);
 }
Exemple #22
0
 public bool IsServiceConnected()
 {
     return(QuikService.IsServiceConnected());
 }
 public StopOrderFunctions(int port, Quik quik, string host)
 {
     QuikService = QuikService.Create(port, host);
     Quik        = quik;
 }
Exemple #24
0
 public QuikEvents(QuikService service)
 {
     QuikService = service;
 }
 public static void StartServices()
 {
     quikService = QuikService.Create(Quik.DefaultPort);
     Task.Run(() => Tray.Run());
 }
 public MessageConverter(QuikService service)
 {
     _service = service;
 }
 public DebugFunctions(int port)
 {
     QuikService = QuikService.Create(port);
 }
        internal static IMessage FromJson(this string json, QuikService service)
        {
            var obj = JsonConvert.DeserializeObject <IMessage>(json, new MessageConverter(service));

            return(obj);
        }
Exemple #29
0
 public StopOrderFunctions(int port, Quik quik)
 {
     QuikService = QuikService.Create(port);
     Quik        = quik;
 }