Skip to content

dv-lebedev/quik-connector

Repository files navigation

QuikConnector

License .Net version

Quik settings in 'info.wnd'

Functionality

  • send orders and monitor their execution by channel of orders
  • get real-time market data
  • control connection to Quik
  • async functions
using System;
using System.Collections.Generic;
using QuikConnector.API;
using QuikConnector.Core;
using QuikConnector.Data;
using QuikConnector.Orders;

namespace QuikConnector.Examples
{
    class Program
    {
        static void Main(string[] args)
        {
            var parameters = new ConnectorParameters(
                account: "MyAccount",
                pathToQuik: Terminal.GetPathToActiveQuik(),
                ddeServerName: "QServer");


            using (var QUIK = new QConnector(parameters))
            {
                QUIK.Connection.Connected += (sender, e) => Console.WriteLine("Connected.");

                QUIK.ImportStarted += (sender, e) => Console.WriteLine("Import started.");

                QUIK.Connect();
                QUIK.StartImport();


                IDataTable<Security> securitiesTable = QUIK.AddDataTable<Security>();

                securitiesTable.Updated += securitiesTable_Updated;

                Console.ReadLine();


                OrderChannel lkoh = QUIK.CreateOrderChannel("LKOH", "EQBR");

                OrderResult result = lkoh.SendTransaction(Direction.Buy, price: 3000.00M, volume: 1);
                
                lkoh.KillOrder(result);

                Console.ReadLine();
            }

        }

        static void securitiesTable_Updated(object sender, List<Security> e)
        {
            var lkoh = e.Find(i => i.Code == "LKOH");

            if (lkoh != null)
            {
                Console.WriteLine("{0}, {1}, {2}, {3}, {4}, {5}",
                    lkoh.ShortName, lkoh.Code, lkoh.Class, lkoh.Bid, lkoh.Ask, lkoh.Price);
            }
        }

    }

    [QuikTable(Name="SecuritiesTable")]
    public class Security
    {
        public string ShortName { get; set; }
        public string Code { get; set; }
        public string Class { get; set; }
        public string Status { get; set; }
        public decimal Bid { get; set; }
        public decimal BidVolume { get; set; }
        public decimal Ask { get; set; }
        public decimal AskVolume { get; set; }
        public decimal Price { get; set; }
        public decimal Lot { get; set; }
    }
}

Dependencies

  • NDde

License

MIT

About

Library for interacting with trading terminal QUIK.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages