コード例 #1
0
ファイル: UnitRA.cs プロジェクト: wshPrt/trading
        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
ファイル: OrderAutoRA.cs プロジェクト: wshPrt/trading
        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);
        }
コード例 #3
0
        public static Deal Get(string key)
        {
            Dictionary <string, string> dic = TradeRA.GetFields(key);

            return(new Deal()
            {
                code = dic["code"],
                name = dic["name"],
                money = decimal.Parse(dic["money"]),
                deal_no = dic["deal_no"],
                time_dt = DateTime.Parse(dic["time_dt"]),
                price = decimal.Parse(dic["price"]),
                count = int.Parse(dic["count"]),
                type = int.Parse(dic["type"]),
                order_no = dic["order_no"],
                unit_id = int.Parse(dic["unit_id"]),
                unit_name = dic["unit_name"],
                account_id = int.Parse(dic["account_id"]),
                account_name = dic["account_name"],
                commission = decimal.Parse(dic["commission"]),
                management_fee = decimal.Parse(dic["management_fee"]),
                transferred = int.Parse(dic["transferred"]),
                profit = decimal.Parse(dic["profit"])
            });
        }
コード例 #4
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);
        }
コード例 #5
0
ファイル: OrderRA.cs プロジェクト: wshPrt/trading
        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);
        }
コード例 #6
0
ファイル: PositionRA.cs プロジェクト: wshPrt/trading
        public static void UpdateTransfer(int from_unit, int to_unit, int from_account, int to_account, string code, int count, decimal price_latest)
        {
            string key_from = "P_" + code + "_A_" + from_account + "_U_" + from_unit;

            TradeRA.Increment(key_from, "count", -count);
            TradeRA.Increment(key_from, "count_sellable", -count);
            string key_to = "P_" + code + "_A_" + to_account + "_U_" + to_unit;

            if (TradeRA.KeyExists(key_to))
            {
                TradeRA.Increment(key_to, "count", count);

                TradeRA.Increment(key_to, "count_sellable", count);
            }
            else
            {
                Position position = Get(key_from);
                position.unit_id              = to_unit;
                position.account_id           = to_account;
                position.count                = position.count_sellable = count;
                position.price_cost_today_buy = position.price_cost_today_sell = 0;
                position.count_today_buy      = position.count_today_sell = 0;
                position.price_latest         = price_latest;
                Add(position, key_to);
            }
        }
コード例 #7
0
ファイル: PositionRA.cs プロジェクト: wshPrt/trading
        public static Position Get(string key)
        {
            Dictionary <string, string> dic = TradeRA.GetFields(key);

            if (dic.Count == 0)
            {
                return(null);
            }
            else
            {
                return new Position()
                       {
                           id                    = int.Parse(dic["id"]),
                           code                  = dic["code"],
                           name                  = dic["name"],
                           price_cost            = decimal.Parse(dic["price_cost"]),
                           count                 = int.Parse(dic["count"]),
                           count_sellable        = int.Parse(dic["count_sellable"]),
                           price_cost_today_buy  = decimal.Parse(dic["price_cost_today_buy"]),
                           price_cost_today_sell = decimal.Parse(dic["price_cost_today_sell"]),
                           count_today_buy       = int.Parse(dic["count_today_buy"]),
                           count_today_sell      = int.Parse(dic["count_today_sell"]),
                           unit_id               = int.Parse(dic["unit_id"]),
                           unit_name             = dic["unit_name"],
                           account_id            = int.Parse(dic["account_id"]),
                           account_name          = dic["account_name"],
                           price_latest          = decimal.Parse(dic["price_latest"]),
                           block                 = int.Parse(dic["block"])
                       }
            };
        }
