Пример #1
0
        public static void Update(Unit unit, string key)
        {
            Dictionary <string, string> items = new Dictionary <string, string>();

            items.Add("code", unit.code);
            items.Add("name", unit.name);
            items.Add("account_group_id", unit.account_group_id.ToString());
            items.Add("ratio_management_fee", unit.ratio_management_fee.ToString());
            items.Add("ratio_commission", unit.ratio_commission.ToString());
            items.Add("ratio_software_fee", unit.ratio_software_fee.ToString());
            items.Add("limit_stock_count", unit.limit_stock_count.ToString());
            items.Add("limit_ratio_mbm_single", unit.limit_ratio_mbm_single.ToString());
            items.Add("limit_ratio_gem_single", unit.limit_ratio_gem_single.ToString());
            items.Add("limit_ratio_gem_total", unit.limit_ratio_gem_total.ToString());
            items.Add("limit_ratio_sme_single", unit.limit_ratio_sme_single.ToString());
            items.Add("limit_ratio_sme_total", unit.limit_ratio_sme_total.ToString());
            items.Add("limit_ratio_smg_total", unit.limit_ratio_smg_total.ToString());
            items.Add("limit_ratio_star_single", unit.limit_ratio_star_single.ToString());
            items.Add("limit_ratio_star_total", unit.limit_ratio_star_total.ToString());
            items.Add("ratio_warning", unit.ratio_warning.ToString());
            items.Add("ratio_close_position", unit.ratio_close_position.ToString());
            items.Add("limit_no_buying", unit.limit_no_buying);
            items.Add("limit_order_price", unit.limit_order_price.ToString());
            TradeRA.SetFields(key, items);
        }
Пример #2
0
        public static void Add(Account account, string key)
        {
            Dictionary <string, string> items = new Dictionary <string, string>();

            items.Add("id", account.id.ToString());
            items.Add("code", account.code);
            items.Add("name", account.name);
            items.Add("limit_no_buying", account.limit_no_buying);
            items.Add("limit_ratio_single", account.limit_ratio_single.ToString());
            items.Add("limit_ratio_gem_single", account.limit_ratio_gem_single.ToString());
            items.Add("limit_ratio_gem_total", account.limit_ratio_gem_total.ToString());
            items.Add("ratio_capital_warning", account.ratio_capital_warning.ToString());
            items.Add("capital_initial", account.capital_initial.ToString());
            items.Add("status", account.status.ToString());
            items.Add("status_order", account.status_order.ToString());
            items.Add("created_by", account.created_by.ToString());
            items.Add("capital_available", account.capital_available.ToString());
            items.Add("capital_stock_value", account.capital_stock_value.ToString());
            items.Add("capital_stock_value_gem", account.capital_stock_value_gem.ToString());
            items.Add("capital_total", account.capital_total.ToString());
            items.Add("capital_profit", account.capital_profit.ToString());
            items.Add("synchronized_time", account.synchronized_time ?? "");
            TradeRA.SetFields(key, items);
            TradeRA.SetExpire(key);
        }
Пример #3
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);
        }
Пример #4
0
        public static void Add(Order order, string key)
        {
            Dictionary <string, string> items = new Dictionary <string, string>();

            items.Add("trade_no", order.trade_no);
            items.Add("trade_count", order.trade_count.ToString());
            items.Add("code", order.code);
            items.Add("name", order.name);
            items.Add("price", order.price.ToString());
            items.Add("count", order.count.ToString());
            items.Add("type", order.type.ToString());
            items.Add("unit_id", order.unit_id.ToString());
            items.Add("unit_name", order.unit_name ?? UnitRA.GetName(order.unit_id));
            items.Add("user_id", order.user_id.ToString());
            items.Add("user_name", order.user_name ?? UserRA.Get(order.user_id.ToString(), "name"));
            items.Add("platform", order.platform.ToString());
            items.Add("deal_count", order.deal_count.ToString());
            items.Add("deal_average_price", order.deal_average_price.ToString());
            items.Add("cancel_count", "0");
            items.Add("status", order.status ?? "");
            items.Add("state", order.state.ToString());
            items.Add("time_dt", order.time_dt.Format());
            items.Add("account_id", order.account_id.ToString());
            items.Add("account_name", order.account_name ?? AccountRA.GetName(order.account_id));
            items.Add("order_no", order.order_no ?? "");
            items.Add("remark", order.remark ?? "");
            TradeRA.SetFields(key, items);
            TradeRA.SetExpire(key);
        }
