private void fillFromCondition(ExecutionCondition orderCondition) { tradeUnderlying.Text = orderCondition.Symbol; tradeExchange.Text = orderCondition.Exchange; tradeType.Text = orderCondition.SecType; tradeRb.Checked = true; }
public void ParseExecutionCondition() { ExecutionCondition cond = ParseCondition <ExecutionCondition>("trade occurs for ANY symbol on ANY exchange for * security type"); var examp = OrderCondition.Create(OrderConditionType.Execution) as ExecutionCondition; examp.Exchange = "ANY"; examp.Symbol = "ANY"; examp.SecType = "*"; Assert.IsNotNull(cond); Assert.AreEqual(cond.Exchange, "any", true); Assert.IsFalse(cond.IsConjunctionConnection); Assert.AreEqual(cond.SecType, "*"); Assert.AreEqual(cond.Symbol, "any", true); Assert.AreEqual(cond, examp); }
public void Validate(T model, IValidationContext context) { var shouldExecute = ExecutionCondition?.Invoke(model) ?? true; if (!shouldExecute) { return; } context.EnterPath(Path); if (ErrorId.HasValue) { context.EnableErrorDetectionMode(ErrorMode, ErrorId.Value); } RunValidation(model, context); context.LeavePath(); }
public static OrderCondition Create(OrderConditionType type) { OrderCondition?rval = null; switch (type) { case OrderConditionType.Execution: rval = new ExecutionCondition(); break; case OrderConditionType.Margin: rval = new MarginCondition(); break; case OrderConditionType.PercentChange: rval = new PercentChangeCondition(); break; case OrderConditionType.Price: rval = new PriceCondition(); break; case OrderConditionType.Time: rval = new TimeCondition(); break; case OrderConditionType.Volume: rval = new VolumeCondition(); break; } if (rval != null) { rval.Type = type; } return(rval ?? throw new InvalidOperationException("Invalid OrderConditionType.")); }
public static bool CheckCondition(ExecutionCondition condition, ProcessorInfo info, int stepId) { if (condition.Always) { return(true); } if (condition.IfPreviousSucceded && stepId > 0 && info.StepStatus[stepId - 1] == Status.Successful) { return(true); } bool stepsSucceded = true; foreach (var index in condition.StepsSucceded) { if (index < 0 || index > info.StepStatus.Count || info.StepStatus[index] == Status.Failed || info.StepStatus[index] == Status.Waiting) { stepsSucceded = false; break; } } return(stepsSucceded); }
public OrdinaryStepConfig(IStep step, ExecutionCondition condition) { Step = step; Condition = condition; ExecutionStatus = Status.NotStarted; }
private void fillCondition(ExecutionCondition executionCondition) { executionCondition.Symbol = tradeUnderlying.Text; executionCondition.Exchange = tradeExchange.Text; executionCondition.SecType = tradeType.Text; }
public StepConfig(IStep step, ExecutionCondition condition) { Step = step; Condition = condition; }
/// <summary> /// Создание "рыночной"заявки. /// </summary> /// <param name="classCode">Код класса инструмента</param> /// <param name="securityCode">Код инструмента</param> /// <param name="accountID">Счет клиента</param> /// <param name="operation">Операция заявки (покупка/продажа)</param> /// <param name="qty">Количество (в лотах)</param> /// <param name="executionCondition">Условие исполнения заявки (PUT_IN_QUEUE, FILL_OR_KILL, KILL_BALANCE)</param> /// <param name="clientCode">Код клиента</param> public async Task <Order> SendMarketOrder(string classCode, string securityCode, string accountID, Operation operation, int qty, ExecutionCondition executionCondition = ExecutionCondition.PUT_IN_QUEUE, string clientCode = null) { return(await SendOrder(classCode, securityCode, accountID, operation, 0, qty, TransactionType.M, executionCondition, clientCode).ConfigureAwait(false)); }
/// <summary> /// Создание заявки. /// </summary> /// <param name="classCode">Код класса инструмента</param> /// <param name="securityCode">Код инструмента</param> /// <param name="accountID">Счет клиента</param> /// <param name="operation">Операция заявки (покупка/продажа)</param> /// <param name="price">Цена заявки</param> /// <param name="qty">Количество (в лотах)</param> /// <param name="orderType">Тип заявки (L - лимитная, M - рыночная)</param> /// <param name="executionCondition">Условие исполнения заявки (PUT_IN_QUEUE, FILL_OR_KILL, KILL_BALANCE)</param> /// <param name="clientCode">Код клиента</param> async Task <Order> SendOrder(string classCode, string securityCode, string accountID, Operation operation, decimal price, int qty, TransactionType orderType, ExecutionCondition executionCondition = ExecutionCondition.PUT_IN_QUEUE, string clientCode = null) { long res = 0; bool set = false; Order order_result = new Order(); /////// TransactionReply lastTransactionReply = new TransactionReply(); Quik.Events.OnTransReply += (TransactionReply transReply) => { if (transReply.TransID == res) { lastTransactionReply = transReply; } }; /////// Transaction newOrderTransaction = new Transaction { ACTION = TransactionAction.NEW_ORDER, ACCOUNT = accountID, CLASSCODE = classCode, SECCODE = securityCode, QUANTITY = qty, OPERATION = operation == Operation.Buy ? TransactionOperation.B : TransactionOperation.S, PRICE = price, TYPE = orderType, EXECUTION_CONDITION = executionCondition, CLIENT_CODE = clientCode }; try { res = await Quik.Trading.SendTransaction(newOrderTransaction).ConfigureAwait(false); Thread.Sleep(500); Console.WriteLine("res: " + res); } catch { //ignore } while (!set) { if (res > 0) { if (lastTransactionReply == null || lastTransactionReply.ResultMsg == null || lastTransactionReply.ResultMsg == "" || lastTransactionReply.ErrorCode == 0) { try { order_result = await Quik.Orders.GetOrder_by_transID(classCode, securityCode, res).ConfigureAwait(false); } catch { order_result = new Order { RejectReason = "Неудачная попытка получения заявки по ID-транзакции №" + res }; } } else { if (order_result != null) { order_result.RejectReason = lastTransactionReply.ResultMsg; } else { order_result = new Order { RejectReason = lastTransactionReply.ResultMsg } }; } } else { if (order_result != null) { order_result.RejectReason = newOrderTransaction.ErrorMessage; } else { order_result = new Order { RejectReason = newOrderTransaction.ErrorMessage } }; } if (order_result != null && (order_result.RejectReason != "" || order_result.OrderNum > 0)) { set = true; } } Quik.Events.OnTransReply -= (TransactionReply transReply) => { }; return(order_result); }