コード例 #8
0
ファイル: OrderAutoRA.cs プロジェクト: wshPrt/trading
        public static OrderAuto Get(string key)
        {
            Dictionary <string, string> dic = TradeRA.GetFields(key);

            return(new OrderAuto()
            {
                id = long.Parse(dic["id"]),
                unit_id = int.Parse(dic["unit_id"]),
                user_id = int.Parse(dic["user_id"]),
                platform = int.Parse(dic["platform"]),
                account_id = int.Parse(dic["account_id"]),
                account_name = dic["account_name"],
                code = dic["code"],
                name = dic["name"],
                status = int.Parse(dic["status"]),
                type = int.Parse(dic["type"]),
                price_min = decimal.Parse(dic["price_min"]),
                price_max = decimal.Parse(dic["price_max"]),
                price_type = int.Parse(dic["price_type"]),
                count_min = int.Parse(dic["count_min"]),
                count_max = int.Parse(dic["count_max"]),
                count_total = int.Parse(dic["count_total"]),
                time_min = int.Parse(dic["time_min"]),
                time_max = int.Parse(dic["time_max"]),
                time_next_dt = DateTime.Parse(dic["time_next_dt"]),
                time_prev_dt = DateTime.Parse(dic["time_prev_dt"]),
                order_times = int.Parse(dic["order_times"]),
                order_count = int.Parse(dic["order_count"]),
                result_prev = dic["result_prev"],
                operator_start = dic["operator_start"],
                operator_stop = dic["operator_stop"]
            });
        }
コード例 #9
0
        public static Account Get(string key)
        {
            Dictionary <string, string> dic = TradeRA.GetFields(key);

            return(new Account()
            {
                id = int.Parse(dic["id"]),
                code = dic["code"],
                name = dic["name"],
                limit_no_buying = dic["limit_no_buying"],
                limit_ratio_single = decimal.Parse(dic["limit_ratio_single"]),
                limit_ratio_gem_single = decimal.Parse(dic["limit_ratio_gem_single"]),
                limit_ratio_gem_total = decimal.Parse(dic["limit_ratio_gem_total"]),
                ratio_capital_warning = decimal.Parse(dic["ratio_capital_warning"]),
                capital_initial = decimal.Parse(dic["capital_initial"]),
                status = int.Parse(dic["status"]),
                status_order = int.Parse(dic["status_order"]),
                created_by = int.Parse(dic["created_by"]),
                capital_available = decimal.Parse(dic["capital_available"]),
                capital_stock_value = decimal.Parse(dic["capital_stock_value"]),
                capital_stock_value_gem = decimal.Parse(dic["capital_stock_value_gem"]),
                capital_total = decimal.Parse(dic["capital_total"]),
                capital_profit = decimal.Parse(dic["capital_profit"]),
                synchronized_time = dic["synchronized_time"],
            });
        }
コード例 #10
0
ファイル: AccountGroupRA.cs プロジェクト: wshPrt/trading
 public static void Delete4AccountGroup(int account_group_id)
 {
     string[] keys = TradeRA.KeySearch("G_" + account_group_id + "_*");
     foreach (string key in keys)
     {
         TradeRA.Delete(key);
     }
 }
コード例 #11
0
ファイル: UnitRA.cs プロジェクト: wshPrt/trading
 public static void UpdateCapitalDealBuy(decimal delta, bool freezing, string key)
 {
     TradeRA.Increment(key, "capital_balance", -(float)delta);
     if (freezing)
     {
         TradeRA.Increment(key, "capital_freezing", -(float)delta);
     }
 }
コード例 #12
0
ファイル: OrderRA.cs プロジェクト: wshPrt/trading
        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);
        }
コード例 #13
0
        public static string GetName(int account_id)
        {
            if (account_id == 0)
            {
                return("");
            }

            return(TradeRA.Get("A_" + account_id, "name"));
        }
コード例 #14
0
ファイル: UnitRA.cs プロジェクト: wshPrt/trading
        public static string GetName(int unit_id)
        {
            if (unit_id == 0)
            {
                return("");
            }

            return(TradeRA.Get("U_" + unit_id, "name"));
        }
コード例 #15
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);
        }
コード例 #16
0
ファイル: OrderAutoRA.cs プロジェクト: wshPrt/trading
 public static bool Delete(OrderAutoUpdate model)
 {
     string[] keys = TradeRA.KeySearch("S_" + model.id + "_U_" + model.unit_id + "_*");
     if (keys.Length > 0)
     {
         return(TradeRA.Delete(keys[0]));
     }
     return(false);
 }
コード例 #17
0
ファイル: PositionRA.cs プロジェクト: wshPrt/trading
        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);
        }
