Exemplo n.º 1
0
        public void ShouldReturnStrictMockOfCorrectType()
        {
            Interaction i    = new Interaction();
            object      mock = i.CreateStrictMock <StrictMockSpec>();

            Specify.That(mock.GetType().FullName).ShouldEqual("NBehave.Spec.Framework.Specification.Mocks.__Proxy__StrictMockSpec");
        }
Exemplo n.º 2
0
        public void ShouldCreateStrictInstanceOfInterfaceWithDefaultCtor()
        {
            Interaction i       = new Interaction();
            IMockable   fooMock = i.CreateStrictMock <IMockable>();

            Specify.That(fooMock).ShouldNotBeNull();
        }
Exemplo n.º 3
0
        public void ShouldCreateStrictInstanceOfAbstractType()
        {
            Interaction  i           = new Interaction();
            MockableBase fooBaseMock = i.CreateStrictMock <MockableBase>();

            Specify.That(fooBaseMock).ShouldNotBeNull();
        }
Exemplo n.º 4
0
        protected internal ReBalancing(Specify specify) : base(specify)
        {
            foreach (var quotes in Retrieve.Quotes)
            {
                if (quotes.Price != null && quotes.Volume != null && long.TryParse(quotes.Time, out long time) && double.TryParse(quotes.Price, out double price) && int.TryParse(quotes.Volume, out int volume))
                {
                    Analysize(new Catalog.Chart
                    {
                        Date   = time,
                        Price  = price,
                        Volume = volume
                    });
                }
            }
            if (specify.Time == 1440)
            {
                OnTime = true;
            }

            else
            {
                Check = string.Empty;
            }

            ((Catalog.IEvents <Datum>)API.reals[1]).Send += Analysize;
        }
Exemplo n.º 5
0
        public void ShouldReturnStrictMockWhenSupplyingCtorArgs()
        {
            Interaction    i    = new Interaction();
            StrictMockSpec mock = i.CreateStrictMock <StrictMockSpec>(5, "Test");

            Specify.That(mock.i).ShouldEqual(5);
            Specify.That(mock.s).ShouldEqual("Test");
            Specify.That(mock.GetType().FullName).ShouldEqual("NBehave.Spec.Framework.Specification.Mocks.__Proxy__StrictMockSpec");
        }
Exemplo n.º 6
0
        protected bool GetRecentAnalysis(Specify s)
        {
            var date = DateTime.Now.Hour < 5 && DateTime.Now.Hour >= 0 ? DateTime.Now.AddDays(-1).ToString("yyMMdd") : DateTime.Now.ToString("yyMMdd");

            using (var db = new GoblinBatDbContext())
            {
                return(db.Logs.Any(o => o.Date.ToString().Equals(date) && o.Code.Equals(s.Code) && o.Assets.Equals(s.Assets) && o.Strategy.Equals(s.Strategy) && o.Time.Equals(s.Time) && o.Short.Equals(s.Short) && o.Long.Equals(s.Long)));
            }
        }
Exemplo n.º 7
0
 public Quotes(Specify specify, ConnectXingAPI api)
 {
     this.specify         = specify;
     this.api             = api;
     strategy             = specify.Strategy.Equals("TF");
     api.OnReceiveBalance = false;
     api.SendQuotes      += OnReceiveQuotes;
     api.WindingClass     = string.Empty;
 }
Exemplo n.º 8
0
        public void ShouldThrowExceptionWhenNoMatchingConstructorCanBeFoundForStrictMock()
        {
            MethodThatThrows mtt = delegate()
            {
                Interaction  i       = new Interaction();
                MockableBase fooBase = i.CreateStrictMock <MockableBase>(1, 2, 3);
            };

            Specify.ThrownBy(mtt).ShouldBeOfType(typeof(NoMatchingConstructorException));
        }
Exemplo n.º 9
0
        protected internal TF(Specify specify)
        {
            this.specify = specify;
            Short        = new Stack <double>(512);
            Long         = new Stack <double>(512);

            foreach (Catalog.Chart chart in Retrieve.Chart)
            {
                Analysize(chart);
            }
        }
Exemplo n.º 10
0
        public Analysize(Specify specify)
        {
            this.specify = specify;
            Short        = new Stack <double>(512);
            Long         = new Stack <double>(512);

            foreach (Chart chart in Retrieve.GetInstance(specify.Code).Chart)
            {
                Analysis(chart);
            }
        }
