Esempio n. 1
0
        public static void Add(OrderAutoAdd order, string key)
        {
            Dictionary <string, string> items = new Dictionary <string, string>();

            items.Add("id", order.id.ToString());
            items.Add("unit_id", order.unit_id.ToString());
            items.Add("user_id", order.user_id.ToString());
            items.Add("platform", order.platform.ToString());
            items.Add("account_id", order.account_id.ToString());
            items.Add("account_name", order.account_name);
            items.Add("code", order.code);
            items.Add("name", order.name);
            items.Add("status", "0");
            items.Add("type", order.type.ToString());
            items.Add("price_min", order.price_min.ToString());
            items.Add("price_max", order.price_max.ToString());
            items.Add("price_type", order.price_type.ToString());
            items.Add("count_min", order.count_min.ToString());
            items.Add("count_max", order.count_max.ToString());
            items.Add("count_total", order.count_total.ToString());
            items.Add("time_min", order.time_min.ToString());
            items.Add("time_max", order.time_max.ToString());
            items.Add("time_next_dt", DateTime.MinValue.Format());
            items.Add("time_prev_dt", DateTime.MinValue.Format());
            items.Add("order_times", "0");
            items.Add("order_count", "0");
            items.Add("result_prev", "");
            items.Add("operator_start", "");
            items.Add("operator_stop", "");
            TradeRA.SetFields(key, items);
            TradeRA.SetExpire(key);
        }
Esempio n. 2
0
        public Result <long> OrderAutoAdd(OrderAutoAdd model)
        {
            if (model.count_min > model.count_max || model.price_min > model.price_max || model.time_min > model.time_max)
            {
                return(Result(ApiResultEnum.Parameter_Error, 0L));
            }

            HQItem hq    = HQService.Get(model.code);
            Order  order = new Order()
            {
                user_id  = user_id,
                unit_id  = model.unit_id,
                code     = model.code,
                price    = hq.Last,
                count    = model.count_total,
                type     = model.type,
                platform = platform
            };

            ApiResultEnum result = LimitBiz.CheckStatus(order);

            if (result != ApiResultEnum.Success)
            {
                return(Result(result, 0L));
            }
            result = LimitBiz.CheckUnit(order);
            if (result != ApiResultEnum.Success)
            {
                return(Result(result, 0L));
            }

            model.name     = StockInfoBiz.GetStock(model.code).name;
            model.id       = FuncHelper.GetUniqueID();
            model.user_id  = user_id;
            model.platform = platform;
            if (model.account_id > 0)
            {
                model.account_name = AccountRA.GetName(model.account_id);
            }
            else
            {
                model.account_name = "";
            }
            string key = "S_" + model.id + "_U_" + model.unit_id + "_D_0";

            OrderAutoRA.Add(model, key);
            return(Result(ApiResultEnum.Success, model.id));
        }