public object CreateStrategy(object json) { var body = JsonConverter.Decode(json); var user_id = body["user_id"]; var strategy_name = body["strategy_name"]; var create_time = body["create_time"]; string strategy_hash = ""; using (var ctx = new quantEntities()) { var new_strategy = new strategy { user_id = user_id, strategy_name = strategy_name, create_time = create_time, strategy_hash = strategy_hash, }; ctx.strategy.Add(new_strategy); try { ctx.SaveChanges(); } catch (Exception e) { return(Helper.JsonConverter.Error(410, "新建策略时发生错误")); } var data = new { strategy_id = new_strategy.strategy_id }; return(Helper.JsonConverter.BuildResult(data)); } }
public object DeleteStrategy(int id) { using (var ctx = new quantEntities()) { ctx.Database.ExecuteSqlCommand("delete from backtest where strategy_id=@id", new MySqlParameter("@id", id)); strategy s = ctx.strategy.Find(id); if (s != null) { ctx.strategy.Remove(s); ctx.SaveChanges(); } } var data = new { id = id }; return(Helper.JsonConverter.BuildResult(data)); }
public static bool InitBot(string aInitStr) { if (!aInitStr.Contains(_botInitStartText)) { return(false); } // Getting strategy int rPos = aInitStr.IndexOf("-r"); string strategyStr = aInitStr.Substring(rPos + 3, aInitStr.IndexOf(" ", rPos) - rPos + 3); //Console.WriteLine(strategyStr); BotStrategy = (strategy)Enum.Parse(typeof(strategy), strategyStr); // Getting filename int fPos = aInitStr.IndexOf("-f"); _fileName = aInitStr.Substring(fPos + 3); Console.WriteLine(_fileName); if (!File.Exists(_fileName)) { return(false); } return(File.Exists(_fileName) && (new FileInfo(_fileName)).Length <= _maxFileSixe); }
foreach (var(strategy, runResult) in results)
public ExtentSwitch(Strategy strategy, IRoleType roleType) => this.strategyExtent = new StrategyExtentRole(strategy, roleType);
public ExtentSwitch(Strategy strategy, IAssociationType associationType) => this.strategyExtent = new StrategyExtentAssociation(strategy, associationType);
public context(strategy str) { this.str = str; }