Example #1
0
 /// <summary>
 /// Отмена заявки.
 /// </summary>
 /// <param name="order">Информация по заявке, которую требуется отменить.</param>
 public async Task<long> KillOrder(Order order)
 {
     Transaction killOrderTransaction = new Transaction
     {
         ACTION = TransactionAction.KILL_ORDER,
         CLASSCODE = order.ClassCode,
         SECCODE = order.SecCode,
         ORDER_KEY = order.OrderNum.ToString()
     };
     return await Quik.Trading.SendTransaction(killOrderTransaction);
 }
Example #2
0
 /// <summary>
 /// Создание новой заявки.
 /// </summary>
 /// <param name="order">Инфомация о новой заявки, на основе которой будет сформирована транзакция.</param>
 public async Task<long> CreateOrder(Order order)
 {
     Transaction newOrderTransaction = new Transaction
     {
         ACTION = TransactionAction.NEW_ORDER,
         ACCOUNT = order.Account, 
         CLASSCODE = order.ClassCode,
         SECCODE = order.SecCode,
         QUANTITY = order.Quantity,
         OPERATION = order.Operation == Operation.Buy ? TransactionOperation.B : TransactionOperation.S,
         PRICE = order.Price
     };
     return await Quik.Trading.SendTransaction(newOrderTransaction);
 }
Example #3
0
 private static void Events_OnOrder(DataStructures.Transaction.Order order)
 {
     Console.WriteLine("Events_OnOrder: " + order.ToJson());
 }
Example #4
0
        internal void OnOrderCall(Order order)
        {
            if (OnOrder != null) OnOrder(order);
            // invoke event specific for the transaction
            string correlationId = order.TransID.ToString();

            #region Totally untested code or handling manual transactions
            if (!QuikService.Storage.Contains(correlationId)) {
                correlationId = "manual:" + order.OrderNum + ":" + correlationId;
                var fakeTrans = new Transaction() {
                    Comment = correlationId,
                    IsManual = true
                    // TODO map order properties back to transaction
                    // ideally, make C# property names consistent (Lua names are set as JSON.NET properties via an attribute)
                };
                QuikService.Storage.Set<Transaction>(correlationId, fakeTrans);
            }
            #endregion

            var tr = QuikService.Storage.Get<Transaction>(correlationId);
            if (tr != null) {
                lock (tr) {
                    tr.OnOrderCall(order);
                }
            }
            Trace.Assert(tr != null, "Transaction must exist in persistent storage until it is completed and all order messages are recieved");
        }
Example #5
0
 internal void OnOrderCall(Order order)
 {
     if (OnOrder != null) { OnOrder(order); }
     if (Orders == null) { Orders = new List<Order>(); }
     Orders.Add(order);
 }