Ejemplo n.º 1
0
 public HistoryRepositoryTests()
 {
     _context           = new PartyTubeDbContextMock();
     _appSettings       = new AppSettings();
     _videoRepository   = new VideoRepository(_context.Context);
     _historyRepository = new HistoryRepository(_context.Context, _appSettings, _videoRepository);
 }
        public HttpResponseMessage GetDateShip(DateTime date)
        {
            var employees = HistoryRepository.SearchDailyShipping(date);
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, employees);

            return(response);
        }
        public HttpResponseMessage Post(List <History> e)
        {
            HttpResponseMessage response = null;

            try
            {
                var SO       = InventoryRepository.DeleteInventory(e);
                var shipping = HistoryRepository.SearchShippingBySalesOrder(SO);
                response = Request.CreateResponse(HttpStatusCode.OK, shipping);
            }
            catch (Exception x)
            {
                string error = x.ToString();
                if (error.Equals("An error occurred while updating the entries. See the inner exception for details."))
                {
                    return(new HttpResponseMessage(HttpStatusCode.NotModified));
                }
                else
                {
                    return(new HttpResponseMessage(HttpStatusCode.Forbidden));
                }
            }


            return(response);
        }
        public HttpResponseMessage GetItemsBySN(String serialNo)
        {
            var employees = HistoryRepository.SearchSNHistory(serialNo);
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, employees);

            return(response);
        }
        public HttpResponseMessage GetItemsBySalesOrder(String salesOrder)
        {
            var employees = HistoryRepository.SearchShippingBySalesOrder(salesOrder);
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, employees);

            return(response);
        }
Ejemplo n.º 6
0
        public PartialViewResult Exec(CalcModel model)
        {
            var result = double.NaN;

            if (Calc.getOperNames().Contains(model.OperName))
            {
                result = Calc.Exec(model.OperName, model.InputData);

                var operation = OperationRepository.LoadByName(model.OperName);

                if (operation != null)
                {
                    var history = new HistoryItemModel()
                    {
                        Operation = operation.Id,
                        Initiator = 1,
                        Result    = result,
                        Args      = string.Join(";", model.InputData),
                        CalcDate  = DateTime.Now,
                        Time      = 15
                    };

                    HistoryRepository.Save(history);
                }
            }

            return(PartialView("ExecResult", result));
        }
        public HttpResponseMessage Get()
        {
            var employees = HistoryRepository.GetAllShippingHistory();
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, employees);

            return(response);
        }
