/// <summary> /// Create stop-order /// </summary> /// <param name="accountID">Account id</param> /// <param name="time">Date and time</param> /// <param name="insID">Instrum id</param> /// <param name="bs">Buy or sell</param> /// <param name="st">StopLoss or TakeProfit</param> /// <param name="endTime">End time or null</param> /// <param name="alertPrice">Alert price</param> /// <param name="price">Order price or null</param> /// <param name="lotCount">Lots count</param> /// <param name="status">Stop order status</param> /// <param name="completeTime">Complete date and time</param> /// <param name="stopOrderNo">Global stop-order number</param> /// <returns>New stop-order</returns> public StopOrder CreateStopOrder(int accountID, DateTime time, int insID, BuySell bs, StopOrderType st, DateTime?endTime, decimal alertPrice, decimal?price, int lotCount, StopOrderStatus status, DateTime?completeTime, long stopOrderNo) { StopOrder stopOrder = new StopOrder() { AccountID = accountID, Time = time, InsID = insID, BuySell = bs, StopType = st, EndTime = endTime, AlertPrice = alertPrice, Price = price, LotCount = lotCount, Status = status, CompleteTime = completeTime, StopOrderNo = stopOrderNo }; using (var db = new DaContext(_options)) { db.StopOrder.Add(stopOrder); db.SaveChanges(); } return(stopOrder); }
public bool UpdateStopOrder(long stopOrderNo, DateTime?endTime, StopOrderStatus status, DateTime updateTime) { var db_stopOrder = _da.GetStopOrder(stopOrderNo); if (db_stopOrder != null) { db_stopOrder.Status = status; db_stopOrder.EndTime = endTime; if (status != StopOrderStatus.Active && db_stopOrder.CompleteTime == null) { db_stopOrder.CompleteTime = updateTime; } _da.UpdateStopOrder(db_stopOrder); } return(true); }
public StopOrder CreateStopOrder(int accountID, DateTime time, int insID, BuySell bs, StopOrderType st, DateTime?endTime, decimal alertPrice, decimal?price, int lotCount, StopOrderStatus status, DateTime?completeTime, long stopOrderNo) { StopOrder so = new StopOrder() { StopOrderID = _nextStopOrderID++, AccountID = accountID, Time = time, InsID = insID, BuySell = bs, StopType = st, EndTime = endTime, AlertPrice = alertPrice, Price = price, LotCount = lotCount, Status = status, CompleteTime = completeTime, StopOrderNo = stopOrderNo }; _id_stopOrders.Add(so.StopOrderID, so); return(so); }
/// <summary> /// Создать новый стоп-ордер /// </summary> /// <param name="time">Дата и время создания</param> /// <param name="insID">Фин инструмент</param> /// <param name="bs">Покупка или продажа</param> /// <param name="soType">Тип стоп-ордера</param> /// <param name="endTime">Время окончания (null-действует бесконечно)</param> /// <param name="alertPrice">Цена срабатывания стопа</param> /// <param name="price">Цена заявки, которая будет создана при срабатывании стопа (null-заявка по рыночной цене)</param> /// <param name="lotCount">Кол-во лотов</param> /// <param name="status">Статус нового стоп-ордера</param> /// <returns>Новый стоп-ордер</returns> public StopOrder AddStopOrder(DateTime time, int insID, BuySell bs, StopOrderType soType, DateTime?endTime, decimal alertPrice, decimal?price, int lotCount, StopOrderStatus status) { StopOrder so = new StopOrder(); so.StopOrderID = GetNewID <StopOrder>(_stopOrders, r => r.StopOrderID); so.Time = time; so.InsID = insID; so.BuySell = bs; so.StopType = soType; so.EndTime = endTime; so.AlertPrice = alertPrice; so.Price = price; so.LotCount = lotCount; so.Status = status; so.AccountID = _account.AccountID; so.CompleteTime = null; _stopOrders.Add(so); return(so); }