예제 #1
0
        private int SetOptimize(IAsset asset, int repeat)
        {
            try
            {
                set = new StrategySetting
                {
                    ShortTick = SetValue(ran.Next(asset.ShortTickPeriod / 3, asset.ShortTickPeriod), ran.Next(15, 50), ran.Next(asset.ShortTickPeriod, asset.ShortTickPeriod * 5)),
                    LongTick  = SetValue(ran.Next(asset.LongTickPeriod / 3, asset.LongTickPeriod), ran.Next(30, 150), ran.Next(asset.LongTickPeriod, asset.LongTickPeriod * 5)),
                    ShortDay  = SetValue(2, ran.Next(1, 3), ran.Next(asset.ShortDayPeriod, asset.ShortDayPeriod * 3)),
                    LongDay   = SetValue(ran.Next(asset.LongDayPeriod / 3, asset.LongDayPeriod), ran.Next(1, 10), ran.Next(asset.LongDayPeriod, asset.LongDayPeriod * 3)),
                    Reaction  = SetValue(ran.Next(asset.Reaction / 3, asset.Reaction), ran.Next(1, 5), ran.Next(asset.Reaction, asset.Reaction * 2)),
                    Hedge     = SetValue(0, 1, ran.Next(0, 5)),
                    Capital   = asset.Assets
                };
                return(set.EstimatedTime());
            }
            catch (Exception ex)
            {
                new LogMessage().Record("Exception", ex.ToString());

                if (TimerBox.Show("Run the Program Again and Set it Manually.", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, 3157).Equals(DialogResult.OK))
                {
                    Application.Restart();
                }
            }
            finally
            {
                if (repeat % 5000 == 0 && TimerBox.Show("Run the Program Again and Set it Manually.", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, 3157).Equals(DialogResult.OK))
                {
                    Application.Restart();
                }
            }
            return(0);
        }
예제 #2
0
        private int SetOptimize(IAsset asset, AutomaticallySetting auto, int repeat)
        {
            try
            {
                set = new StrategySetting
                {
                    ShortTick = auto.SetVariableAutomatic(IAsset.Variable.ShortTick, asset.ShortTickPeriod, ran.Next(1, 21)),
                    LongTick  = auto.SetVariableAutomatic(IAsset.Variable.LongTick, asset.LongTickPeriod, ran.Next(1, 16)),
                    ShortDay  = auto.SetVariableAutomatic(IAsset.Variable.ShortDay, asset.ShortDayPeriod, ran.Next(1, 11)),
                    LongDay   = auto.SetVariableAutomatic(IAsset.Variable.LongDay, asset.LongDayPeriod, ran.Next(1, 11)),
                    Reaction  = auto.SetVariableAutomatic(IAsset.Variable.Reaction, asset.Reaction, ran.Next(1, 51)),
                    Hedge     = auto.SetVariableAutomatic(IAsset.Variable.Hedge, asset.Hedge, ran.Next(0, 6)),
                    Base      = auto.SetVariableAutomatic(IAsset.Variable.Base, asset.Base, ran.Next(0, 3)),
                    Sigma     = auto.SetVariableAutomatic(IAsset.Variable.Sigma, asset.Sigma, ran.Next(0, 2)),
                    Percent   = auto.SetVariableAutomatic(IAsset.Variable.Percent, asset.Percent, ran.Next(0, 2)),
                    Max       = auto.SetVariableAutomatic(IAsset.Variable.Max, asset.Max, ran.Next(0, 2)),
                    Quantity  = auto.SetVariableAutomatic(IAsset.Variable.Quantity, asset.Quantity, ran.Next(0, 2)),
                    Time      = auto.SetVariableAutomatic(IAsset.Variable.Time, asset.Time, ran.Next(0, 6)),
                    Capital   = asset.Assets
                };
                Estimate = set.EstimatedTime(new List <string>(64), CalculateTheRemainingTime() * count, true);

                if (repeat % 2500 == 0 && TimerBox.Show("Run the Program Again and Set it Manually.", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, 5157).Equals(DialogResult.OK))
                {
                    Application.ExitThread();
                    Application.Exit();
                }
                else if (repeat % 500 == 0 && TimerBox.Show("Do You Want to Use the Existing Settings?", "Question", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, 7519).Equals(DialogResult.OK))
                {
                    checkBox.Checked = true;
                    button.ForeColor = Color.Gold;
                    button.PerformClick();

                    return(int.MinValue);
                }
            }
            catch (Exception ex)
            {
                new LogMessage().Record("Exception", ex.ToString());

                if (TimerBox.Show("Run the Program Again and Set it Manually.", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, 5157).Equals(DialogResult.OK))
                {
                    Application.ExitThread();
                    Application.Exit();
                }
            }
            return(Estimate.Count);
        }
예제 #3
0
        private void CheckBoxCheckedChanged(object sender, EventArgs e)
        {
            if (!button.ForeColor.Equals(Color.Maroon))
            {
                if (button.ForeColor.Equals(Color.Ivory) && CheckCurrent)
                {
                    set = new StrategySetting
                    {
                        ShortTick = SetValue((int)numericPST.Value, (int)numericIST.Value, (int)numericDST.Value),
                        ShortDay  = SetValue((int)numericPSD.Value, (int)numericISD.Value, (int)numericDSD.Value),
                        LongTick  = SetValue((int)numericPLT.Value, (int)numericILT.Value, (int)numericDLT.Value),
                        LongDay   = SetValue((int)numericPLD.Value, (int)numericILD.Value, (int)numericDLD.Value),
                        Reaction  = SetValue((int)numericPR.Value, (int)numericIR.Value, (int)numericDR.Value),
                        Hedge     = SetValue((int)numericPH.Value, (int)numericIH.Value, (int)numericDH.Value),
                        Capital   = (long)numericCapital.Value
                    };
                    button.Text        = string.Concat("Estimated Back Testing Time is ", pro.Rate(set.EstimatedTime(), count).ToString("N0"), " Minutes.");
                    checkBox.Text      = "Reset";
                    checkBox.ForeColor = Color.Yellow;
                    button.ForeColor   = Color.Gold;

                    return;
                }
                button.Text        = string.Concat("Click to Recommend ", DateTime.Now.DayOfWeek.Equals(DayOfWeek.Friday) ? 2880 + 870 : 870, " Minutes and Save Existing Data.");
                button.ForeColor   = Color.Ivory;
                checkBox.ForeColor = Color.Ivory;
                checkBox.Text      = "Process";
            }
            else if (CheckCurrent == false)
            {
                checkBox.Text = string.Concat(pro.ProgressBarValue.ToString("N0"), " / ", Max.ToString("N0"));
                checkBox.Font = new Font(checkBox.Font.Name, 10.25F, FontStyle.Regular);

                if (TimerBox.Show(string.Concat("Currently\n", GC.GetTotalMemory(false).ToString("N0"), "bytes of Memory\nare in Use.\n\nDo You want to Clean Up the Accumulated Memory?"), "Notice", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, 1325).Equals(DialogResult.OK))
                {
                    GC.Collect();
                }
            }
            else if (CheckCurrent)
            {
                checkBox.Text = string.Concat("Parallel ", Process.GetCurrentProcess().Threads.Count - Count > 0 ? (Process.GetCurrentProcess().Threads.Count - Count).ToString("N0") : "End");
                checkBox.Font = new Font(checkBox.Font.Name, 15.75F, FontStyle.Regular);
            }
        }