Пример #5
0
        public static void UpdateStatus(Order order, string key)
        {
            Dictionary <string, string> items = new Dictionary <string, string>();

            items.Add("deal_count", order.deal_count.ToString());
            items.Add("cancel_count", order.cancel_count.ToString());
            items.Add("status", order.status);
            TradeRA.SetFields(key, items);
        }
Пример #6
0
        public static void UpdateFee(Deal deal, string key)
        {
            Dictionary <string, string> items = new Dictionary <string, string>();

            items.Add("commission", deal.commission.ToString());
            items.Add("management_fee", deal.management_fee.ToString());
            items.Add("profit", deal.profit.ToString());
            TradeRA.SetFields(key, items);
        }
Пример #7
0
        public static void UpdateBuy(Position position, string key)
        {
            Dictionary <string, string> items = new Dictionary <string, string>();

            items.Add("price_cost", position.price_cost.ToString());
            items.Add("count", position.count.ToString());
            items.Add("price_cost_today_buy", position.price_cost_today_buy.ToString());
            items.Add("count_today_buy", position.count_today_buy.ToString());
            TradeRA.SetFields(key, items);
        }
Пример #8
0
        public static void UpdateCapital(Account account, string key)
        {
            Dictionary <string, string> items = new Dictionary <string, string>();

            items.Add("capital_available", account.capital_available.ToString());
            items.Add("capital_stock_value", account.capital_stock_value.ToString());
            items.Add("capital_total", account.capital_total.ToString());
            items.Add("capital_profit", account.capital_profit.ToString());
            items.Add("synchronized_time", account.synchronized_time);
            TradeRA.SetFields(key, items);
        }
Пример #9
0
        public static void UpdateNew(Order order, string key)
        {
            Dictionary <string, string> items = new Dictionary <string, string>();

            items.Add("name", order.name);
            items.Add("deal_count", order.deal_count.ToString());
            items.Add("cancel_count", order.cancel_count.ToString());
            items.Add("status", order.status);
            items.Add("time_dt", order.time_dt.Format());
            TradeRA.SetFields(key, items);
        }
Пример #10
0
        public static void UpdateOrderSuccess(string key, int unit_id, string trade_no, string order_no)
        {
            string key_new = "O_" + order_no + "_T_" + trade_no + "_U_" + unit_id;

            TradeRA.KeyRename(key, key_new);

            Dictionary <string, string> items = new Dictionary <string, string>();

            items.Add("order_no", order_no);
            items.Add("state", "1");
            items.Add("result_time", DateTime.Now.Format());
            TradeRA.SetFields(key_new, items);
        }
Пример #11
0
        public static void UpdateCapitalStockValue(decimal value, string key)
        {
            if (!TradeRA.KeyExists(key))
            {
                return;
            }

            Dictionary <string, string> items = new Dictionary <string, string>();

            items.Add("capital_stock_value_gem", value.ToString());
            items.Add("calculated_time", DateTime.Now.Format());
            TradeRA.SetFields(key, items);
        }
Пример #12
0
        public static void UpdateCapitalStockValue(decimal[] values, string key)
        {
            Dictionary <string, string> items = new Dictionary <string, string>();

            items.Add("capital_stock_value_mbm", values[0].ToString());
            items.Add("capital_stock_value_star", values[1].ToString());
            items.Add("capital_stock_value_gem", values[2].ToString());
            items.Add("capital_stock_value_sme", values[3].ToString());
            items.Add("capital_stock_value", values[4].ToString());
            items.Add("capital_profit", values[5].ToString());
            items.Add("calculated_time", DateTime.Now.Format());
            TradeRA.SetFields(key, items);
        }
Пример #13
0
        public static void UpdateCapitalStockValue(string ua, decimal value)
        {
            List <AccountGroupItem> list = new List <AccountGroupItem>();

            string[] keys = TradeRA.KeySearch("G_*_" + ua);

            if (keys.Length > 0)
            {
                Dictionary <string, string> items = new Dictionary <string, string>();
                items.Add("capital_stock_value", value.ToString());
                items.Add("calculated_time", DateTime.Now.Format());
                TradeRA.SetFields(keys[0], items);
            }
        }
Пример #14
0
        private static void AddItems(OrderAuto order_auto, Order order)
        {
            Dictionary <string, string> items = new Dictionary <string, string>();

            items.Add("id", order_auto.order_times.ToString());
            items.Add("time", order_auto.time_prev_dt.Format());
            items.Add("price", order.price.ToString());
            items.Add("count", order.count.ToString());
            items.Add("result", order_auto.result_prev);
            string key = "T_" + order_auto.id + "_" + order_auto.order_times.ToString().PadLeft(3, '0');

            TradeRA.SetFields(key, items);
            TradeRA.SetExpire(key);
        }
