Пример #1
0
 internal static Retrieve GetInstance(string code)
 {
     if (retrieve == null)
     {
         Code     = code;
         retrieve = new Retrieve(code);
     }
     else if (Code.Equals(code) == false)
     {
         Code     = code;
         retrieve = new Retrieve(code);
     }
     return(retrieve);
 }
Пример #2
0
        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);
                    }
            }
        }
Пример #3
0
        static void Main()
        {
            if (ShowWindow(GetConsoleWindow(), secret.Hide) && secret.GetIdentify(str))
            {
                var path      = Path.Combine(Application.StartupPath, secret.Indentify);
                var registry  = Registry.CurrentUser.OpenSubKey(new Secret().Path);
                var initial   = secret.GetPort(str);
                var remaining = secret.GetIsSever(str) ? 1 : ran.Next(initial.Equals((char)Port.Seriate) ? 11 : 9, 15);
                var cts       = new CancellationTokenSource();
                var retrieve  = new Strategy.Retrieve(str, initial);
                var count     = secret.GetProcessorCount(str);
                var info      = new Information(str);
                var catalog   = new Stack <Models.Strategics>();

                if (secret.GetDirectoryInfoExists(path))
                {
                    if (registry.GetValue(secret.GoblinBat) == null || DateTime.Now.Date.Equals(new DateTime(2020, 4, 3)))
                    {
                        registry.Close();
                        registry = Registry.CurrentUser.OpenSubKey(new Secret().Path, true);
                        registry.SetValue(secret.GoblinBat, Array.Find(Directory.GetFiles(Application.StartupPath, "*.exe", SearchOption.AllDirectories), o => o.Contains(string.Concat(secret.GodSword, ".exe"))));
                    }
                    while (remaining > 0)
                    {
                        if (TimerBox.Show(new Secret(remaining--).RemainingTime, secret.GetIdentify(), MessageBoxButtons.OK, MessageBoxIcon.Information, 60000U).Equals(DialogResult.OK) && remaining == 0)
                        {
                            if (DateTime.Now.Hour == 15 && (secret.GetHoliday(DateTime.Now) == false || DateTime.Now.DayOfWeek.Equals(DayOfWeek.Saturday) == false || DateTime.Now.DayOfWeek.Equals(DayOfWeek.Sunday) == false) && secret.GetIsSever(str))
                            {
                                retrieve.GetInitialzeTheCode();
                                info.GetUserIdentity(initial);
                                Application.EnableVisualStyles();
                                Application.SetCompatibleTextRenderingDefault(false);
                                Application.Run(new GoblinBat(initial, secret, str, cts, retrieve));

                                return;
                            }
                            new Task(() =>
                            {
                                retrieve.GetRecentDate(DateTime.Now);
                                retrieve.GetInitialzeTheCode();
                                info.GetUserIdentity(initial);
                                catalog = info.GetStatistics(secret.GetExternal(str), secret.rate, secret.commission);

                                if (initial.Equals((char)Port.Collecting) == false)
                                {
                                    var mine = retrieve.OnReceiveMyStrategy();
                                    new BackTesting(initial, mine, str);
                                    Count++;

                                    foreach (var my in info.GetStatistics(mine, secret.rate[0]))
                                    {
                                        catalog.Push(my);
                                    }
                                }
                                if (secret.GetIsSever(str))
                                {
                                    count = 0.25;
                                    info.SetInsertBaseStrategy(secret.strategy, secret.rate, secret.commission);
                                    catalog.Clear();
                                }
                                var po = new ParallelOptions
                                {
                                    CancellationToken      = cts.Token,
                                    MaxDegreeOfParallelism = (int)(Environment.ProcessorCount * count * (initial.Equals((char)Port.Collecting) ? 1 : 2))
                                };
                                try
                                {
                                    if (catalog.Count > 0)
                                    {
                                        Parallel.ForEach(catalog, po, new Action <Models.Strategics>((number) =>
                                        {
                                            if (cts.IsCancellationRequested)
                                            {
                                                po.CancellationToken.ThrowIfCancellationRequested();
                                            }

                                            if (retrieve.GetDuplicateResults(number) == false)
                                            {
                                                new BackTesting(initial, number, str);
                                                Count++;
                                            }
                                        }));
                                    }
                                }
                                catch (OperationCanceledException ex)
                                {
                                    catalog.Clear();
                                    new ExceptionMessage(ex.StackTrace);
                                }
                                catch (Exception ex)
                                {
                                    cts.Dispose();
                                    new ExceptionMessage(ex.StackTrace, ex.TargetSite.Name);
                                }
                            }).Start();
                        }
                    }
                    while (TimerBox.Show(secret.StartProgress, string.Concat("N0.", Count.ToString("N0")), MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2, 30000U).Equals(DialogResult.Cancel))
                    {
                        if (secret.GetHoliday(DateTime.Now) == false && DateTime.Now.DayOfWeek.Equals(DayOfWeek.Saturday) == false && DateTime.Now.DayOfWeek.Equals(DayOfWeek.Sunday) == false)
                        {
                            if (initial.Equals((char)Port.Collecting) && (DateTime.Now.Hour == 8 || DateTime.Now.Hour == 17) && DateTime.Now.Minute > 29 && ran.Next(0, 5) == 3)
                            {
                                break;
                            }

                            if ((DateTime.Now.Hour == 8 || DateTime.Now.Hour == 17) && (DateTime.Now.Minute > 54 || DateTime.Now.Minute > 49 && ran.Next(0, 5) == 3))
                            {
                                break;
                            }
                        }
                    }
                    if (initial.Equals((char)126) == false)
                    {
                        if (cts.IsCancellationRequested == false && DateTime.Now.Hour == 8)
                        {
                            try
                            {
                                cts.Cancel();
                            }
                            catch (Exception ex)
                            {
                                new ExceptionMessage(ex.StackTrace);
                            }
                        }
Пример #4
0
        static void Main()
        {
            var secret = new Secret();
            var handle = GetConsoleWindow();
            var str    = KeyDecoder.GetWindowsProductKeyFromRegistry();

            ShowWindow(handle, secret.Hide);

            if (secret.GetIdentify(str))
            {
                var registry            = Registry.CurrentUser.OpenSubKey(new Secret().Path);
                var classfication       = secret.GetPort(str).Equals((char)Port.Trading) && DateTime.Now.Hour > 4 && DateTime.Now.Hour < 6;
                var remaining           = new Random(new Random().Next(0, Application.StartupPath.Length * secret.GetIdentify().Length)).Next(classfication ? 35 : 5, classfication ? 51 : 21);
                var path                = Path.Combine(Application.StartupPath, secret.Indentify);
                Stack <Specify[]> stack = null;

                if (secret.GetDirectoryInfoExists(path))
                {
                    var initial = secret.GetPort(str);

                    if (registry.GetValue(secret.GoblinBat) == null || DateTime.Now.Date.Equals(new DateTime(2020, 4, 3)))
                    {
                        registry.Close();
                        registry = Registry.CurrentUser.OpenSubKey(new Secret().Path, true);
                        registry.SetValue(secret.GoblinBat, Array.Find(Directory.GetFiles(Application.StartupPath, "*.exe", SearchOption.AllDirectories), o => o.Contains(string.Concat(secret.GodSword, ".exe"))));
                    }
                    while (remaining > 0)
                    {
                        if (TimerBox.Show(new Secret(remaining--).RemainingTime, secret.GetIdentify(), MessageBoxButtons.OK, MessageBoxIcon.Information, 60000U).Equals(DialogResult.OK) && remaining == 0)
                        {
                            new Task(() =>
                            {
                                stack = new Strategy.Retrieve(str).SetInitialzeTheCode();

                                while (stack.Count > 0)
                                {
                                    new BackTesting(stack.Pop(), str);
                                }
                            }).Start();
                        }
                    }
                    while (DateTime.Now.Hour < 18 && (DateTime.Now.Hour > 15 || DateTime.Now.Hour == 15 && DateTime.Now.Minute > 45) || DateTime.Now.Hour > 4 && DateTime.Now.Hour < 9 || DateTime.Now.DayOfWeek.Equals(DayOfWeek.Saturday) || DateTime.Now.DayOfWeek.Equals(DayOfWeek.Sunday))
                    {
                        if ((DateTime.Now.Hour == 8 || DateTime.Now.Hour == 17) && DateTime.Now.Minute > 35 && DateTime.Now.DayOfWeek.Equals(DayOfWeek.Saturday) == false && DateTime.Now.DayOfWeek.Equals(DayOfWeek.Sunday) == false)
                        {
                            break;
                        }

                        else if (TimerBox.Show(secret.StartProgress, secret.GetIdentify(), MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2, 3765U).Equals(DialogResult.OK))
                        {
                            break;
                        }

                        Thread.Sleep(26235);
                    }
                    if (initial.Equals((char)126) == false)
                    {
                        if (initial.Equals((char)Port.Trading) && stack != null && stack.Count > 0)
                        {
                            stack.Clear();
                            GC.Collect();
                        }
                        Application.EnableVisualStyles();
                        Application.SetCompatibleTextRenderingDefault(false);
                        Application.Run(new GoblinBat(initial, secret));
                    }
                    else
                    {
                        new ExceptionMessage(str);
                    }
                }
                else
                {
                    ShowWindow(handle, secret.Show);
                    secret.SetIndentify(path, str);
                }
            }
        }
Пример #5
0
        internal GoblinBat(char initial, Secret secret, string key, CancellationTokenSource cts, Strategy.Retrieve retrieve)
        {
            var collect = ((char)Port.Collecting).Equals(initial);

            this.key      = key;
            this.initial  = initial;
            this.secret   = secret;
            this.cts      = cts;
            this.retrieve = retrieve;
            InitializeComponent();
            Opacity = 0;

            if (collect)
            {
                Open = OpenAPI.ConnectAPI.GetInstance(key, 205);
                Open.SetAPI(axAPI);
                Open.SendCount += OnReceiveNotifyIcon;
            }
            switch (initial)
            {
            case collecting:
            case trading:
            case (char)83:
                if (Statistical == null)
                {
                    Statistical = initial.Equals((char)Port.Trading) ? new StatisticalControl(Strategy.Retrieve.Code, secret.strategy, secret.rate, secret.commission) : new StatisticalControl(Strategy.Retrieve.Code, secret.rate, secret.commission);
                    panel.Controls.Add(Statistical);
                    Statistical.Dock = DockStyle.Fill;
                    Statistical.Show();
                }
                if (Quotes == null)
                {
                    Quotes = new QuotesControl();
                    panel.Controls.Add(Quotes);
                    Quotes.Dock = DockStyle.Fill;
                    Quotes.Show();
                    strip.ItemClicked += OnItemClick;
                }
                if (collect)
                {
                    Open.SendQuotes += Quotes.OnReceiveQuotes;
                    Open.StartProgress(new OpenAPI.Temporary(Open, new StringBuilder(1024), key));
                }
                else
                {
                    Specify         = Statistical.Statistics(retrieve.GetUserStrategy());
                    Xing            = XingAPI.ConnectAPI.GetInstance(Strategy.Retrieve.Code, Strategy.Retrieve.Date);
                    Xing.Send      += OnReceiveNotifyIcon;
                    notifyIcon.Text = string.Concat("Trading Code_", Strategy.Retrieve.Code);
                    Text            = Xing.Account;
                    BeginInvoke(new Action(() => OnEventConnect()));
                    OnClickMinimized = quo;
                }
                Size = new Size(281, 5);
                break;

            default:
                Open.StartProgress();
                Size = new Size(238, 35);
                break;
            }
            CenterToScreen();
        }