Exemplo n.º 11
0
        protected Stack <double> GetBasicChart(string check, DateTime now, Specify specify, int period, Stack <double> stack)
        {
            if (specify.Time == 1440)
            {
                try
                {
                    for (int i = 0; i > int.MinValue; i--)
                    {
                        var date = i == 0 ? now.ToString(format) : now.AddDays(i).ToString(format);
                        int time;

                        if (check.Equals(date))
                        {
                            using (var db = new GoblinBatDbContext(key))
                            {
                                switch (now.Hour)
                                {
                                case 6:
                                case 7:
                                case 8:
                                    time = db.Charts.Any(o => o.Time == 660) ? 660 : 405;
                                    break;

                                case 16:
                                case 17:
                                    time = 405;
                                    break;

                                default:
                                    return(stack);
                                }
                                var call = db.Charts.Where(o => o.Code.Equals(specify.Code) && o.Time == time && o.Base == period).AsNoTracking();

                                if (call.Any(o => o.Date.Equals(check)))
                                {
                                    foreach (var e in call.OrderByDescending(o => o.Date).Take(period + 1).Select(o => new { o.Value, o.Date }).OrderBy(o => o.Date))
                                    {
                                        stack.Push(e.Value);
                                    }

                                    return(stack);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    new ExceptionMessage(ex.StackTrace, specify.Code);
                }
            }
            return(null);
        }
Exemplo n.º 12
0
        protected bool GetRecentAnalysis(Specify s)
        {
            var date = DateTime.Now.Hour < 5 && DateTime.Now.Hour >= 0 ? DateTime.Now.AddDays(-1).ToString(CallUpGoblinBat.date) : DateTime.Now.ToString(CallUpGoblinBat.date);

            try
            {
                using (var db = new GoblinBatDbContext(key))
                    return(db.Logs.Any(o => o.Date.ToString().Equals(date) && o.Code.Equals(s.Code) && o.Assets.Equals(s.Assets) && o.Strategy.Equals(s.Strategy) && o.Date.Equals(s.Time)));
            }
            catch (Exception ex)
            {
                new ExceptionMessage(ex.StackTrace, s.Code);
            }
            return(false);
        }
Exemplo n.º 13
0
        public Trading(ConnectXingAPI api, Specify specify, Queue <Chart> charts)
        {
            this.specify = specify;
            Short        = new Stack <double>(512);
            Long         = new Stack <double>(512);
            SendDatum   += Analysize;

            foreach (Chart chart in charts)
            {
                SendDatum?.Invoke(this, new Datum(chart));
            }

            SendDatum     -= Analysize;
            this.api       = api;
            OnTime         = true;
            api.SendDatum += Analysize;
        }
Exemplo n.º 14
0
        public Trading(ConnectXingAPI api, Specify specify, Quotes quotes, Queue <Chart> charts)
        {
            this.specify = specify;
            Short        = new Stack <double>(512);
            Long         = new Stack <double>(512);
            SendDatum   += Analysize;

            foreach (Chart chart in charts)
            {
                SendDatum?.Invoke(this, new Datum(chart));
            }

            SendDatum     -= Analysize;
            this.api       = api;
            this.quotes    = quotes;
            Check          = string.Empty;
            api.SendDatum += Analysize;
        }
Exemplo n.º 15
0
        public Specify[] Statistics(string code)
        {
            var commission = string.IsNullOrEmpty(emptyCommission.Text) == false && double.TryParse(emptyCommission.Text, out double ec) ? (ec / 100) : 3e-5;
            var temp       = new Specify[5];

            for (int i = 0; i < temp.Length; i++)
            {
                temp[i] = new Specify
                {
                    Assets     = (ulong)numericAssets.Value,
                    Code       = string.IsNullOrEmpty(emptyCode.Text) ? code : emptyCode.Text,
                    Commission = commission,
                    Strategy   = strategy.Text,
                    RollOver   = checkRollOver.Checked,
                    Time       = i == 4 && uint.TryParse(emptyNum.Text.Replace(",", string.Empty), out uint time) ? time : (uint)string.Concat("numeric", i).FindByName <NumericUpDown>(this).Value,
                    Short      = (int)string.Concat("numeric", i + 10).FindByName <NumericUpDown>(this).Value,
                    Long       = (int)string.Concat("numeric", i + 20).FindByName <NumericUpDown>(this).Value
                }
            }
            ;
            return(temp);
        }
Exemplo n.º 16
0
 public void CompareOneWithTwo()
 {
     Specify.That(1).ShouldEqual(2);
 }
Exemplo n.º 17
0
        protected internal TF(Specify specify) : base(KeyDecoder.GetKey())
        {
            this.specify = specify;

            if (specify.Strategy.Length > 2)
            {
                Short = GetBasicChart(new Stack <double>(512), specify, specify.Short);
                Long  = GetBasicChart(new Stack <double>(512), specify, specify.Long);

                if (Short.Count == 0 || Long.Count == 0)
                {
                    sCollection = true;
                    lCollection = true;
                    var charts = new Queue <Models.Charts>(256);

                    if (Short.Count > 0)
                    {
                        Short.Clear();
                        sCollection = false;
                        LongValue   = new Dictionary <string, double>();
                    }
                    else if (Long.Count > 0)
                    {
                        Long.Clear();
                        lCollection = false;
                        ShortValue  = new Dictionary <string, double>();
                    }
                    else
                    {
                        ShortValue = new Dictionary <string, double>();
                        LongValue  = new Dictionary <string, double>();
                    }
                    foreach (Catalog.Chart chart in Retrieve.Chart)
                    {
                        Analysize(chart);
                    }

                    if (sCollection)
                    {
                        foreach (var kv in ShortValue)
                        {
                            charts.Enqueue(new Models.Charts
                            {
                                Code  = specify.Code,
                                Time  = (int)specify.Time,
                                Base  = specify.Short,
                                Date  = kv.Key,
                                Value = kv.Value
                            });
                        }
                    }
                    if (lCollection)
                    {
                        foreach (var kv in LongValue)
                        {
                            charts.Enqueue(new Models.Charts
                            {
                                Code  = specify.Code,
                                Time  = (int)specify.Time,
                                Base  = specify.Long,
                                Date  = kv.Key,
                                Value = kv.Value
                            });
                        }
                    }
                    if (charts.Count > 0 && SetBasicChart(charts))
                    {
                        charts.Clear();
                    }
                }
            }
        }
Exemplo n.º 18
0
        protected Stack <double> GetBasicChart(Stack <double> stack, Specify specify, int period)
        {
            var path   = Path.Combine(Application.StartupPath, chart, specify.Code, specify.Time.ToString());
            var exists = new DirectoryInfo(path);
            var file   = string.Concat(path, @"\", period, res);
            var files  = new FileInfo(file);

            if (exists.Exists && files.Exists)
            {
                using (var sr = new StreamReader(file))
                    try
                    {
                        if (sr != null)
                        {
                            while (sr.EndOfStream == false)
                            {
                                if (double.TryParse(sr.ReadLine().Split(',')[1], out double value))
                                {
                                    stack.Push(value);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        new ExceptionMessage(ex.StackTrace, specify.Strategy);
                    }
            }
            else
            {
                var time = (int)specify.Time;
                var temp = new Dictionary <string, double>();
                using (var db = new GoblinBatDbContext(key))
                    try
                    {
                        var call = db.Charts.Where(o => o.Code.Equals(specify.Code) && o.Time == time && o.Base == period).AsNoTracking();

                        if (call.Any(o => o.Date.Equals(time == 1440 ? rDate : rTime)))
                        {
                            foreach (var e in call.OrderByDescending(o => o.Date).Take(period + 1).Select(o => new
                            {
                                o.Date,
                                o.Value
                            }).OrderBy(o => o.Date))
                            {
                                stack.Push(e.Value);
                                temp[e.Date] = e.Value;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        new ExceptionMessage(ex.StackTrace, specify.Strategy);
                    }
                if (temp.Count > 0)
                {
                    try
                    {
                        if (exists.Exists == false)
                        {
                            exists.Create();
                        }

                        using (var sw = new StreamWriter(file))
                            foreach (var kv in temp.OrderBy(o => o.Key))
                            {
                                sw.WriteLine(string.Concat(kv.Key, ',', kv.Value));
                            }
                    }
                    catch (Exception ex)
                    {
                        new ExceptionMessage(ex.StackTrace, specify.Strategy);
                    }
                }
            }
            return(stack);
        }
Exemplo n.º 19
0
        public void ShouldPassWhenComparingMinValues()
        {
            TestStepRun run = Runner.GetPrimaryTestStepRun(CodeReference.CreateFromMember(typeof(Int32ComparisonSpecSample).GetMethod("CompareMinValues")));

            Specify.That(run.Result.Outcome).ShouldEqual(TestOutcome.Passed);
        }
Exemplo n.º 20
0
        public Specify[] Statistics(Specify[] specifies)
        {
            var temp = new Dictionary <uint, int[]>();
            int i    = 0;

            if (specifies.Any(o => o.Assets == 0))
            {
                var basic = new Specify[10];
                var ro    = new bool[] { true, false };

                for (i = 0; i < basic.Length; i++)
                {
                    basic[i] = new Specify
                    {
                        Assets     = (ulong)numericAssets.Value,
                        Code       = code,
                        Commission = commission[0],
                        MarginRate = rate[0],
                        Strategy   = strategy != null ? strategy[ran.Next(0, strategy.Length - 1)] : ran.Next(20, 100).ToString("D2"),
                        RollOver   = ro[ran.Next(0, ro.Length)],
                        Time       = i == 0 ? 1440 : (uint)string.Concat(numeric, i).FindByName <NumericUpDown>(this).Value,
                        Short      = (int)string.Concat(numeric, 10 + i).FindByName <NumericUpDown>(this).Value,
                        Long       = (int)string.Concat(numeric, 20 + i++).FindByName <NumericUpDown>(this).Value
                    }
                }
                ;
                return(basic);
            }
            foreach (var specify in specifies)
            {
                numericAssets.Value = specify.Assets;
                var commission = specify.Commission.ToString("P4");
                commission = commission.Substring(5, 1).Equals("0") ? specify.Commission.ToString("P3") : commission;
                var margin = specify.MarginRate.ToString("P2");
                margin = margin.Split('.')[1].Substring(1, 1).Equals("0") ? specify.MarginRate.ToString("P1") : margin;
                checkRollOver.CheckState = specify.RollOver ? CheckState.Checked : CheckState.Unchecked;
                temp[specify.Time]       = new int[]
                {
                    specify.Short,
                    specify.Long
                };
                if (comboCode.Items.Contains(specify.Code) == false)
                {
                    comboCode.Items.Add(specify.Code);
                }

                if (comboCommission.Items.Contains(commission) == false)
                {
                    comboCommission.Items.Add(commission);
                }

                if (comboMarginRate.Items.Contains(margin) == false)
                {
                    comboMarginRate.Items.Add(margin);
                }

                if (strategy != null && comboStrategy.Items.Contains(specify.Strategy) == false)
                {
                    comboStrategy.Items.Add(specify.Strategy);
                }

                comboCommission.SelectedItem = commission;
                comboMarginRate.SelectedItem = margin;
                comboCode.SelectedItem       = specify.Code;

                if (strategy == null && specify.Strategy.Length == 2 && int.TryParse(specify.Strategy, out int reaction))
                {
                    numericReaction.Value = reaction;
                }

                else if (strategy != null)
                {
                    comboStrategy.SelectedItem = specify.Strategy;
                }
            }
            if (temp.Count > 3)
            {
                foreach (var kv in temp.OrderByDescending(o => o.Key))
                {
                    if (i > 0)
                    {
                        string.Concat(numeric, i).FindByName <NumericUpDown>(this).Value = kv.Key;
                    }

                    string.Concat(numeric, 10 + i).FindByName <NumericUpDown>(this).Value   = kv.Value[0];
                    string.Concat(numeric, 20 + i++).FindByName <NumericUpDown>(this).Value = kv.Value[1];
                }
            }
            else
            {
                for (int j = 1; j < 9; j++)
                {
                    string.Concat(numeric, j).FindByName <NumericUpDown>(this).Value      = 0;
                    string.Concat(numeric, 10 + j).FindByName <NumericUpDown>(this).Value = 4;
                    string.Concat(numeric, 20 + j).FindByName <NumericUpDown>(this).Value = 60;
                }
                foreach (var kv in temp.OrderByDescending(o => o.Key))
                {
                    if (kv.Key == 0)
                    {
                        continue;
                    }

                    if (i == 0)
                    {
                        string.Concat(numeric, 10 + i).FindByName <NumericUpDown>(this).Value   = kv.Value[0];
                        string.Concat(numeric, 20 + i++).FindByName <NumericUpDown>(this).Value = kv.Value[1];

                        continue;
                    }
                    string.Concat(numeric, 10 - i).FindByName <NumericUpDown>(this).Value = kv.Key;
                    string.Concat(numeric, 20 - i).FindByName <NumericUpDown>(this).Value = kv.Value[0];
                    string.Concat(numeric, 30 - i).FindByName <NumericUpDown>(this).Value = kv.Value[1];
                }
            }
            return(specifies);
        }

        Catalog.DataBase.ImitationGame Statistics()
        {
            int i = 0;

            return(new Catalog.DataBase.ImitationGame
            {
                Assets = (long)numericAssets.Value,
                Code = comboCode.SelectedIndex < 0 ? code : comboCode.SelectedItem.ToString(),
                Commission = comboCommission.SelectedIndex < 0 ? commission[0] : commission[Array.FindIndex(Commission, o => o.Equals(comboCommission.SelectedItem.ToString()))],
                MarginRate = comboMarginRate.SelectedIndex < 0 ? rate[0] : rate[Array.FindIndex(MaginRate, o => o.Equals(comboMarginRate.SelectedItem.ToString()))],
                Strategy = strategy == null?numericReaction.Value.ToString() : comboStrategy.SelectedIndex < 0 || comboStrategy.SelectedItem.ToString().Equals(auto) ? this.strategy[ran.Next(0, this.strategy.Length - 1)] : comboStrategy.SelectedItem.ToString(),
                               RollOver = checkRollOver.CheckState.Equals(CheckState.Checked),
                               BaseTime = 1440,
                               BaseShort = (int)string.Concat(numeric, i + 10).FindByName <NumericUpDown>(this).Value,
                               BaseLong = (int)string.Concat(numeric, i++ + 20).FindByName <NumericUpDown>(this).Value,
                               NonaTime = (int)string.Concat(numeric, i).FindByName <NumericUpDown>(this).Value,
                               NonaShort = (int)string.Concat(numeric, i + 10).FindByName <NumericUpDown>(this).Value,
                               NonaLong = (int)string.Concat(numeric, i++ + 20).FindByName <NumericUpDown>(this).Value,
                               OctaTime = (int)string.Concat(numeric, i).FindByName <NumericUpDown>(this).Value,
                               OctaShort = (int)string.Concat(numeric, i + 10).FindByName <NumericUpDown>(this).Value,
                               OctaLong = (int)string.Concat(numeric, i++ + 20).FindByName <NumericUpDown>(this).Value,
                               HeptaTime = (int)string.Concat(numeric, i).FindByName <NumericUpDown>(this).Value,
                               HeptaShort = (int)string.Concat(numeric, i + 10).FindByName <NumericUpDown>(this).Value,
                               HeptaLong = (int)string.Concat(numeric, i++ + 20).FindByName <NumericUpDown>(this).Value,
                               HexaTime = (int)string.Concat(numeric, i).FindByName <NumericUpDown>(this).Value,
                               HexaShort = (int)string.Concat(numeric, i + 10).FindByName <NumericUpDown>(this).Value,
                               HexaLong = (int)string.Concat(numeric, i++ + 20).FindByName <NumericUpDown>(this).Value,
                               PentaTime = (int)string.Concat(numeric, i).FindByName <NumericUpDown>(this).Value,
                               PentaShort = (int)string.Concat(numeric, i + 10).FindByName <NumericUpDown>(this).Value,
                               PentaLong = (int)string.Concat(numeric, i++ + 20).FindByName <NumericUpDown>(this).Value,
                               QuadTime = (int)string.Concat(numeric, i).FindByName <NumericUpDown>(this).Value,
                               QuadShort = (int)string.Concat(numeric, i + 10).FindByName <NumericUpDown>(this).Value,
                               QuadLong = (int)string.Concat(numeric, i++ + 20).FindByName <NumericUpDown>(this).Value,
                               TriTime = (int)string.Concat(numeric, i).FindByName <NumericUpDown>(this).Value,
                               TriShort = (int)string.Concat(numeric, i + 10).FindByName <NumericUpDown>(this).Value,
                               TriLong = (int)string.Concat(numeric, i++ + 20).FindByName <NumericUpDown>(this).Value,
                               DuoTime = (int)string.Concat(numeric, i).FindByName <NumericUpDown>(this).Value,
                               DuoShort = (int)string.Concat(numeric, i + 10).FindByName <NumericUpDown>(this).Value,
                               DuoLong = (int)string.Concat(numeric, i++ + 20).FindByName <NumericUpDown>(this).Value,
                               MonoTime = (int)string.Concat(numeric, i).FindByName <NumericUpDown>(this).Value,
                               MonoShort = (int)string.Concat(numeric, i + 10).FindByName <NumericUpDown>(this).Value,
                               MonoLong = (int)string.Concat(numeric, i + 20).FindByName <NumericUpDown>(this).Value
            });
        }

        void SetInitialValue()
        {
            Commission = new string[commission.Length];
            MaginRate  = new string[rate.Length];

            for (int i = 0; i < commission.Length; i++)
            {
                var temp = commission[i].ToString("P4");

                if (temp.Substring(5, 1).Equals("0"))
                {
                    Commission[i] = commission[i].ToString("P3");

                    continue;
                }
                Commission[i] = temp;
            }
            for (int i = 0; i < rate.Length; i++)
            {
                var temp = rate[i].ToString("P2");

                if (temp.Split('.')[1].Substring(1, 1).Equals("0"))
                {
                    MaginRate[i] = rate[i].ToString("P1");

                    continue;
                }
                MaginRate[i] = temp;
            }
            comboCode.Items.Add(code);
            comboCommission.Items.AddRange(Commission);
            comboMarginRate.Items.AddRange(MaginRate);
        }

        void ButtonClick(object sender, EventArgs e) => BeginInvoke(new Action(() =>
        {
            SuspendLayout();
            var button = (Button)sender;
            int i      = 0;

            switch (button.Name)
            {
            case start:
                int value = int.MaxValue;

                for (i = 0; i < 10; i++)
                {
                    var time = i > 0 ? string.Concat(numeric, i).FindByName <NumericUpDown>(this).Value : 1440;

                    if (strategy == null && i > 0 && i < 9)
                    {
                        for (int j = 1; j < 9; j++)
                        {
                            string.Concat(numeric, j).FindByName <NumericUpDown>(this).Value      = 0;
                            string.Concat(numeric, 10 + j).FindByName <NumericUpDown>(this).Value = 4;
                            string.Concat(numeric, 20 + j).FindByName <NumericUpDown>(this).Value = 60;
                        }
                        continue;
                    }
                    else if (value > time && string.Concat(numeric, i + 10).FindByName <NumericUpDown>(this).Value < string.Concat(numeric, i + 20).FindByName <NumericUpDown>(this).Value)
                    {
                        value = (int)time;

                        continue;
                    }
                    else if (MessageBox.Show(message, warning, MessageBoxButtons.OK, MessageBoxIcon.Error).Equals(DialogResult.OK))
                    {
                        return;
                    }
                }
                SendStatistics?.Invoke(this, new Statistics(Statistics()));
                buttonStorage.Text      = setting;
                buttonStorage.ForeColor = Color.Gold;
                Cursor = Cursors.WaitCursor;
                Application.DoEvents();
                return;

            case storage:
                if ((strategy != null && (comboCode.SelectedIndex < 0 || comboCommission.SelectedIndex < 0 || comboStrategy.SelectedIndex < 0)) || (numericReaction != null && (comboCode.SelectedIndex < 0 || comboCommission.SelectedIndex < 0)))
                {
                    if (MessageBox.Show(notApplicable, warning, MessageBoxButtons.OK, MessageBoxIcon.Warning).Equals(DialogResult.OK))
                    {
                        return;
                    }
                }

                if (button.ForeColor.Equals(Color.Crimson) == false)
                {
                    SendStatistics?.Invoke(this, new Statistics(new Catalog.Setting
                    {
                        Assets     = (long)numericAssets.Value,
                        Commission = commission[Array.FindIndex(Commission, o => o.Equals(comboCommission.SelectedItem.ToString()))],
                        Strategy   = strategy != null ? strategy[Array.FindIndex(strategy, o => o.Equals(comboStrategy.SelectedItem.ToString()))] : numericReaction.Value.ToString(),
                        Code       = code,
                        RollOver   = checkRollOver.CheckState,
                        BaseShort  = (int)string.Concat(numeric, i + 10).FindByName <NumericUpDown>(this).Value,
                        BaseLong   = (int)string.Concat(numeric, i++ + 20).FindByName <NumericUpDown>(this).Value,
                        NonaTime   = (int)string.Concat(numeric, i).FindByName <NumericUpDown>(this).Value,
                        NonaShort  = (int)string.Concat(numeric, i + 10).FindByName <NumericUpDown>(this).Value,
                        NonaLong   = (int)string.Concat(numeric, i++ + 20).FindByName <NumericUpDown>(this).Value,
                        OctaTime   = (int)string.Concat(numeric, i).FindByName <NumericUpDown>(this).Value,
                        OctaShort  = (int)string.Concat(numeric, i + 10).FindByName <NumericUpDown>(this).Value,
                        OctaLong   = (int)string.Concat(numeric, i++ + 20).FindByName <NumericUpDown>(this).Value,
                        HeptaTime  = (int)string.Concat(numeric, i).FindByName <NumericUpDown>(this).Value,
                        HeptaShort = (int)string.Concat(numeric, i + 10).FindByName <NumericUpDown>(this).Value,
                        HeptaLong  = (int)string.Concat(numeric, i++ + 20).FindByName <NumericUpDown>(this).Value,
                        HexaTime   = (int)string.Concat(numeric, i).FindByName <NumericUpDown>(this).Value,
                        HexaShort  = (int)string.Concat(numeric, i + 10).FindByName <NumericUpDown>(this).Value,
                        HexaLong   = (int)string.Concat(numeric, i++ + 20).FindByName <NumericUpDown>(this).Value,
                        PentaTime  = (int)string.Concat(numeric, i).FindByName <NumericUpDown>(this).Value,
                        PentaShort = (int)string.Concat(numeric, i + 10).FindByName <NumericUpDown>(this).Value,
                        PentaLong  = (int)string.Concat(numeric, i++ + 20).FindByName <NumericUpDown>(this).Value,
                        QuadTime   = (int)string.Concat(numeric, i).FindByName <NumericUpDown>(this).Value,
                        QuadShort  = (int)string.Concat(numeric, i + 10).FindByName <NumericUpDown>(this).Value,
                        QuadLong   = (int)string.Concat(numeric, i++ + 20).FindByName <NumericUpDown>(this).Value,
                        TriTime    = (int)string.Concat(numeric, i).FindByName <NumericUpDown>(this).Value,
                        TriShort   = (int)string.Concat(numeric, i + 10).FindByName <NumericUpDown>(this).Value,
                        TriLong    = (int)string.Concat(numeric, i++ + 20).FindByName <NumericUpDown>(this).Value,
                        DuoTime    = (int)string.Concat(numeric, i).FindByName <NumericUpDown>(this).Value,
                        DuoShort   = (int)string.Concat(numeric, i + 10).FindByName <NumericUpDown>(this).Value,
                        DuoLong    = (int)string.Concat(numeric, i++ + 20).FindByName <NumericUpDown>(this).Value,
                        MonoTime   = (int)string.Concat(numeric, i).FindByName <NumericUpDown>(this).Value,
                        MonoShort  = (int)string.Concat(numeric, i + 10).FindByName <NumericUpDown>(this).Value,
                        MonoLong   = (int)string.Concat(numeric, i + 20).FindByName <NumericUpDown>(this).Value
                    }));
                }
                break;
            }
            button.Text      = complete;
            button.ForeColor = Color.Crimson;
            ResumeLayout();
        }));
        void CheckRollOverCheckStateChanged(object sender, EventArgs e) => BeginInvoke(new Action(() =>
        {
            var button = (CheckBox)sender;

            switch (button.CheckState)
            {
            case CheckState.Checked:
                button.Text      = over;
                button.ForeColor = Color.Ivory;
                break;

            case CheckState.Unchecked:
                button.Text      = notUsed;
                button.ForeColor = Color.Maroon;
                break;

            case CheckState.Indeterminate:
                button.Text      = auto;
                button.ForeColor = Color.Navy;
                button.BackColor = Color.DimGray;
                return;
            }
            button.BackColor = Color.Transparent;
        }));

        string[] Commission
        {
            get; set;
        }
        string[] MaginRate
        {
            get; set;
        }
Exemplo n.º 21
0
        public void ShouldFailWhenComparingOneWithTwo()
        {
            TestStepRun run = Runner.GetPrimaryTestStepRun(CodeReference.CreateFromMember(typeof(Int32ComparisonSpecSample).GetMethod("CompareOneWithTwo")));

            Specify.That(run.Result.Outcome).ShouldEqual(TestOutcome.Failed);
        }
Exemplo n.º 22
0
 public void CompareMinValues()
 {
     Specify.That(int.MinValue).ShouldEqual(int.MinValue);
 }
Exemplo n.º 23
0
 public void CompareOnes()
 {
     Specify.That(1).ShouldEqual(1);
 }
Exemplo n.º 24
0
        void OnReceiveNotifyIcon(object sender, NotifyIconText e)
        {
            switch (e.NotifyIcon.GetType().Name)
            {
            case dic:
                var temp = (Dictionary <int, string>)e.NotifyIcon;

                if (temp.TryGetValue(0, out string code))
                {
                    notifyIcon.Text = checkDataBase;
                    Open.StartProgress(3605);
                    notifyIcon.Text = secret.GetIdentify();

                    return;
                }
                var first = temp.First();
                notifyIcon.Text = string.Concat(DateTime.Now.ToShortTimeString(), " Remains_", first.Key, " Code_", first.Value);
                return;

            case sb:
                strip.ItemClicked += OnItemClick;
                BeginInvoke(new Action(() =>
                {
                    if (Quotes == null)
                    {
                        Quotes = new QuotesControl();
                        panel.Controls.Add(Quotes);
                        Open.SendQuotes += Quotes.OnReceiveQuotes;
                        Quotes.Dock      = DockStyle.Fill;
                    }
                    if (Account == null)
                    {
                        Account = new AccountControl();
                        panel.Controls.Add(Account);
                        Account.Dock      = DockStyle.Fill;
                        Open.SendDeposit += Account.OnReceiveDeposit;
                    }
                    if (Balance == null)
                    {
                        Balance = new BalanceControl();
                        panel.Controls.Add(Balance);
                        Balance.Dock      = DockStyle.Fill;
                        Open.SendBalance += Balance.OnReceiveBalance;
                    }
                    if (Statistical == null)
                    {
                        Statistical = new StatisticalAnalysis();
                        panel.Controls.Add(Statistical);
                        Statistical.Dock = DockStyle.Fill;
                    }
                    var chart = Retrieve.GetInstance(KeyDecoder.GetWindowsProductKeyFromRegistry(), Open.Code).Chart;
                    var check = e.NotifyIcon.ToString().Split((char)59);
                    Acc       = new string[check.Length - 3];
                    Server    = check[check.Length - 1].Equals(secret.Mock);

                    if (Server ? false : new VerifyIdentity().Identify(check[check.Length - 3], check[check.Length - 2]) == false)
                    {
                        TimerBox.Show(new Secret(check[check.Length - 2]).Identify, secret.GoblinBat, MessageBoxButtons.OK, MessageBoxIcon.Warning, 3750);
                        Dispose();

                        return;
                    }
                    for (int i = 0; i < check.Length - 3; i++)
                    {
                        Acc[i] = check[i];
                    }

                    new Task(() =>
                    {
                        var specify = new Specify
                        {
                            Account  = Acc,
                            Assets   = 17500000,
                            Code     = Open.Code,
                            Strategy = "TF",
                            Time     = 30,
                            Short    = 4,
                            Long     = 60
                        };
                        new Strategy.OpenAPI.Trading(Open, specify, new Strategy.OpenAPI.Quotes(specify, Open), chart);
                    }).Start();
                    new Task(() =>
                    {
                        var liquidate = new Specify
                        {
                            Account  = Acc,
                            Assets   = 17500000,
                            Code     = Open.Code,
                            Strategy = "WU",
                            Time     = 15,
                            Short    = 4,
                            Long     = 60
                        };
                        new Strategy.OpenAPI.Trading(Open, liquidate, new Strategy.OpenAPI.Quotes(liquidate, Open), chart);
                    }).Start();
                    new Task(() => new Strategy.OpenAPI.Trading(Open, new Specify
                    {
                        Account  = Acc,
                        Assets   = 17500000,
                        Code     = Open.Code,
                        Strategy = "DL",
                        Time     = 1440,
                        Short    = 4,
                        Long     = 60,
                        Reaction = 531
                    }, chart)).Start();
                    Open.SendState += Quotes.OnReceiveState;
                    Open.SendTrend += Quotes.OnReceiveTrend;
                    Retrieve.Dispose();
                }));
                return;

            case str:
                BeginInvoke(new Action(() => Quotes.OnReceiveOrderMsg(e.NotifyIcon.ToString())));
                return;

            case bt:
                if (Array.Exists(XingConnect, o => o.Equals(initial)))
                {
                    BeginInvoke(new Action(() =>
                    {
                        Xing            = XingAPI.ConnectAPI.GetInstance(initial.Equals(trading) ? Strategy.Retrieve.Code : Open.Code, Strategy.Retrieve.Date);
                        Xing.Send      += OnReceiveNotifyIcon;
                        notifyIcon.Text = string.Concat("Trading Code_", initial.Equals(trading) ? Strategy.Retrieve.Code : Open.Code);
                        OnEventConnect();
                        OnClickMinimized = quo;
                        Application.DoEvents();
                    }));
                }
                else
                {
                    Account.Show();
                    Open.SendDeposit -= Account.OnReceiveDeposit;
                    Account.Hide();
                    Balance.Show();
                    Open.SendBalance -= Balance.OnReceiveBalance;
                    Balance.Hide();
                    Open.SendState -= Quotes.OnReceiveState;
                    Open.SendTrend -= Quotes.OnReceiveTrend;
                }
                return;

            case int32:
                if ((int)e.NotifyIcon < 0)
                {
                    if (Temporary != null && initial.Equals(collecting))
                    {
                        Temporary.SetStorage(Open.Code);
                    }

                    Process.Start("shutdown.exe", "-r");
                    Dispose();
                }
                else
                {
                    foreach (var ctor in Xing.querys)
                    {
                        switch (ctor.GetType().Name)
                        {
                        case cfobq10500:
                        case ccebq10500:
                            ((IEvents <Deposit>)ctor).Send -= Account.OnReceiveDeposit;
                            ((IMessage <NotifyIconText>)ctor).SendMessage -= OnReceiveNotifyIcon;
                            Account.Hide();
                            break;

                        case t0441:
                        case cceaq50600:
                            ((IEvents <Balance>)ctor).Send -= Balance.OnReceiveBalance;
                            ((IMessage <NotifyIconText>)ctor).SendMessage -= OnReceiveNotifyIcon;
                            Balance.Hide();
                            break;
                        }
                    }
                    Statistical.Hide();
                    return;
                }
                break;

            case cha:
                switch ((char)e.NotifyIcon)
                {
                case (char)69:
                    new ExceptionMessage(e.NotifyIcon.ToString());
                    Dispose();
                    return;

                case (char)41:
                    if (initial.Equals(trading))
                    {
                        Xing.OnReceiveBalance = false;
                        Process.Start("shutdown.exe", "-r");
                        Dispose();
                    }
                    break;

                case (char)21:
                    if (initial.Equals(trading))
                    {
                        Xing.OnReceiveBalance = true;
                    }

                    break;

                default:
                    return;
                }
                break;

            case boolean:
                break;
            }
        }
Exemplo n.º 25
0
        private void OnReceiveNotifyIcon(object sender, NotifyIconText e)
        {
            switch (e.NotifyIcon.GetType().Name)
            {
            case "StringBuilder":
                strip.ItemClicked += OnItemClick;
                BeginInvoke(new Action(() =>
                {
                    Quotes = new QuotesControl();
                    panel.Controls.Add(Quotes);
                    API.SendQuotes += Quotes.OnReceiveQuotes;
                    Quotes.Dock     = DockStyle.Fill;
                    Account         = new AccountControl();
                    panel.Controls.Add(Account);
                    Account.Dock     = DockStyle.Fill;
                    API.SendDeposit += Account.OnReceiveDeposit;
                    Balance          = new BalanceControl();
                    panel.Controls.Add(Balance);
                    Balance.Dock     = DockStyle.Fill;
                    API.SendBalance += Balance.OnReceiveBalance;
                    Statistical      = new StatisticalControl();
                    panel.Controls.Add(Statistical);
                    Statistical.Dock = DockStyle.Fill;
                    var code         = e.NotifyIcon.ToString().Split(';');
                    var chart        = Retrieve.GetInstance(code[code.Length - 1]).Chart;
                    new Task(() =>
                    {
                        var specify = new Specify
                        {
                            Account  = secret.Accounts,
                            Assets   = 17500000,
                            Code     = code[code.Length - 1],
                            Strategy = "TF",
                            Time     = 30,
                            Short    = 4,
                            Long     = 60
                        };
                        new Trading(API, specify, new Statistic.Quotes(specify, API), chart);
                    }).Start();
                    new Task(() =>
                    {
                        var liquidate = new Specify
                        {
                            Account  = secret.Accounts,
                            Assets   = 17500000,
                            Code     = code[code.Length - 1],
                            Strategy = "WU",
                            Time     = 15,
                            Short    = 4,
                            Long     = 60
                        };
                        new Trading(API, liquidate, new Statistic.Quotes(liquidate, API), chart);
                    }).Start();
                    new Task(() => new Trading(API, new Specify
                    {
                        Account  = secret.Accounts,
                        Assets   = 17500000,
                        Code     = code[code.Length - 1],
                        Strategy = "DL",
                        Time     = 1440,
                        Short    = 4,
                        Long     = 60,
                        Reaction = 531
                    }, chart)).Start();
                    API.SendState += Quotes.OnReceiveState;
                    API.SendTrend += Quotes.OnReceiveTrend;
                    Retrieve.Dispose();
                }));
                return;

            case "String":
                BeginInvoke(new Action(() => Quotes.OnReceiveOrderMsg(e.NotifyIcon.ToString())));
                return;

            case "Byte":
                Account.Show();
                API.SendDeposit -= Account.OnReceiveDeposit;
                Account.Hide();
                Balance.Show();
                API.SendBalance -= Balance.OnReceiveBalance;
                Balance.Hide();
                BackColor        = Color.FromArgb(121, 133, 130);
                Opacity          = 0.8135;
                OnClickMinimized = "quotes";
                WindowState      = FormWindowState.Minimized;
                API.SendState   -= Quotes.OnReceiveState;
                API.SendTrend   -= Quotes.OnReceiveTrend;
                return;

            case "Char":
                Dispose();
                break;
            }
            ;
        }