コード例 #18
0
ファイル: PositionRA.cs プロジェクト: wshPrt/trading
        public static List <Position> List()
        {
            List <Position> list = new List <Position>();

            string[] keys = TradeRA.KeySearch("P_*");
            foreach (string key in keys)
            {
                list.Add(Get(key));
            }
            return(list);
        }
コード例 #19
0
ファイル: PositionRA.cs プロジェクト: wshPrt/trading
        public static List <Position> List4UnitCode(Position model)
        {
            List <Position> list = new List <Position>();

            string[] keys = TradeRA.KeySearch("P_" + model.code + "_A_*_U_" + model.unit_id);
            foreach (string key in keys)
            {
                list.Add(Get(key));
            }
            return(list);
        }
コード例 #20
0
ファイル: PositionRA.cs プロジェクト: wshPrt/trading
        public static List <Position> List4Account(int account_id)
        {
            List <Position> list = new List <Position>();

            string[] keys = TradeRA.KeySearch("P_*_A_" + account_id + "_U_*");
            foreach (string key in keys)
            {
                list.Add(Get(key));
            }
            return(list);
        }
コード例 #21
0
ファイル: PositionRA.cs プロジェクト: wshPrt/trading
        public static int GetSellable(int unit_id, string code)
        {
            int count_sellable = 0;

            string[] keys = TradeRA.KeySearch("P_" + code + "_A_*_U_" + unit_id);
            foreach (string key in keys)
            {
                count_sellable += TradeRA.GetInt(key, "count_sellable");
            }
            return(count_sellable);
        }
コード例 #22
0
ファイル: OrderRA.cs プロジェクト: wshPrt/trading
        public static IEnumerable <Order> List4Failed(Model.Search.SearchOrderStatus model)
        {
            List <Order> list = new List <Order>();

            string[] keys = TradeRA.KeySearch("O_*_F");
            foreach (string key in keys)
            {
                list.Add(Get(key));
            }
            return(list.Where(o => o.state_enum == model.status));
        }
コード例 #23
0
ファイル: OrderRA.cs プロジェクト: wshPrt/trading
        public static List <Order> List4Trade(string trade_no)
        {
            List <Order> list = new List <Order>();

            string[] keys = TradeRA.KeySearch("O_*_T_" + trade_no + "*");
            foreach (string key in keys)
            {
                list.Add(Get(key));
            }
            return(list);
        }
コード例 #24
0
ファイル: OrderAutoRA.cs プロジェクト: wshPrt/trading
        public static List <OrderAuto> List4Unit(int unit_id)
        {
            List <OrderAuto> list = new List <OrderAuto>();

            string[] keys = TradeRA.KeySearch("S_*_U_" + unit_id + "_D_*");
            foreach (string key in keys)
            {
                list.Add(Get(key));
            }
            return(list);
        }
コード例 #25
0
ファイル: PositionRA.cs プロジェクト: wshPrt/trading
        public static List <Position> List4Unit(int unit_id)
        {
            List <Position> list = new List <Position>();

            string[] keys = TradeRA.KeySearch("P_*_U_" + unit_id);
            foreach (string key in keys)
            {
                list.Add(Get(key));
            }
            return(list);
        }
コード例 #26
0
ファイル: AccountGroupRA.cs プロジェクト: wshPrt/trading
        public static List <AccountGroupItem> List4Unit(int unit_id)
        {
            List <AccountGroupItem> list = new List <AccountGroupItem>();

            string[] keys = TradeRA.KeySearch("G_*_U_" + unit_id + "_A_*");
            foreach (string key in keys)
            {
                list.Add(Get(key));
            }
            return(list);
        }
コード例 #27
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);
        }
コード例 #28
0
ファイル: OrderAutoRA.cs プロジェクト: wshPrt/trading
        public static List <OrderAuto> List4Undone()
        {
            List <OrderAuto> list = new List <OrderAuto>();

            string[] keys = TradeRA.KeySearch("S_*_D_0");
            foreach (string key in keys)
            {
                list.Add(Get(key));
            }
            return(list);
        }
コード例 #29
0
ファイル: OrderRA.cs プロジェクト: wshPrt/trading
        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);
        }
コード例 #30
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);
        }