Esempio n. 1
0
        public Simulation(string argName, TestParam argTestParam, ref PersonForm view, ref UInt32 currentThreadNum)
        {
            currentThreadNum++;
            name          = argName;
            testParam     = argTestParam;
            currentStatus = PositionStatus.None;
            currentPosition.closePrice = 0.0;
            tradeTimes        = 0;
            badTradeTimes     = 0;
            goodTradeTimes    = 0;
            profit            = 0;
            simulationIndex   = 0;
            currentPriceTrend = Trend.None;
            lastPriceTrend    = Trend.None;
            TradeDt           = new DataTable();
            MAs = new List <MA>(8);
            MAs.Add(new MA(5));
            MAs.Add(new MA(10));
            MAs.Add(new MA(20));
            MAs.Add(new MA(30));
            MAs.Add(new MA(60));
            MAs.Add(new MA(120));
            MAs.Add(new MA(240));


            updateCurrentStatusDelegate    = new Model.Simulation.UpdateCurrentStatusDelegate(view.updateCurrentStatus);
            updateTradeLogParallelDelegate = new Model.Simulation.UpdateTradeLogParallelDelegate(view.updateTradeLogParallelTextBox);
        }
Esempio n. 2
0
        public TestParam Get(int id, int pid)
        {
            var idx = SQLHelper.Insert();

            var ts = new TestParam();

            ts.ID = id;

            return(ts);
        }
 private void Submit_Click(object sender, EventArgs e)
 {
     if (this.Entity == null)
     {
         this.Entity    = new TestParam();
         this.Entity.Id = Guid.NewGuid().ToString();
     }
     this.Entity.Key   = this.textBox1.Text.Trim();
     this.Entity.Value = this.textBox2.Text.Trim();
     this.DialogResult = System.Windows.Forms.DialogResult.OK;
     this.Close();
 }
Esempio n. 4
0
        public IQueryable <Tests> LoadPageTests(TestParam param)
        {
            var temp = dbSession.TestDal.LoadEntities(t => t.Id > 0);

            if (!string.IsNullOrEmpty(param.gameName))
            {
                temp = temp.Where(t => t.GameName.Contains(param.gameName));
            }
            param.Total = temp.Count();
            return(temp.OrderByDescending(d => d.InTime)
                   .Skip(param.PageSize * (param.PageIndex - 1))
                   .Take(param.PageSize).AsQueryable());
        }
        public static IEnumerable <object[]> GetSignInModelTests()
        {
            var testParams = new TestParam[] {
                new TestParam {
                    Name           = "Email",
                    PossibleValues = new object[] { email, "emailWrong", null, string.Empty }
                },
                new TestParam {
                    Name           = "Password",
                    PossibleValues = new object[] { password, "wrong", null, string.Empty, }
                }
            };

            return(TestCombinationsGenerator.Combine(testParams).Skip(1));
        }
            public async Task UpdateCostStatus(TestParam param)
            {
                // Arrange
                var cost = MockCost();
                var oldLatestRevision = cost.LatestCostStageRevision;

                // Act
                var response = await CostStatusService.UpdateCostStageRevisionStatus(cost.Id, param.Status, BuType.Pg);

                // Assert
                response.Should().BeTrue();
                cost.Status.Should().Be(param.ExpectedCostStatus);
                cost.LatestCostStageRevision.Status.Should().Be(param.ExpectedLatestRevisionStatus);
                oldLatestRevision.Status.ShouldBeEquivalentTo(param.OldLatestRevisionStatus);
            }
            public virtual void TestMethod(ref int refParam, out TestParam outParam)
            {
                Assert.AreEqual(refParam, REF_PARAM_CORRECT_VALUE);
                // Test that setting parameters will not affect final output
                outParam = null;
                refParam = REF_PARAM_INCORRECT_VALUE;

                // Test that results of byRef params are visible to us
                Int32     refParamResult = REF_PARAM_INCORRECT_VALUE;
                TestParam outParamResult;

                this.result.TestMethod(ref refParamResult, out outParamResult);
                Assert.AreEqual(refParamResult, REF_PARAM_CORRECT_VALUE);
                Assert.IsNotNull(outParamResult);
                _sideEffectSuccessfulyExecuted = true;
            }
        private void ClickDelete(object arg1, EventArgs arg2)
        {
            TestParam entity = this.myGridView1.FindFirstSelect <TestParam>();

            if (entity != null)
            {
                this.isModify = true;
                if (MessageBox.Show("是否删除数据?", "确认", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    this.Entity.ParamList.Remove(entity);
                    if (isModify)
                    {
                        bll.SelectAll().RemoveAll(p => p.Id == this.Entity.Id);
                    }
                    this.myGridView1.LoadData(this.Entity.ParamList, base.ignoreFields);
                }
            }
        }
Esempio n. 9
0
        private void loadTestParams()
        {
            for (UInt16 i = tpr.k1; i < tpr.k1_End;)
            {
                for (double j = tpr.k2; j < tpr.k2_End;)
                {
                    for (double n = tpr.k3; n < tpr.k3_End;)
                    {
                        TestParam tp = new TestParam();
                        tp.k1 = i;
                        tp.k2 = j;
                        tp.k3 = n;
                        listTestParams.Add(tp);

                        n += tpr.k3_Step;
                    }
                    j += tpr.k2_Step;
                }
                i += tpr.k1_Step;
            }
        }
Esempio n. 10
0
        public void Serialize_Success()
        {
            // => Arrange
            var param = new TestParam()
            {
                Name  = "Test",
                Age   = 25,
                IsOld = true
            };
            var serializer = new TestParamSerializer();

            // => Act
            var serialized = serializer.Serialize(param);

            var deserialized = serializer.Deserialize(serialized);

            // => Assert
            Assert.NotNull(deserialized);
            Assert.Equal("Test", deserialized.Name);
            Assert.Equal(25, deserialized.Age);
            Assert.True(deserialized.IsOld);
        }
Esempio n. 11
0
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Alpha1))
     {
         TestParam param = new TestParam
         {
             testStr = "11111"
         };
         FsmManager.Instance.ChangeState(FsmConsts.FSM_TEST_1, param);
     }
     if (Input.GetKeyDown(KeyCode.Alpha2))
     {
         TestParam param = new TestParam
         {
             testStr = "22222"
         };
         FsmManager.Instance.ChangeState(FsmConsts.FSM_TEST_2, param);
     }
     if (Input.GetKeyDown(KeyCode.Alpha0))
     {
         FsmManager.Instance.ChangeState(FsmConsts.FSM_DEFAULT);
     }
 }
