コード例 #1
0
        /// <summary>
        /// Get Orders list
        /// </summary>
        /// <param name="accountID">account Id</param>
        /// <param name="isActiveOnly">true - active orders only, false - all orders</param>
        /// <param name="idFrom">From orderId</param>
        /// <returns>Orders list</returns>
        public IEnumerable <CommonData.Order> GetOrders(int accountID, bool isActiveOnly, int idFrom)
        {
            List <CommonData.Order> orders = new List <CommonData.Order>();
            var          db_allOrders      = _da.DbContext.Table <Order>().Where(r => r.AccountID == accountID && r.OrderID >= idFrom);
            List <Order> db_orders;

            if (isActiveOnly)
            {
                db_orders = db_allOrders.Where(r => (OrderStatus)r.Status == OrderStatus.Active).ToList();
            }
            else
            {
                db_orders = db_allOrders.ToList();
            }

            foreach (var db_order in db_orders)
            {
                var order = new CommonData.Order()
                {
                    OrderID     = db_order.OrderID,
                    Time        = StorageLib.ToDateTime(db_order.Time),
                    InsID       = db_order.InsID,
                    BuySell     = (BuySell)db_order.BuySell,
                    LotCount    = db_order.LotCount,
                    Price       = db_order.Price,
                    Status      = (OrderStatus)db_order.Status,
                    AccountID   = db_order.AccountID,
                    StopOrderID = db_order.StopOrderID,
                    OrderNo     = db_order.OrderNo
                };
                orders.Add(order);
            }

            return(orders);
        }
コード例 #2
0
        /// <summary>
        /// Update Order object
        /// </summary>
        /// <param name="order">Order object (OrderID > 0)</param>
        public void UpdateOrder(CommonData.Order order)
        {
            Order db_order = new Order()
            {
                OrderID     = order.OrderID,
                Time        = StorageLib.ToDbTime(order.Time),
                InsID       = order.InsID,
                BuySell     = (byte)order.BuySell,
                LotCount    = order.LotCount,
                Price       = order.Price,
                Status      = (byte)order.Status,
                AccountID   = order.AccountID,
                StopOrderID = order.StopOrderID,
                OrderNo     = order.OrderNo
            };

            _da.DbContext.Update(db_order);
        }