Ejemplo n.º 8
0
        public static void TestMultyExtremums(string toolName, int startStop, int endStop, int stopStep, int startPegTopSize, int endPegTopSize, int pegTopSizeStep)
        {
            var repository = new HistoryRepository(toolName, false);
            var resultText = new List <string>();

            //var good = new List<int>();
            //var bad = new List<int>();


            for (int minExtremumStep = 0; minExtremumStep <= 500; minExtremumStep += 100)
            {
                for (int stop = startStop; stop <= endStop; stop += stopStep)
                {
                    for (int pegTopSize = startPegTopSize; pegTopSize <= endPegTopSize; pegTopSize += pegTopSizeStep)
                    {
                        var strat = new MultyExtremumStrategy(stop, pegTopSize, minExtremumStep);

                        var result = strat.Run(repository.Days);
                        result.PrintDepo(@"depo\" + stop + "_" + pegTopSize + ".txt");

                        resultText.Add("mE: " + minExtremumStep + " stop: " + stop + " pegTopSize: " + pegTopSize);
                        resultText.Add(result.ToString());
                        resultText.Add("");
                        //good.Add(strat.Good);
                        //bad.Add(strat.Bad);
                    }
                }
            }

            //var a = good.Average();
            //var b = bad.Average();

            File.WriteAllLines("out.txt", resultText);
        }
Ejemplo n.º 9
0
 public JobSequence(
     DefinitionsRepository definitions,
     HistoryRepository history)
 {
     definitionRepo = definitions;
     historyRepo    = history;
 }
Ejemplo n.º 10
0
        public static void TestExtremums(string toolName, int startStop, int endStop, int stopStep,
                                         int startPegTopSize, int endPegTopSize, int pegTopSizeStep)
        {
            var repository = new HistoryRepository(toolName, false);
            var resultText = new List <string>();

            //var good = new List<int>();
            //var bad = new List<int>();

            for (int stop = startStop; stop <= endStop; stop += stopStep)
            {
                for (int pegTopSize = startPegTopSize; pegTopSize <= endPegTopSize; pegTopSize += pegTopSizeStep)
                {
                    for (double breakevenSize = 0.8; breakevenSize <= 2.0; breakevenSize += 0.1)
                    {
                        var strat = new ExtremumStrategy(stop, pegTopSize, breakevenSize);

                        var result = strat.Run(repository.Days);
                        result.PrintDepo(@"depo\" + stop.ToString("D4") + "_" + pegTopSize + "_" + ((int)(100 * breakevenSize)).ToString("D2") + ".txt");

                        resultText.Add("stop: " + stop + " pegTopSize: " + pegTopSize + " breakevenSize: " + breakevenSize.ToString(new CultureInfo("en-us")));
                        resultText.Add(result.ToString());
                        resultText.Add("");
                        //good.Add(strat.Good);
                        //bad.Add(strat.Bad);
                    }
                }
            }

            //var a = good.Average();
            //var b = bad.Average();

            File.WriteAllLines("out.txt", resultText);
        }
Ejemplo n.º 11
0
        public static void TestCorrectedExtremumsFast(string toolName, int startStop, int endStop, int stopStep,
                                                      int startTrStop, int endTrStop, int trStopStep, int pegTopSize)
        {
            var repository = new HistoryRepository(toolName, false);

            var headers = new List <string> {
                "Stop", "Trailing stop", "Breakeven size"
            };

            headers.AddRange(TradesResult.GetHeaders());
            var table = new List <List <string> >();

            for (int stop = startStop; stop <= endStop; stop += stopStep)
            {
                for (int trStop = Math.Max(startTrStop, stop); trStop <= endTrStop; trStop += trStopStep)
                {
                    for (double breakevenSize = 0.0; breakevenSize <= 0.61; breakevenSize += 0.2)
                    {
                        var strat = new CorrectedExtremumStrategy(stop, pegTopSize, breakevenSize, trStop);

                        var result = strat.Run(repository.Days);
                        result.PrintDepo(@"depo\" + stop.ToString("D4") + "_" + trStop.ToString("D4") + "_" +
                                         ((int)(100 * breakevenSize)).ToString("D2") + ".txt");

                        var currentText = new List <string> {
                            stop.ToString(), trStop.ToString(), breakevenSize.ToEnString()
                        };
                        currentText.AddRange(result.GetTableRow());
                        table.Add(currentText);
                    }
                }
            }

            TablesWriter.PrintExcel("out.xlsx", headers, table);
        }
Ejemplo n.º 12
0
        public void Get_migrations_query()
        {
            using (var context = new Context())
            {
                var historyRepository = new HistoryRepository(context.Configuration);

                using (var historyContext = historyRepository.CreateHistoryContext())
                {
                    var query = historyRepository.GetMigrationsQuery(historyContext);

                    var expression = (MethodCallExpression)query.Expression;

                    Assert.Equal("OrderBy", expression.Method.Name);
                    Assert.Equal("h => h.MigrationId", expression.Arguments[1].ToString());

                    expression = (MethodCallExpression)expression.Arguments[0];

                    Assert.Equal("Where", expression.Method.Name);
                    Assert.Equal(
                        "h => (h.ContextKey == value(Microsoft.Data.Entity.Migrations.Infrastructure.HistoryRepository).GetContextKey())",
                        expression.Arguments[1].ToString());

                    var queryableType = expression.Arguments[0].Type;

                    Assert.True(queryableType.IsGenericType);
                    Assert.Equal("EntityQueryable", queryableType.Name.Remove(queryableType.Name.IndexOf("`", StringComparison.Ordinal)));
                    Assert.Equal(1, queryableType.GenericTypeArguments.Length);
                    Assert.Equal("HistoryRow", queryableType.GenericTypeArguments[0].Name);
                }
            }
        }
Ejemplo n.º 13
0
 public ActionResult ChangedMade(History history)
 {
     var historyRepo = new HistoryRepository();
     history.dateTime = DateTime.Now;
     historyRepo.Collection.Insert(history);
     return JsonNet(new { success = true });
 }
Ejemplo n.º 14
0
        public async Task <InsertResponse> GenerateHistoriesAsync(GenerateItemsRequest request)
        {
            var patientIds = await UserManager.GetUsersIdAsync(new UsersIdRequest
            {
                Amount   = request.Count,
                UserType = UserType.Patient
            });

            var doctorIds = await UserManager.GetUsersIdAsync(new UsersIdRequest
            {
                Amount   = request.Count,
                UserType = UserType.Doctor
            });

            var historyPoints = Builder <HistoryPoint> .CreateNew()
                                .With(e => e.CreationDate = Date.Between(new DateTime(1930, 1, 1), DateTime.UtcNow))
                                .With(e => e.Report       = Faker.Lorem.Paragraph());

            var histories = new Bogus.Faker <History>()
                            .RuleFor(u => u.Id, f => ObjectId.GenerateNewId().ToString())
                            .RuleFor(bp => bp.DoctorId, f => f.PickRandom(doctorIds))
                            .RuleFor(bp => bp.PatientId, f => f.PickRandom(patientIds))
                            .RuleFor(u => u.HistoryPoints, f => f.Make(10, () => historyPoints.Build()))
                            .Generate(request.Count).ToList();

            return(await HistoryRepository.BulkInsertHistoriesAsync(histories));
        }
Ejemplo n.º 15
0
 public DataUtilities(
     ILoggerFactory loggerFactory,
     HistoryRepository historyRepository)
 {
     logForRemote = loggerFactory.CreateLogger(ConstLogging.JobFacRemoteLoggerProviderName);
     historyRepo  = historyRepository;
 }
Ejemplo n.º 16
0
        public static void TestExtremumsContinuationLength(string toolName)
        {
            const int  maxCount    = 30;
            const bool isTrendLong = true;
            var        repository  = new HistoryRepository(toolName, false);

            var averages = new List <List <int> >();

            for (int i = 1; i < maxCount; ++i)
            {
                var lengths = new List <int>();
                foreach (var day in repository.Days)
                {
                    var current = ProbabilityAnalyzer.TestExtremumsContinuationLength(day.FiveMins, i, isTrendLong);
                    lengths.AddRange(current);
                }

                if (!lengths.Any())
                {
                    lengths.Add(0);
                }

                averages.Add(lengths);
            }
            File.WriteAllLines("continLengthProbs.txt", averages.ConvertAll(list => list.Average().ToString(new CultureInfo("en-us")) + "\t" + list.Count));
        }
Ejemplo n.º 17
0
        public static void TestDaysHeightsAlternation(string toolName)
        {
            const int maxContinuationLength = 5;
            const int maxAverageDaysLength  = 20;

            var repository = new HistoryRepository(toolName, false);

            var output = new List <string>();

            var headers = new List <string> {
                "Length of average interval", "Continuation length", "Alternates count", "Continuation count", "Alternates percent"
            };
            var tableOutput = new List <List <string> >();

            for (int averageDaysLength = 5; averageDaysLength <= maxAverageDaysLength; ++averageDaysLength)
            {
                output.Add("Length of average interval: " + averageDaysLength);
                output.Add("");
                for (int continuationLength = 1; continuationLength < maxContinuationLength; ++continuationLength)
                {
                    var     current          = ProbabilityAnalyzer.TesCandlesHightAlternation(repository.Days.Select(day => day.Params).ToList(), continuationLength, averageDaysLength);
                    decimal alternatePercent = Math.Round(current.Item1 / ((decimal)current.Item1 + current.Item2), 2);
                    output.Add("Continuation length: " + continuationLength);
                    output.Add("Alternates count: " + current.Item1 + ", continuation count: " + current.Item2 + ", alternates percent: " + alternatePercent);
                    output.Add("");
                    tableOutput.Add(new List <string> {
                        averageDaysLength.ToString(), continuationLength.ToString(), current.Item1.ToString(), current.Item2.ToString(), alternatePercent.ToString(new CultureInfo("en-us"))
                    });
                }
                output.Add("");
            }
            TablesWriter.PrintExcel("AlternationTest " + toolName + ".xlsx", headers, tableOutput);
            File.WriteAllLines("AlternationTest " + toolName + ".txt", output);
        }
Ejemplo n.º 18
0
        public static BaseActionResult UpdateHistory(History obj4update)
        {
            string msg;

            if (obj4update == null)
            {
                msg = string.Format(XiaoluResources.MSG_UPDATE_SUCCESS, XiaoluResources.STR_HISTORY) + string.Format(XiaoluResources.STR_FAIL_RESAON, XiaoluResources.MSG_OBJECT_IS_NULL);
                return(new BaseActionResult(false, msg));
            }

            try
            {
                using (var context = new XiaoluEntities())
                {
                    var repository = new HistoryRepository(context);
                    repository.Update(obj4update);
                    context.SaveChanges();
                    msg = string.Format(XiaoluResources.MSG_UPDATE_SUCCESS, obj4update.UserId);
                    return(new BaseActionResult(true, msg));
                }
            }
            catch (Exception e)
            {
                msg = string.Format(XiaoluResources.MSG_UPDATE_FAIL, obj4update.UserId) + string.Format(XiaoluResources.STR_FAIL_RESAON, ExceptionHelper.GetInnerExceptionInfo(e));
                return(new BaseActionResult(false, msg));
            }
        }
Ejemplo n.º 19
0
        public HistoryRepositoryTests()
        {
            RadarTechno.History.History[] histories = new[]
            {
                new RadarTechno.History.History("author", "entity-technology", "id1", "diff"),
                new RadarTechno.History.History("author", "entity-technology", "id1", "diff2"),
                new RadarTechno.History.History("author", "entity-technology", "id1", "diff3"),
                new RadarTechno.History.History("author", "entity-technology", "id2", "diff")
            };

            _mongoRunner = MongoDbRunner.Start();
            MongoClient    client     = new MongoClient(_mongoRunner.ConnectionString);
            IMongoDatabase database   = client.GetDatabase("radar-techno");
            var            collection = database.GetCollection <RadarTechno.History.History>("history");

            collection.InsertMany(histories);
            var databaseSettings = new DatabaseSettings()
            {
                ConnectionString = _mongoRunner.ConnectionString,
                Database         = "radar-techno"
            };
            IOptions <DatabaseSettings> options = Options.Create <DatabaseSettings>(databaseSettings);

            _database   = new RadarDatabase(options);
            _repository = new HistoryRepository(_database);
        }
Ejemplo n.º 20
0
 public JobFactory(
     DefinitionsRepository definitionRepo,
     HistoryRepository historyRepo)
 {
     this.definitionRepo = definitionRepo;
     this.historyRepo    = historyRepo;
 }
Ejemplo n.º 21
0
        public static void TestExtremumsContinuationFronAngle(string toolName)
        {
            const int maxCount   = 15;
            var       repository = new HistoryRepository(toolName, false);

            var result = new List <Tuple <int, int> >();

            for (int monotoneCount = 2; monotoneCount < maxCount; ++monotoneCount)
            {
                result.Clear();
                for (double minAngle = 0; minAngle < Math.PI / 2; minAngle += 0.1)
                {
                    int successCount = 0, failCount = 0;
                    foreach (var day in repository.Days)
                    {
                        var current = ProbabilityAnalyzer.TestExtremumsContinuationFromAngle(day.FiveMins, monotoneCount, minAngle, true);
                        successCount += current.Item1;
                        failCount    += current.Item2;
                    }
                    if (failCount == 0)
                    {
                        failCount++;
                    }

                    result.Add(new Tuple <int, int>(successCount, failCount));
                }
                File.WriteAllLines("continProbs" + monotoneCount + ".txt",
                                   result.ConvertAll(t => (t.Item1 + "\t" + t.Item2)));
                //result.ConvertAll(t => (t.Item1/((double) t.Item2 + t.Item1)).ToString(new CultureInfo("en-us"))));
            }
        }
Ejemplo n.º 22
0
        public static void TestFirstExtremumsOrder(string toolName, int pegTopSize, bool isMinimums)
        {
            var repository = new HistoryRepository(toolName, false);

            var extremumFinder = new ExtremumsFinder(pegTopSize);

            foreach (var day in repository.Days)
            {
                var extremums = extremumFinder.FindFirstExtremums(day.FiveMins, isMinimums);

                bool bad = false;
                for (int i = 0; i < extremums.Count; ++i)                       //TODO Люой экстремум
                {
                    for (int j = i + 1; j < extremums.Count; ++j)
                    {
                        if (extremums[j].Date >= extremums[i].Date && extremums[j].CheckerIndex < extremums[i].CheckerIndex)
                        {
                            Console.Out.WriteLine(extremums[i] + "\t" + extremums[j]);
                            bad = true;
                        }
                    }
                }

                Assert.That(!bad);
            }
        }
Ejemplo n.º 23
0
        public static BaseActionResult BulkDeleteHistoryByIds(string idsStr)
        {
            string msg;

            string[] idArr = idsStr.Split(',');
            if (idArr.Length == 0)
            {
                msg = XiaoluResources.ERR_MSG_NO_RECORD_FOR_ACTION;
                return(new BaseActionResult(false, msg));
            }
            try
            {
                List <History> list4delete = new List <History>();
                foreach (string id in idArr)
                {
                    var obj4delete = GetHistoryById(id);
                    list4delete.Add(obj4delete);
                }

                using (var context = new XiaoluEntities())
                {
                    var repository = new HistoryRepository(context);
                    repository.BulkDelete(list4delete);
                    context.SaveChanges();
                    msg = string.Format(XiaoluResources.MSG_BULK_ACTION_SUCCESS, XiaoluResources.STR_HISTORY, idArr.Length);
                    return(new BaseActionResult(true, msg));
                }
            }
            catch (Exception e)
            {
                msg = string.Format(XiaoluResources.MSG_BULK_ACTION_FAIL, XiaoluResources.STR_DELETE, idArr.Length) + string.Format(XiaoluResources.STR_FAIL_RESAON, ExceptionHelper.GetInnerExceptionInfo(e));
                return(new BaseActionResult(false, msg, e));
            }
        }
Ejemplo n.º 24
0
        public static BaseActionResult CreateHistory(History obj4create)
        {
            string msg;
            if (obj4create == null)
            {
                msg = string.Format(XiaoluResources.MSG_CREATE_SUCCESS, XiaoluResources.STR_HISTORY) + string.Format(XiaoluResources.STR_FAIL_RESAON, XiaoluResources.MSG_OBJECT_IS_NULL);
                return new BaseActionResult(false, msg);
            }

            try
            {
                using (var context = new XiaoluEntities())
                {
                    var repository = new HistoryRepository(context);
                    string newId = Guid.NewGuid().ToString();
                    obj4create.Id = newId;
                    repository.Create(obj4create);
                    context.SaveChanges();
                    msg = string.Format(XiaoluResources.MSG_CREATE_SUCCESS, obj4create.UserId);
                    return new BaseActionResult(true, msg);
                }
            }
            catch (Exception e)
            {
                msg = string.Format(XiaoluResources.MSG_CREATE_FAIL, obj4create.UserId) + string.Format(XiaoluResources.STR_FAIL_RESAON, ExceptionHelper.GetInnerExceptionInfo(e));
                return new BaseActionResult(false, msg);
            }
        }
Ejemplo n.º 25
0
        public static BaseActionResult BulkDeleteHistoryByIds(string idsStr)
        {
            string msg;
            string[] idArr = idsStr.Split(',');
            if (idArr.Length == 0)
            {
                msg = XiaoluResources.ERR_MSG_NO_RECORD_FOR_ACTION;
                return new BaseActionResult(false, msg);
            }
            try
            {
                List<History> list4delete = new List<History>();
                foreach (string id in idArr)
                {
                    var obj4delete = GetHistoryById(id);
                    list4delete.Add(obj4delete);
                }

                using (var context = new XiaoluEntities())
                {
                    var repository = new HistoryRepository(context);
                    repository.BulkDelete(list4delete);
                    context.SaveChanges();
                    msg = string.Format(XiaoluResources.MSG_BULK_ACTION_SUCCESS, XiaoluResources.STR_HISTORY, idArr.Length);
                    return new BaseActionResult(true, msg);
                }
            }
            catch (Exception e)
            {
                msg = string.Format(XiaoluResources.MSG_BULK_ACTION_FAIL, XiaoluResources.STR_DELETE, idArr.Length) + string.Format(XiaoluResources.STR_FAIL_RESAON, ExceptionHelper.GetInnerExceptionInfo(e));
                return new BaseActionResult(false, msg, e);
            }
        }
        public void Create_history_context_from_user_context()
        {
            var serviceProvider = TestHelpers.CreateServiceProvider();

            using (var context = new Context(serviceProvider))
            {
                var historyRepository = new HistoryRepository(
                    serviceProvider,
                    new DbContextService <IDbContextOptions>(new DbContextOptions()),
                    new DbContextService <DbContext>(context));

                using (var historyContext = historyRepository.CreateHistoryContext())
                {
                    Assert.Same(historyRepository.HistoryModel, historyContext.Model);

                    var options        = ((IDbContextServices)context).ScopedServiceProvider.GetRequiredService <DbContextService <IDbContextOptions> >();
                    var historyOptions = ((IDbContextServices)historyContext).ScopedServiceProvider.GetRequiredService <DbContextService <IDbContextOptions> >();

                    var extensions        = options.Service.Extensions;
                    var historyExtensions = historyOptions.Service.Extensions;

                    Assert.Equal(extensions.Count, historyExtensions.Count);

                    for (var i = 0; i < extensions.Count; i++)
                    {
                        Assert.Same(extensions[i], historyExtensions[i]);
                    }
                }
            }
        }
Ejemplo n.º 27
0
 public UrlController()
 {
     urlRepository  = new UrlRepository();
     userRepository = new UserRepository();
     logRepository  = new LogRepository();
     histRepository = new HistoryRepository();
 }
        public void Create_and_cache_history_model()
        {
            var serviceProvider = TestHelpers.CreateServiceProvider();

            using (var context = new Context(serviceProvider))
            {
                var historyRepository = new HistoryRepository(
                    serviceProvider,
                    new DbContextService <IDbContextOptions>(new DbContextOptions()),
                    new DbContextService <DbContext>(context));

                var historyModel1 = historyRepository.HistoryModel;
                var historyModel2 = historyRepository.HistoryModel;

                Assert.Same(historyModel1, historyModel2);
                Assert.Equal(1, historyModel1.EntityTypes.Count);

                var entityType = historyModel1.EntityTypes[0];
                Assert.Equal("Microsoft.Data.Entity.Migrations.Infrastructure.HistoryRow", entityType.Name);
                Assert.Equal(3, entityType.Properties.Count);
                Assert.Equal(new[] { "ContextKey", "MigrationId", "ProductVersion" }, entityType.Properties.Select(p => p.Name));

                Assert.Equal(150, entityType.Properties.Single(p => p.Name == "MigrationId").MaxLength);
                Assert.Equal(300, entityType.Properties.Single(p => p.Name == "ContextKey").MaxLength);
                Assert.Equal(32, entityType.Properties.Single(p => p.Name == "ProductVersion").MaxLength);
            }
        }
        public void Update_down_when_explicit_and_automatic_should_migrate_to_target_version()
        {
            ResetDatabase();

            var historyRepository = new HistoryRepository(ConnectionString, ProviderFactory, "MyKey", null);

            var migrator = CreateMigrator <ShopContext_v2>();

            migrator.Update();

            Assert.True(TableExists("crm.tbl_customers"));

            migrator = CreateMigrator <ShopContext_v3>(automaticDataLossEnabled: true);

            var generatedMigration = new MigrationScaffolder(migrator.Configuration).Scaffold("Migration");

            migrator = CreateMigrator <ShopContext_v3>(
                automaticDataLossEnabled: true,
                scaffoldedMigrations: generatedMigration);

            migrator.Update();

            Assert.True(TableExists("crm.tbl_customers"));

            migrator.Update(DbMigrator.InitialDatabase);

            Assert.False(TableExists("MigrationsStores"));
            Assert.False(TableExists("tbl_customers"));
            Assert.Null(historyRepository.GetLastModel());
        }
        public static void OptimizeNotMain(string toolName, int startStop, int endStop, int stopStep)
        {
            var          repository       = new HistoryRepository(toolName, false);
            var          resultText       = new List <string>();
            const double breakevenPercent = 0.15;
            var          lastTradeTime    = new TimeSpan(15, 45, 00);
            const int    monotoneCount    = 4;
            const int    invertCount      = 3;
            const double stopPercent      = 1;

            //for (double stopPercent = 0.5; stopPercent < 1.6; stopPercent += 0.1)
            //{
            for (int stopLoss = startStop; stopLoss <= endStop; stopLoss += stopStep)
            {
                var strat = new MonotoneExtremumsStrategy(monotoneCount, stopLoss, invertCount, breakevenPercent, lastTradeTime, stopPercent);

                var result = strat.Run(repository.Days);
                result.PrintDepo(@"mono\depo\" + stopLoss + "_" + (int)(stopPercent * 10) + ".txt");

                if (result.DealsCount == 0)
                {
                    continue;
                }

                resultText.Add(stopLoss + " " + stopPercent);
                resultText.Add(result.ToString());
                resultText.Add("");
            }
            //}

            File.WriteAllLines(@"mono\out.txt", resultText);
        }
Ejemplo n.º 31
0
        public static void TestSecondExtremumsAlternation(string toolName, int pegTopSize)
        {
            //TODO ошибка в том, что реализм требует сортировки firstExtremums по checkerIndex, а текущий метод поиска secondExtremums - сортировки по Date. В общем случае, обоюдная сортировка невозможна
            var repository     = new HistoryRepository(toolName, false);
            var extremumFinder = new ExtremumsFinder(pegTopSize);

            bool bad = false;

            foreach (var day in repository.Days)
            {
                var firstMaximums = extremumFinder.FindFirstExtremums(day.FiveMins, false);
                var maximums      = extremumFinder.FindSecondExtremums(firstMaximums, false);

                var firstMinimums = extremumFinder.FindFirstExtremums(day.FiveMins, true);
                var minimums      = extremumFinder.FindSecondExtremums(firstMinimums, true);

                var allExtremums = maximums
                                   .Concat(minimums)
                                   .OrderBy(ex => ex.CheckerIndex)
                                   .ToList();

                for (int i = 0; i < allExtremums.Count - 1; ++i)
                {
                    if (allExtremums[i].Date >= allExtremums[i + 1].Date && allExtremums[i].IsMinimum == allExtremums[i + 1].IsMinimum)
                    {
                        bad = true;
                        Console.Out.WriteLine(allExtremums[i] + "\t" + allExtremums[i + 1]);
                    }
                }
            }
            Assert.That(!bad);
        }
Ejemplo n.º 32
0
        public HistoryRepositoryTests()
        {
            _data       = new List <History>();
            _repository = new HistoryRepository(Context.Object);
            _history    = new History
            {
                Id          = Guid.NewGuid(),
                UserId      = Guid.NewGuid(),
                Action      = UserAction.Add,
                Description = "Added",
                DateTime    = DateTime.Now,
                UserEmail   = "*****@*****.**",
                UserName    = "******",
                UserRole    = UserRole.Moderator,
                UserAddress = new Address
                {
                    Id        = 1,
                    CountryId = Guid.NewGuid(),
                    CityId    = Guid.NewGuid(),
                    Street    = "A"
                }
            };

            Context.Setup(c => c.CreateAsync(It.IsAny <History>()))
            .Callback((History item) => _data.Add(item))
            .Returns(Task.CompletedTask);
            Context.Setup(c => c.GetAll <History>())
            .Returns(() => _data.AsQueryable());
        }
Ejemplo n.º 33
0
        public void Can_explicit_update_when_custom_history_factory()
        {
            ResetDatabase();

            var migrator
                = CreateMigrator <ShopContext_v1>(historyContextFactory: _testHistoryContextFactoryA);

            var generatedMigration
                = new MigrationScaffolder(migrator.Configuration).Scaffold("Migration");

            migrator
                = CreateMigrator <ShopContext_v1>(
                      automaticMigrationsEnabled: false,
                      scaffoldedMigrations: generatedMigration,
                      historyContextFactory: _testHistoryContextFactoryA);

            migrator.Update();

            Assert.True(TableExists("MigrationsCustomers"));
            Assert.True(TableExists("__Migrations"));

            migrator.Update("0");

            Assert.False(TableExists("MigrationsCustomers"));
            Assert.False(TableExists("__Migrations"));

            var historyRepository = new HistoryRepository(ConnectionString, ProviderFactory, "MyKey", null);

            Assert.Null(historyRepository.GetLastModel());
        }
Ejemplo n.º 34
0
 public ActionResult GetAllHistory()
 {
     var historyRepo = new HistoryRepository();
     return JsonNet(new Histories()
     {
         Items = historyRepo.GetAllHistory()
     });
 }
Ejemplo n.º 35
0
 public ActionResult GetRecentHistory()
 {
     var historyRepo = new HistoryRepository();
     return JsonNet(new Histories()
     {
         Items = historyRepo.GetRecentHistory(DateTime.UtcNow.AddDays(-7))
     });
 }
Ejemplo n.º 36
0
        public MainPage()
        {
            this.InitializeComponent();

            this.NavigationCacheMode = NavigationCacheMode.Required;

            this.historyRepository = new HistoryRepository();
        }
Ejemplo n.º 37
0
        public static int CountHistoryByQuery(HistoryQuery query)
        {
            using (var context = new XiaoluEntities())
            {
                var repository = new HistoryRepository(context);

                int count = repository.GetPageCount(item => _isMatch(item, query));
                return count;
            }
        }
Ejemplo n.º 38
0
        public static BaseActionResult DeleteHistory(History obj4delete)
        {
            using (var context = new XiaoluEntities())
            {
                string msg;
                var repository = new HistoryRepository(context);

                if (obj4delete == null)
                {
                    msg = string.Format(XiaoluResources.MSG_DELETE_SUCCESS, XiaoluResources.STR_HISTORY) + string.Format(XiaoluResources.STR_FAIL_RESAON, XiaoluResources.MSG_OBJECT_IS_NULL);
                    return new BaseActionResult(false, msg);
                }
                repository.Delete(obj4delete);
                context.SaveChanges();
                msg = string.Format(XiaoluResources.MSG_UPDATE_SUCCESS, obj4delete.UserId);
                return new BaseActionResult(true, msg);
            }
        }
Ejemplo n.º 39
0
        public static List<History> GetHistoryListByQuery(HistoryQuery query)
        {
            using (var context = new XiaoluEntities())
            {
                var repository = new HistoryRepository(context);

                List<History> historys = repository.GetPageList(item => _isMatch(item, query), item => _orderByKey(item, query), query.OrderByValue, query.Offset, query.Limit);
                return historys;
            }
        }