Esempio n. 12
0
        public TestParam Get(int id)
        {
            SqlBulk.InsertTwo();
            RedisHelper redisHelper = new RedisHelper("127.0.0.1:6379");

            redisHelper.SetValue("mykey", "abc111");

            var person = new Users
            {
                UserName = "******",
                Email    = "*****@*****.**",
                Address  = "浙江"
            };

            // redisHelper.SetEntryInHash("Hash", "Name", "wujf");

            redisHelper.SetHashValue("user:123", person);

            var ts = new TestParam();

            ts.ID = id;

            return(ts);
        }
 async Task <string> IPedantic.TestPassClass(TestParam param)
 {
     return(string.Format("{0}:{1}", param.Name, param.Price));
 }
 public override void Customize(TestParam testParam)
 {
     throw new NotImplementedException();
 }
Esempio n. 15
0
 async Task <string> IPedantic.TestPassClass(TestParam param)
 {
     return($"{param.Name}:{param.Price}");
 }
Esempio n. 16
0
 public void Test([FromBody] TestParam value)
 {
 }
Esempio n. 17
0
    public void OnInitState(IFsmStateParam _param)
    {
        TestParam param = _param as TestParam;

        Debug.Log(param.testStr);
    }
Esempio n. 18
0
 public MySimpleEventHandler(TestParam aa)
 {
 }
Esempio n. 19
0
 public Test(
     TestParam param)
 {
 }
