public bool GetDuplicateResults(Models.Strategics game) { if (string.IsNullOrEmpty(RecentDate)) { GetRecentDate(DateTime.Now); } return(GetDuplicateResults(game, RecentDate)); }
public IEnumerable <Models.Strategics> GetStatistics(Models.Strategics strategy, double rate) { var list = new List <Models.Strategics>(); int i, ms, ml, bs, bl; if (strategy.Strategy.Length == 2 && int.TryParse(strategy.Strategy, out int st)) { for (i = st > 30 ? st - 10 : st - st % 20; i < (st < 90 ? st + 10 : st + 10 - st % 90); i++) { for (ms = strategy.MonoShort - 3 > minShort ? strategy.MonoShort - 3 : minShort; ms < (strategy.MonoShort + 3 > maxShort ? maxShort + 1 : strategy.MonoShort + 3); ms++) { for (ml = strategy.MonoLong / 5 - 3 > minLong / 5 ? strategy.MonoLong - 15 : minLong; ml < (strategy.MonoLong / 5 + 3 > maxLong / 5 ? maxLong + 1 : strategy.MonoLong + 15 + 1); ml += 5) { for (bs = strategy.BaseShort - 3 > minShort ? strategy.BaseShort - 3 : minShort; bs < (strategy.BaseShort + 3 > maxShort ? maxShort + 1 : strategy.BaseShort + 3); bs++) { for (bl = strategy.BaseLong / 5 - 3 > minLong / 5 ? strategy.BaseLong - 15 : minLong; bl < (strategy.BaseLong / 5 + 3 > maxLong / 5 ? maxLong + 1 : strategy.BaseLong + 15 + 1); bl += 5) { if (ms < ml && bs < bl) { list.Add(new Models.Strategics { Assets = strategy.Assets, Code = Retrieve.Code, Commission = strategy.Commission, MarginRate = rate, Strategy = i.ToString("D2"), RollOver = strategy.RollOver, BaseTime = 1440, BaseShort = bs, BaseLong = bl, NonaTime = strategy.NonaTime, NonaShort = strategy.NonaShort, NonaLong = strategy.NonaLong, OctaTime = strategy.OctaTime, OctaShort = strategy.OctaShort, OctaLong = strategy.OctaLong, HeptaTime = strategy.HeptaTime, HeptaShort = strategy.HeptaShort, HeptaLong = strategy.HeptaLong, HexaTime = strategy.HexaTime, HexaShort = strategy.HexaShort, HexaLong = strategy.HexaLong, PentaTime = strategy.PentaTime, PentaShort = strategy.PentaShort, PentaLong = strategy.PentaLong, QuadTime = strategy.QuadTime, QuadShort = strategy.QuadShort, QuadLong = strategy.QuadLong, TriTime = strategy.TriTime, TriShort = strategy.TriShort, TriLong = strategy.TriLong, DuoTime = strategy.DuoTime, DuoShort = strategy.DuoShort, DuoLong = strategy.DuoLong, MonoTime = 1, MonoShort = ms, MonoLong = ml }); } } } } } } } return(strategy.Strategy.Length == 2 ? list.Distinct() : list); }
public BackTesting(char verify, Models.Strategics game, string key) : base(key) { if (game.Strategy.Length == 2) { Charts = new Queue <Models.Charts>(128); } this.verify = verify.Equals((char)86); this.game = game; Residue = new Dictionary <uint, int>(); SellOrder = new Dictionary <string, uint>(); BuyOrder = new Dictionary <string, uint>(); Judge = new Dictionary <uint, double>(); TradingJudge = new Dictionary <uint, double>(); games = new Queue <Models.Strategics>(); Parallel.ForEach(Retrieve.GetCatalog(game), new Action <Catalog.XingAPI.Specify>((param) => { if (param.Time > 0) { if (param.Strategy.Length > 2) { switch (param.Strategy) { case basic: new Base(this, param); break; case bantam: new Bantam(this, param); break; case feather: new Feather(this, param); break; case fly: new Fly(this, param); break; case sFly: new SuperFly(this, param); break; case heavy: new Heavy(this, param); break; } } else { new Consecutive(this, param); } } })); if (this.verify) { statement = new Queue <Conclusion>(32); new Task(() => new ExceptionMessage(game)).Start(); } if (StartProgress(game.Strategy.Length) > 0) { using (var sw = new StreamWriter(new Secret().GetPath(game.Strategy, statement.Count), true)) try { while (statement.Count > 0) { var sb = new StringBuilder(); var str = statement.Dequeue(); if (str.Time.Contains(';')) { var split = str.Time.Split(';'); sb.Append(split[0]).Append(',').Append(split[1]).Append(',').Append(str.Division).Append(',').Append(str.Price).Append(',').Append(str.OrderNumber); } else { sb.Append(str.Time).Append(',').Append(str.Division).Append(',').Append(str.Price).Append(',').Append(str.OrderNumber); } sw.WriteLine(sb); } } catch (Exception ex) { new ExceptionMessage(ex.StackTrace); } } }
internal static Catalog.XingAPI.Specify[] GetCatalog(Models.Strategics find) { var temp = new Catalog.XingAPI.Specify[10]; int i = 0; while (i < temp.Length) { switch (i) { case 0: temp[i++] = new Catalog.XingAPI.Specify { Assets = (ulong)find.Assets, Code = find.Code, Commission = find.Commission, MarginRate = find.MarginRate, Strategy = find.Strategy, RollOver = find.RollOver, Time = (uint)find.BaseTime, Short = find.BaseShort, Long = find.BaseLong }; break; case 1: temp[i++] = new Catalog.XingAPI.Specify { Assets = (ulong)find.Assets, Code = find.Code, Commission = find.Commission, MarginRate = find.MarginRate, Strategy = find.Strategy, RollOver = find.RollOver, Time = (uint)find.NonaTime, Short = find.NonaShort, Long = find.NonaLong }; break; case 2: temp[i++] = new Catalog.XingAPI.Specify { Assets = (ulong)find.Assets, Code = find.Code, Commission = find.Commission, MarginRate = find.MarginRate, Strategy = find.Strategy, RollOver = find.RollOver, Time = (uint)find.OctaTime, Short = find.OctaShort, Long = find.OctaLong }; break; case 3: temp[i++] = new Catalog.XingAPI.Specify { Assets = (ulong)find.Assets, Code = find.Code, Commission = find.Commission, MarginRate = find.MarginRate, Strategy = find.Strategy, RollOver = find.RollOver, Time = (uint)find.HeptaTime, Short = find.HeptaShort, Long = find.HeptaLong }; break; case 4: temp[i++] = new Catalog.XingAPI.Specify { Assets = (ulong)find.Assets, Code = find.Code, Commission = find.Commission, MarginRate = find.MarginRate, Strategy = find.Strategy, RollOver = find.RollOver, Time = (uint)find.HexaTime, Short = find.HexaShort, Long = find.HexaLong }; break; case 5: temp[i++] = new Catalog.XingAPI.Specify { Assets = (ulong)find.Assets, Code = find.Code, Commission = find.Commission, MarginRate = find.MarginRate, Strategy = find.Strategy, RollOver = find.RollOver, Time = (uint)find.PentaTime, Short = find.PentaShort, Long = find.PentaLong }; break; case 6: temp[i++] = new Catalog.XingAPI.Specify { Assets = (ulong)find.Assets, Code = find.Code, Commission = find.Commission, MarginRate = find.MarginRate, Strategy = find.Strategy, RollOver = find.RollOver, Time = (uint)find.QuadTime, Short = find.QuadShort, Long = find.QuadLong }; break; case 7: temp[i++] = new Catalog.XingAPI.Specify { Assets = (ulong)find.Assets, Code = find.Code, Commission = find.Commission, MarginRate = find.MarginRate, Strategy = find.Strategy, RollOver = find.RollOver, Time = (uint)find.TriTime, Short = find.TriShort, Long = find.TriLong }; break; case 8: temp[i++] = new Catalog.XingAPI.Specify { Assets = (ulong)find.Assets, Code = find.Code, Commission = find.Commission, MarginRate = find.MarginRate, Strategy = find.Strategy, RollOver = find.RollOver, Time = (uint)find.DuoTime, Short = find.DuoShort, Long = find.DuoLong }; break; case 9: temp[i++] = new Catalog.XingAPI.Specify { Assets = (ulong)find.Assets, Code = find.Code, Commission = find.Commission, MarginRate = find.MarginRate, Strategy = find.Strategy, RollOver = find.RollOver, Time = (uint)find.MonoTime, Short = find.MonoShort, Long = find.MonoLong }; break; } } return(temp); }
public Catalog.XingAPI.Specify[] GetUserStrategy() { var game = new Models.Strategics(); var recommend = GetBestStrategyRecommend(Information.Statistics, game); var rank = secret.GetRank(recommend.Item3); if (recommend.Item5 == null || TimerBox.Show(secret.GetMessage(recommend.Item4, recommend.Item1, recommend.Item4 / (double)recommend.Item1), rank, MessageBoxButtons.YesNo, MessageBoxIcon.Question, 0 > recommend.Item4 ? MessageBoxDefaultButton.Button1 : MessageBoxDefaultButton.Button2, 13975U).Equals(DialogResult.Yes)) { game = recommend.Item2; } else if (recommend.Item1 == int.MinValue) { var user = GetUserStrategics(); if (user != null) { return(GetCatalog(user)); } else { GetUserStrategy(); } } else { game = recommend.Item5; } new Task(() => new ExceptionMessage(game, rank)).Start(); SetIdentify(new Models.Identify { Assets = game.Assets, Strategy = game.Strategy, Commission = game.Commission, RollOver = game.RollOver ? CheckState.Checked : CheckState.Unchecked, Code = game.Code, BaseShort = game.BaseShort, BaseLong = game.BaseLong, NonaTime = game.NonaTime, NonaShort = game.NonaShort, NonaLong = game.NonaLong, OctaTime = game.OctaTime, OctaShort = game.OctaShort, OctaLong = game.OctaLong, HeptaTime = game.HeptaTime, HeptaShort = game.HeptaShort, HeptaLong = game.HeptaLong, HexaTime = game.HexaTime, HexaShort = game.HexaShort, HexaLong = game.HexaLong, PentaTime = game.PentaTime, PentaShort = game.PentaShort, PentaLong = game.PentaLong, QuadTime = game.QuadTime, QuadShort = game.QuadShort, QuadLong = game.QuadLong, TriTime = game.TriTime, TriShort = game.TriShort, TriLong = game.TriLong, DuoTime = game.DuoTime, DuoShort = game.DuoShort, DuoLong = game.DuoLong, MonoTime = game.MonoTime, MonoShort = game.MonoShort, MonoLong = game.MonoLong }); return(GetCatalog(game)); }