Пример #15
0
        public static void Add(AccountGroupItem item, string key)
        {
            Dictionary <string, string> items = new Dictionary <string, string>();

            items.Add("account_group_id", item.account_group_id.ToString());
            items.Add("account_id", item.account_id.ToString());
            items.Add("capital_allow", item.capital_allow.ToString());
            items.Add("sort_buy", item.sort_buy.ToString());
            items.Add("sort_sell", item.sort_sell.ToString());
            items.Add("unit_id", item.unit_id.ToString());
            items.Add("capital_stock_value", item.capital_stock_value.ToString());
            TradeRA.SetFields(key, items);
            TradeRA.SetExpire(key);
        }
Пример #16
0
        public static void Update(Account account, string key)
        {
            Dictionary <string, string> items = new Dictionary <string, string>();

            items.Add("code", account.code);
            items.Add("name", account.name);
            items.Add("limit_no_buying", account.limit_no_buying);
            items.Add("limit_ratio_single", account.limit_ratio_single.ToString());
            items.Add("limit_ratio_gem_single", account.limit_ratio_gem_single.ToString());
            items.Add("limit_ratio_gem_total", account.limit_ratio_gem_total.ToString());
            items.Add("ratio_capital_warning", account.ratio_capital_warning.ToString());
            items.Add("capital_initial", account.capital_initial.ToString());
            TradeRA.SetFields(key, items);
        }
Пример #17
0
        public static void UpdateOrderFailed(string key, string remark)
        {
            Dictionary <string, string> items = new Dictionary <string, string>();

            if (string.IsNullOrWhiteSpace(remark))
            {
                items.Add("state", "3");
            }
            else
            {
                items.Add("state", "2");
                items.Add("remark", remark);
            }
            items.Add("result_time", DateTime.Now.Format());
            TradeRA.SetFields(key, items);
        }
Пример #18
0
        public static void UpdateExecuted(OrderAuto order_auto, Order order, string key)
        {
            Dictionary <string, string> items = new Dictionary <string, string>();

            items.Add("time_next_dt", order_auto.time_next_dt.Format());
            items.Add("time_prev_dt", order_auto.time_prev_dt.Format());
            items.Add("order_times", order_auto.order_times.ToString());
            items.Add("order_count", order_auto.order_count.ToString());
            items.Add("result_prev", order_auto.result_prev);
            TradeRA.SetFields(key, items);
            AddItems(order_auto, order);

            if (order_auto.order_count == order_auto.count_total)
            {
                UpdateStatus(StatusAutoOrderEnum.Done, 1, key);
            }
        }
Пример #19
0
 public static bool Update(OrderAutoUpdate order)
 {
     string[] keys = TradeRA.KeySearch("S_" + order.id + "_*_D_0");
     if (keys.Length > 0)
     {
         Dictionary <string, string> items = new Dictionary <string, string>();
         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("time_min", order.time_min.ToString());
         items.Add("time_max", order.time_max.ToString());
         TradeRA.SetFields(keys[0], items);
         return(true);
     }
     return(false);
 }