Esempio n. 20
0
        public async Task Commodity_dependingOnContentType_shouldReturnCorrectCommodity(TestParam param)
        {
            // Arrange
            var costSubmitted = GetCostRevisionStatusChanged(CostStageRevisionStatus.Draft);
            var costId        = costSubmitted.AggregateId;
            var stageDetails  = new Dictionary <string, dynamic>
            {
                { "contentType", new { key = param.ContentType } },
                { "usageType", new { key = param.UsageType } }
            };

            SetupPurchaseOrderView(costId, costType: param.CostType, stageDetails: stageDetails);

            // Act
            var purchase = await PgPurchaseOrderService.GetPurchaseOrder(costSubmitted);

            // Assert
            purchase.Commodity.Should().Be(param.Commodity);
        }
        public override void Customize(TestParam testParam)
        {
            /***************************************
             * MODIFICHE ALLA CONFIGURAZIONE STANDARD
             **************************************/
            // filenames
            //const string filename = @"data\mtgox-hourly-candles-USD.csv"; // 3,4,2 macd
            //const string filename = @"data\mtgoxcandlesMonth-15m";  //macd 2,4,-5
            //const string filename = @"data\mtgoxcandles10days-5mins";
            //const string filename = @"data\mtgoxcandles2013-6hrs"; //3,4,-3 macd
            //const string filename = @"data\mtgoxcandles2013-12hrs";
            //const string filename = @"data\mtgoxcandles2days-1m";
            //const string filename = @"data\mtgoxcandlesAug2013-15m";
            //const string filename = @"data\mtgox-augdec2013-15m.csv"; //0,3,-5
            //const string filename = @"data\mtgox-complete2013.csv";
            //const string filename = @"data\candles-2013-5m.csv";
            //const string filename = @"data\candles-2013-jan-apr-5m.csv";

            //const string filename = @"data\candles-btce-complete-15m.csv";
            const string filename = @"data\candles-2013-jun-dec-5m.csv";

            //const string filename = @"data\candles-2013-1m.csv";
            //const string filename = @"data\candles-septdec2013-15m.csv";
            //const string filename = @"data\candles-mtgox-jan2014-15m";
            //const string filename = @"data\candles-jan2014-15m";

            // indicatore Ema con rapporto
            MainConfiguration.Configuration.StartWalletCoins = 14M;// 0.33M;//0.33M * 1;
            MainConfiguration.Configuration.StartWalletMoney = 0;
            MainConfiguration.Configuration.QueueLength      = 200;

            MainConfiguration.Configuration.EmaDiff = EmaDiff.Create(10, 21);

            /*
             * MainConfiguration.Configuration.MacdList = new List<MacdItem>()
             *  {
             *      new MacdItem() {Macd = Macd.Create(12, 26, 9)}
             *  };
             */

            MainConfiguration.Configuration.GenerateOutputTradeHistory = true;

            // effettuo un test senza greedyness
            var gain = 15M / 10M;// 1.2M; //2;

            if (false)
            {
                MainConfiguration.Configuration.GreedyWithLongTermTrend = false;
                MainConfiguration.Configuration.GreedyWithCoinsGain     = 1 + 0.1M * gain;
                MainConfiguration.Configuration.GreedyWithMoneyGain     = 1 + 0.1M * gain;
            }
            if (true)
            {
                // greedy baby ;-)
                MainConfiguration.Configuration.GreedyWithCoinsGain = 1 + 0.1M * gain;
                MainConfiguration.Configuration.GreedyWithMoneyGain = 1 + 0.1M * gain;
            }

            MainConfiguration.Configuration.MarketSimulatorCandleFileName = filename;
            MainConfiguration.Configuration.CandleWidthInSeconds          = 60 * 15;

            MainConfiguration.Configuration.AlarmStrongSellBuyRocLimit = 4;
            MainConfiguration.Configuration.AlarmStrongSellMacdLimit   = 8;

            // aggiunti per fare un test con tanti valori ma in realtà sono parametri da non utlizare normalmente
            MainConfiguration.Configuration.EnableStopLoss        = true;
            MainConfiguration.Configuration.StopLossPercent       = 0.1M * 3;
            MainConfiguration.Configuration.ZeroFilterSequenceLen = 10;

            // MainConfiguration.Configuration.TestNumber = testParam.I;
            // MainConfiguration.Configuration.TestNumber = testParam.I;

            MainConfiguration.Configuration.Tolerance = 0.001M * 2;          //{1..4} meglio 2

            MainConfiguration.Configuration.SecurityLimit = 1.0M + 0.1M * 1; //*2;

            //MainConfiguration.Configuration.UndervalueAllowed = true;
            //MainConfiguration.Configuration.UndervalueTolerance = 0M;
            //MainConfiguration.Configuration.AlarmStrongSellBuyLimit = 1.0M + 0.1M*7; // 8 è meglio testParam.I;

            // disabilito il noise per vedere se cambiano i numeri
            MainConfiguration.Configuration.MarketSimulatorEnableNoise = false;

            MainConfiguration.Configuration.Commands = new string[] { "stoplossvalue", "stoploss", "alarm", "poll", "derivative", "expensivecheap" };


            //MainConfiguration.Configuration.ManagerIsConservative = true;
            //MainConfiguration.Configuration.ManagerConservativeMaxMoneyToInvest = 10000;

            if (false)
            {
                // gioco con i valori reali
                MainConfiguration.Configuration.QueueLength                   = 200;
                MainConfiguration.Configuration.StartWalletCoins              = 0.33M;
                MainConfiguration.Configuration.StartWalletMoney              = 0;
                MainConfiguration.Configuration.GenerateCandleFile            = true;
                MainConfiguration.Configuration.GenerateOutputTradeHistory    = true;
                MainConfiguration.Configuration.MarketSimulatorUseMtgox       = true;
                MainConfiguration.Configuration.MarketSimulatorUseCandleFile  = false;
                MainConfiguration.Configuration.RealTimeHeartBeat             = true;
                MainConfiguration.Configuration.RealTimeHeartBeatEveryMinutes = 1;
            }

            MainConfiguration.Configuration.Market  = CMarketSimulator.Create();
            MainConfiguration.Configuration.Manager = new CManagerTrading()
            {
                Conservative = MainConfiguration.Configuration.ManagerIsConservative,       // cerca sempre di investire la quantità di capitale
                PercCapital  = MainConfiguration.Configuration.ManagerInvestCapitalPercent, // quantità di capitale da investire
                Market       = MainConfiguration.Configuration.Market                       //market
            };
        }
