public static void RunOrderAuto() { List <OrderAuto> orders = OrderAutoRA.List4Undone(); foreach (OrderAuto orderAuto in orders) { if (orderAuto.status_enum != StatusAutoOrderEnum.Run) { continue; } if (orderAuto.time_next_dt > DateTime.Now) { continue; } string key = "S_" + orderAuto.id + "_U_" + orderAuto.unit_id + "_D_0"; Random random = new Random(); Order order = new Order() { code = orderAuto.code, type = orderAuto.type, unit_id = orderAuto.unit_id, account_id = orderAuto.account_id, user_id = orderAuto.user_id, platform = orderAuto.platform }; order.count = orderAuto.count_total - orderAuto.order_count; orderAuto.time_next_dt = DateTime.MinValue; if (order.count > orderAuto.count_max) { order.count = random.Next(orderAuto.count_min / 100, orderAuto.count_max / 100) * 100; orderAuto.time_next_dt = DateTime.Now.AddSeconds(random.Next(orderAuto.time_min, orderAuto.time_max)); } if (orderAuto.time_next_dt >= time_pause && orderAuto.time_next_dt <= time_recovery) { orderAuto.time_next_dt = orderAuto.time_next_dt.AddMinutes(90); } if (orderAuto.time_next_dt >= time_close) { OrderAutoRA.UpdateStatus(StatusAutoOrderEnum.Stop, 1, key); continue; } order.price = DataBiz.GetPriceByPriceType(orderAuto.code, orderAuto.price_type_enum); if (order.price < orderAuto.price_min) { order.price = orderAuto.price_min; } else if (order.price > orderAuto.price_max) { order.price = orderAuto.price_max; } ApiResultEnum result = Order(order.Clone() as Order); orderAuto.result_prev = new Model.Return.Return(result).Message; orderAuto.order_times++; orderAuto.order_count += order.count; orderAuto.time_prev_dt = DateTime.Now; OrderAutoRA.UpdateExecuted(orderAuto, order, key); } }