Пример #20
0
        public static void Add(Unit unit, string key)
        {
            Dictionary <string, string> items = new Dictionary <string, string>();

            items.Add("id", unit.id.ToString());
            items.Add("code", unit.code);
            items.Add("name", unit.name);
            items.Add("user_id", unit.user_id.ToString());
            items.Add("account_group_id", unit.account_group_id.ToString());
            items.Add("capital_scale", unit.capital_scale.ToString());
            items.Add("ratio_freezing", unit.ratio_freezing.ToString());
            items.Add("ratio_management_fee", unit.ratio_management_fee.ToString());
            items.Add("ratio_commission", unit.ratio_commission.ToString());
            items.Add("ratio_software_fee", unit.ratio_software_fee.ToString());
            items.Add("limit_stock_count", unit.limit_stock_count.ToString());
            items.Add("limit_ratio_mbm_single", unit.limit_ratio_mbm_single.ToString());
            items.Add("limit_ratio_gem_single", unit.limit_ratio_gem_single.ToString());
            items.Add("limit_ratio_gem_total", unit.limit_ratio_gem_total.ToString());
            items.Add("limit_ratio_sme_single", unit.limit_ratio_sme_single.ToString());
            items.Add("limit_ratio_sme_total", unit.limit_ratio_sme_total.ToString());
            items.Add("limit_ratio_smg_total", unit.limit_ratio_smg_total.ToString());
            items.Add("limit_ratio_star_single", unit.limit_ratio_star_single.ToString());
            items.Add("limit_ratio_star_total", unit.limit_ratio_star_total.ToString());
            items.Add("ratio_warning", unit.ratio_warning.ToString());
            items.Add("ratio_close_position", unit.ratio_close_position.ToString());
            items.Add("limit_no_buying", unit.limit_no_buying);
            items.Add("limit_order_price", unit.limit_order_price.ToString());
            items.Add("status", unit.status.ToString());
            items.Add("status_order", unit.status_order.ToString());
            items.Add("capital_balance", unit.capital_balance.ToString());
            items.Add("priority_strategy", unit.priority_strategy.ToString());
            items.Add("capital_freezing", "0");
            items.Add("capital_inout", "0");
            items.Add("capital_stock_value", unit.capital_stock_value.ToString());
            items.Add("capital_stock_value_mbm", unit.capital_stock_value_mbm.ToString());
            items.Add("capital_stock_value_star", unit.capital_stock_value_star.ToString());
            items.Add("capital_stock_value_gem", unit.capital_stock_value_gem.ToString());
            items.Add("capital_stock_value_sme", unit.capital_stock_value_sme.ToString());
            items.Add("capital_profit", unit.capital_profit.ToString());
            TradeRA.SetFields(key, items);
            TradeRA.SetExpire(key);
        }
Пример #21
0
        public static void UpdateStatus(StatusAutoOrderEnum status, int user_id, string key)
        {
            Dictionary <string, string> items = new Dictionary <string, string>();

            items.Add("status", ((int)status).ToString());
            if (status == StatusAutoOrderEnum.Run)
            {
                items.Add("operator_start", UserRA.Get(user_id.ToString(), "name"));
            }
            else if (status == StatusAutoOrderEnum.Pause)
            {
                items.Add("operator_stop", UserRA.Get(user_id.ToString(), "name"));
            }
            TradeRA.SetFields(key, items);

            if (status == StatusAutoOrderEnum.Done || status == StatusAutoOrderEnum.Stop)
            {
                TradeRA.KeyRename(key, (key.Substring(0, key.Length - 1) + "1"));
            }
        }
Пример #22
0
        public static void Add(Position position, string key)
        {
            Dictionary <string, string> items = new Dictionary <string, string>();

            items.Add("id", position.id.ToString());
            items.Add("code", position.code);
            items.Add("name", position.name);
            items.Add("price_cost", position.price_cost.ToString());
            items.Add("count", position.count.ToString());
            items.Add("count_sellable", position.count_sellable.ToString());
            items.Add("price_cost_today_buy", position.price_cost_today_buy.ToString());
            items.Add("price_cost_today_sell", position.price_cost_today_sell.ToString());
            items.Add("count_today_buy", position.count_today_buy.ToString());
            items.Add("count_today_sell", position.count_today_sell.ToString());
            items.Add("unit_id", position.unit_id.ToString());
            items.Add("unit_name", position.unit_name ?? UnitRA.GetName(position.unit_id));
            items.Add("account_id", position.account_id.ToString());
            items.Add("account_name", position.account_name ?? AccountRA.GetName(position.account_id));
            items.Add("price_latest", position.price_latest.ToString());
            items.Add("block", position.block.ToString());
            TradeRA.SetFields(key, items);
            TradeRA.SetExpire(key);
        }
Пример #23
0
        public static void Add(Deal deal, string key)
        {
            Dictionary <string, string> items = new Dictionary <string, string>();

            items.Add("code", deal.code);
            items.Add("name", deal.name);
            items.Add("type", deal.type.ToString());
            items.Add("count", deal.count.ToString());
            items.Add("money", deal.money.ToString());
            items.Add("time_dt", deal.time_dt.Format());
            items.Add("deal_no", deal.deal_no);
            items.Add("order_no", deal.order_no);
            items.Add("price", deal.price.ToString());
            items.Add("unit_id", deal.unit_id.ToString());
            items.Add("unit_name", deal.unit_name ?? UnitRA.GetName(deal.unit_id));
            items.Add("account_id", deal.account_id.ToString());
            items.Add("account_name", deal.account_name ?? AccountRA.GetName(deal.account_id));
            items.Add("commission", deal.commission.ToString());
            items.Add("management_fee", deal.management_fee.ToString());
            items.Add("transferred", deal.transferred.ToString());
            items.Add("profit", deal.profit.ToString());
            TradeRA.SetFields(key, items);
            TradeRA.SetExpire(key);
        }