Esempio n. 22
0
        void StartReplayInternal(TradingMacro tmOriginal, TestParam testParameter, Action <Task> continueWith)
        {
            if (IsInVirtualTrading)
            {
                while (_replayTasks.ToArray().Any(t => t.Status == TaskStatus.Running))
                {
                    Log = new Exception("Replay is running.");
                    Thread.Sleep(1000);
                    continue;
                }
                _replayTasks.Clear();
                MasterModel.AccountModel.Balance            = MasterModel.AccountModel.Equity = 50000;
                MasterModel.AccountModel.CurrentGrossInPips = 0;
                MasterModel.AccountModel.CurrentLoss        = 0;
                TradesManager.GetAccount().Balance = TradesManager.GetAccount().Equity = 50000;
            }
            SaveTradingSettings(tmOriginal);
            var tms = GetTradingMacros().Where(t => t.IsActive).ToList();

            ReplayArguments.SetTradingMacros(tms);
            ReplayArguments.GetOriginalBalance = new Func <double>(() => MasterModel.AccountModel.OriginalBalance);
            foreach (var tm in tms)
            {
                if (IsInVirtualTrading)
                {
                    if (tm.Strategy == Strategies.None)
                    {
                        tm.Strategy = Strategies.UniversalA;
                    }
                    TradesManager.ClosePair(tm.Pair);
                    tm.ResetSessionId(ReplayArguments.SuperSessionId);
                    if (testParameter != null && tm == tmOriginal)
                    {
                        testParameter.ForEach(tp => {
                            try {
                                tm.LoadSetting(tp);
                            } catch (SetLotSizeException) {
                            } catch (Exception exc) {
                                if (!(exc.InnerException is SetLotSizeException))
                                {
                                    var e2 = new Exception("Property:" + new { tp.Key, tp.Value }, exc);
                                    LogWww(e2);
                                    throw e2;
                                }
                            }
                        });
                    }
                }
                if (!string.IsNullOrWhiteSpace(ReplayArguments.PrevSessionUid))
                {
                    TradingMacro.SessionId = Guid.Parse(ReplayArguments.PrevSessionUid);
                }
                var tmToRun = tm;
                tmToRun.ReplayCancelationToken = (_replayTaskCancellationToken = new CancellationTokenSource()).Token;
                var task = Task.Factory.StartNew(() => tmToRun.Replay(ReplayArguments), tmToRun.ReplayCancelationToken, TaskCreationOptions.LongRunning, TaskScheduler.Default);

                task.ContinueWith(t => {
                    RxApp.MainThreadScheduler.Schedule(() => _replayTasks.Remove(t));
                    if (tm == tmOriginal)
                    {
                        continueWith(t);
                    }
                });
                _replayTasks.Add(task);
                ReplayArguments.IsWww = false;
            }
        }
 public virtual void TestMethod(ref Int32 refParam, out TestParam outParam)
 {
     Assert.AreEqual(REF_PARAM_CORRECT_VALUE, refParam);
     outParam = new TestParam();
 }