public void SplitStringTest_ShouldReturnListOfString(string[] expectedArr, string source) { var actual = DataAnalyzer.SplitString(source); var expected = expectedArr.ToList(); CollectionAssert.AreEqual(expected, actual); }
/// <summary> /// The load event for the DataDisplayForm. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DataDisplayForm_Load(object sender, EventArgs e) { // Setup the controls for this form SetupDataDisplayForm SetupDataDisplayForm_ = new SetupDataDisplayForm(this); SetupDataDisplayForm_.SetFormColors(ref foldClr, ref checkClr, ref callClr, ref betClr, ref foldClrFaded, ref checkClrFaded, ref callClrFaded, ref betClrFaded, ref whiteClrFaded, rtbBackgroundClr); SetupDataDisplayForm_.InitializeForm(); SetupDataDisplayForm_.InitializeFormPanels(ref dataPnl, ref legendFoldClrPnl, ref legendCheckClrPnl, ref legendCallClrPnl, ref legendBetClrPnl, ref dataUpdateStatusIndicator, ref dataUpdateStatusIndicatorBorder); SetupDataDisplayForm_.InitializeFormLabels(ref formTitleLbl, ref timeLbl, ref legendFoldLbl, ref legendCheckLbl, ref legendCallLbl, ref legendBetLbl, ref processingTimeOthersLbl, ref processingTimePlrOfInterestLbl, ref playerNameLbl, ref chartNoDataLbl, ref chartSampleCountLbl); SetupDataDisplayForm_.InitializeFormButtons(ref preFlopBtn, ref flopBtn, ref turnBtn, ref riverBtn); SetupDataDisplayForm_.InitializeFormCharts(ref pieChts, ref isChartUpToDate); SetupDataDisplayForm_.SetControlSizesAndLocations(); DisplayPreFlopData(); dataUpdateStpOthers = new Stopwatch(); dataUpdateStpPlrOfInterest = new Stopwatch(); dataAnalyzers = new DataAnalyzer[10]; playerActionData = new DataCounter[10]; for (int i = 0; i < 10; i++) { dataAnalyzers[i] = new DataAnalyzer(); playerActionData[i] = new DataCounter(); } // only 9 tasks (assuming a 9 player table) updateDataTasks = new Task[9]; }
public void ConvertToDecimalTest_ShouldReturnListOfDecimalValues(string[] sourceArr, double[] expectedArr) { var source = sourceArr.ToList(); var expected = expectedArr.Select(d => (decimal)d).ToList(); var actual = DataAnalyzer.ConvertToDecimals(source); Trace.Listeners.Add(new TextWriterTraceListener(Console.Out)); Trace.WriteLine("Expected: "); foreach (var element in expected) { Trace.Write($"{element} "); } Trace.WriteLine("Actual: "); foreach (var element in actual) { Trace.Write($"{element} "); } Trace.WriteLine(expected.ToString()); Trace.WriteLine(actual.ToString()); CollectionAssert.AreEqual(expected, actual); }
public BaseGraph(DataAnalyzer dataAnalyzer, IFileIterator fileIterator) { this.dataAnalyzer = dataAnalyzer; this.fileIterator = fileIterator; plotModel = new PlotModel(); this.refreshPlotsTimer = new Timer(); plotModel.TextColor = OxyColors.White; // y axis plotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Left, LabelFormatter = AxisLabelFormatter, TextColor = OxyColors.Transparent, TickStyle = TickStyle.None, }); // x axis plotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, LabelFormatter = AxisLabelFormatter, TextColor = OxyColors.Transparent, TickStyle = TickStyle.None, }); Plot = plotModel; }
public GeneratorData Generate(DataAnalyzer dataAnalyzer, ILogger logger) { if (!File.Exists(TemplatePath)) { throw new FileNotFoundException("Cannot find HTML template!"); } this.dataAnalyzer = dataAnalyzer; string htmlCode = File.ReadAllText(TemplatePath); var datas = new List <ChartJsData> { GenerateBestDay(), GenerateTotalTime(), GenerateDailyAverage(), GenerateCommonData(DataAnalyzer.DataType.Editors, "editorsData"), GenerateCommonData(DataAnalyzer.DataType.OperatingSystems, "osData"), GenerateCommonData(DataAnalyzer.DataType.Languages, "languagesData"), GenerateProjectsList() }; PutChartsData(ref htmlCode, datas); var data = new GeneratorData { DataName = $"data_{DateTime.Now:yyyyMMddHHmmss}", FileExtension = "html", Data = htmlCode }; return(data); }
private void AddEnoughPositions() { Order orderObject = null; PositionConfig pConfig = null; try { IEnumerable <Quote> quoteList = ExchangeObject.GetQuoteList(null, this.CurrentAccount.Id); //Service call 3 - Initially once and whenever new position added to account based on Max pos count foreach (Quote q in quoteList) { if (!IsSymbolAlreadyAvailable(q.Symbol)) { pConfig = this.GetPositionConfig(q.Symbol); if (pConfig != null) { if (pConfig.InitialUnits > pConfig.MinQuantity) { if (this.CurrentAccount.Type == "Long") { orderObject = new Order(q.Symbol, pConfig.InitialUnits, q.LastBuyTradePrice, Constants.OrderAction.BUY, this.OrderType); } else if (this.CurrentAccount.Type == "Short") { orderObject = new Order(q.Symbol, pConfig.InitialUnits, q.LastSellTradePrice, Constants.OrderAction.SELL, this.OrderType); } if (ExchangeObject.PlaceOrder(orderObject, this.CurrentAccount.Id)) //Service call 4 { if (orderObject.Status == Constants.OrderState.FILLED) { DataAnalyzer dt = new DataAnalyzer(orderObject.Symbol, this.CurrentAccount.Id, this.CurrentAccount.Type); Thread newThread = new Thread(dt.SaveActiveTicker); newThread.Name = "AnalyzerAdd"; newThread.Start(); } else if (orderObject.Status == Constants.OrderState.PENDING) { Console.WriteLine(DateTime.Now + " : Order status " + Constants.OrderState.PENDING); } else if (orderObject.Status == Constants.OrderState.CANCELLED) { Console.WriteLine(DateTime.Now + " : Order status " + Constants.OrderState.CANCELLED); } if (this.CurrentAccount.PositionList.Count >= this.MaxPositionCount) { return; } } } } } } return; } catch (Exception ex) { throw; } }
public FlightDashboard(IFileIterator fileIterator, DataAnalyzer dataAnalyzer) { this.fileIterator = fileIterator; this.dataAnalyzer = dataAnalyzer; // update the properties' values everytime we read new data this.fileIterator.OnLineChanged += Update; }
private bool PlaceSellOrder() { bool rtnVal = false; Order orderObject = null; //Need short buy change /*if (this.OrderType == Constants.OrderType.MARKET) * orderObject = new Order(this.StockObject.Symbol, this.StockObject.TotalCount, this.CurrentPrice, Constants.OrderAction.SELL, this.OrderType); * else if (this.StockObject.StrategyData.OrderType == Constants.OrderType.LIMIT) * orderObject = new Order(this.StockObject.Symbol, this.StockObject.TotalCount, this.CurrentPrice, Constants.OrderAction.SELL, this.OrderType);*/ if (this.CurrentAccount.Type == "Long") { orderObject = new Order(this.StockObject.Symbol, this.StockObject.TotalCount, this.CurrentPrice, Constants.OrderAction.SELL, this.OrderType); } else if (this.CurrentAccount.Type == "Short") { orderObject = new Order(this.StockObject.Symbol, (this.StockObject.TotalCount * -1), this.CurrentPrice, Constants.OrderAction.BUY, this.OrderType); } if (ExchangeObject.PlaceOrder(orderObject, this.CurrentAccount.Id)) //Service call 5 { if (orderObject.Status == Constants.OrderState.FILLED) { //Do this in new thread.. this.StockObject.TotalCount = orderObject.Count; this.StockObject.SellPrice = orderObject.Price; this.StockObject.TotalRevenue = (orderObject.Count * orderObject.Price) + orderObject.Brokerage; this.StockObject.TotalSellFee = orderObject.Brokerage; this.StockObject.ProfitnLoss = orderObject.PnL; this.StockObject.ModifiedOn = orderObject.DoneAt; this.StockObject.UserName = GetUserConfig(this.StockObject.Symbol).Name; this.StockObject.Status = Constants.PositionState.CLOSED; if (UpdatePositionsForDataAnalysis()) { DataAnalyzer dt = new DataAnalyzer(orderObject.Symbol, this.CurrentAccount.Id, this.CurrentAccount.Type); Thread newThread = new Thread(dt.CloseActiveTicker); newThread.Name = "AnalyzerAdd"; newThread.Start(); } else { Console.WriteLine("Error while writing to DB"); } rtnVal = true; } else if (orderObject.Status == Constants.OrderState.PENDING) { Console.WriteLine(DateTime.Now + " : Order status " + Constants.OrderState.PENDING); } else if (orderObject.Status == Constants.OrderState.CANCELLED) { Console.WriteLine(DateTime.Now + " : Order status " + Constants.OrderState.CANCELLED); } } return(rtnVal); }
//[MenuItem("DataAnalyzer/数据分析")] public static void ShowWindow() { DataAnalyzer window = new DataAnalyzer(); window.wantsMouseMove = true; window.titleContent = new GUIContent("数据分析"); window.Show(); window.Focus(); }
public void CalculateSumTest_ShouldReturnCorrectSumOfElements(double[] sourceArr, double expectedDouble) { decimal expected = (decimal)expectedDouble; var sourceList = sourceArr.Select(d => (decimal)d).ToList(); var actual = DataAnalyzer.CalculateSum(sourceList); Assert.AreEqual(actual, expected); }
public void DntNotAnalyzeIfSomeOfInputParametersAreNull(IEnumerable <IChangeableData> a, IEnumerable <IChangeableData> b) { List <string> detectedItems = new List <string>(); DataAnalyzer analyzer = new DataAnalyzer(); analyzer.DetectedDifferenceEvent += (o, e) => detectedItems.Add(e); analyzer.Analyze(a, b); Assert.IsEmpty(detectedItems); }
public List <string> SimpleTestCases(IEnumerable <IChangeableData> a, IEnumerable <IChangeableData> b) { List <string> detectedItems = new List <string>(); DataAnalyzer analyzer = new DataAnalyzer(); analyzer.DetectedDifferenceEvent += (o, e) => detectedItems.Add(e); analyzer.Analyze(a, b); return(detectedItems); }
// [TestCaseSource(nameof(LongRunningTests))] public void RevenueTests(DateTime from, DateTime to, decimal result) { var catalog = new Catalog("catalog.csv"); using (var eventLog = new EventLog("events.csv")) { var dataAnalyzer = new DataAnalyzer(eventLog, catalog); var revenue = dataAnalyzer.GetRevenue(from, to); Assert.AreEqual(result, revenue); } }
public async Task CalculateTotalPlayTime_ShouldEqual100() { ApiHelper api = ApiHelper.Instance; api.SetKey(API_KEY); var data = await api.GetGamesForUser(TEST_OLD_ACC_URL, true); int totalTime = DataAnalyzer.CalculateTotalTimePlayed(data); Assert.AreEqual(3789, totalTime); }
public async Task FindLeastPlayedGame_ShouldBeMapleStory() { ApiHelper api = ApiHelper.Instance; api.SetKey(API_KEY); var data = await api.GetGamesForUser(TEST_OLD_ACC_URL, true); SimpleGameModel game = DataAnalyzer.FindLeastPlayedGame(data); Assert.AreEqual("MapleStory", game.name); // Note: 2 mins - doesn't show up on profile }
private void D_Progress(long bytesAnalyzed, EventArgs e, DataAnalyzer d) { System.Console.Write($"\rAnalyzed {d.PercentAnalyzed}% of all data"); if (Console.KeyAvailable) { var key = Console.ReadKey(); if (key.Key == ConsoleKey.Q) { d.Continue = false; } } }
public int CalculateDistance(Geometry routeGeometry) { if (routeGeometry == null || routeGeometry.GeometryType != GeometryType.Polyline) { return(0); } var wayPoints = routeGeometry.GetWayPoints(); var dataAnalyzer = new DataAnalyzer(wayPoints); var distances = dataAnalyzer.Distances; return((int)distances.Sum() / 1000); }
//[TestMethod] public async Task FindLeastExpensiveGame_ShouldBeFuri() { ApiHelper api = ApiHelper.Instance; api.SetKey(API_KEY); var data = await api.GetGamesForUser(TEST_OLD_ACC_URL, true); SimpleGameModel game = DataAnalyzer.FindMostPlayedGame(data); Assert.AreEqual("Nier", game.name); }
public void calculateDivideDataTest_DataInbasicDailyAndAnalyzedDataShouldEqualWhileHasPreviousAnalyzedData() { DataAnalyzer dataAnalyzer = new DataAnalyzer(); dataAnalyzer.setBasicDailyData(basicDailyData); dataAnalyzer.setAnalyzedData(analyzedData); dataAnalyzer.standarizeAnalyzeData(); for (int i = 0; i < basicDailyData.Count; i++) { Assert.IsTrue(dataAnalyzer.getAnalyzedData()[i].date == dataAnalyzer.getAnalyzedData()[i].date); } }
public void calculateDivideDataTest_WeightTestNullAnalyzeData() { DataAnalyzer dataAnalyzer = new DataAnalyzer(); dataAnalyzer.setBasicDailyData(basicDailyData); dataAnalyzer.setAnalyzedData(analyzedDataNull); dataAnalyzer.standarizeAnalyzeData(); Assert.AreEqual(1, dataAnalyzer.getAnalyzedData()[0].divideWeight); Assert.AreEqual(1, dataAnalyzer.getAnalyzedData()[1].divideWeight); Assert.AreEqual(1, dataAnalyzer.getAnalyzedData()[2].divideWeight); Assert.AreEqual(2, dataAnalyzer.getAnalyzedData()[3].divideWeight); Assert.AreEqual(2, dataAnalyzer.getAnalyzedData()[4].divideWeight); Assert.AreEqual(1, dataAnalyzer.getAnalyzedData()[5].divideWeight); }
private void UpdateAccountDetails() { DataAnalyzer dt = null; ExchangeObject.GetAccountChanges(this.CurrentAccount); //Service call 2 - Every Do-While loop delay thread sleep this.CurrentAccount.Type = GetAccountType(this.CurrentAccount.Id); if (this.CurrentAccount.OpenedTradesJson != null) { dt = new DataAnalyzer(string.Empty, this.CurrentAccount.Id, this.CurrentAccount.Type); dt.NewTrades = this.CurrentAccount.OpenedTradesJson; Thread newThread = new Thread(dt.SaveNewTrades); newThread.Name = "AnalyzerExpSave"; newThread.Start(); } }
public pgAudioRecording() { InitializeComponent(); audioBuffer = new AudioBuffer(); resultBuffer = new ResultBuffer(); audioRecording = new AudioRecording(audioBuffer); apiHelper = new API_Helper(audioBuffer, resultBuffer, ConfigFileHelper.ConfigApiAddress); dataAnalyzer = new DataAnalyzer(resultBuffer); cts = new CancellationTokenSource(); RecordingStateChanged += OnRecordingStateChanged; }
public async Task FindTotalAchievementPercentange_ShouldBe50Percent() { ApiHelper api = ApiHelper.Instance; api.SetKey(API_KEY); var gameList = await api.GetGamesForUser(TEST_OLD_ACC_URL); var appIds = gameList.Select(g => g.appid).ToList(); var achievementList = await api.GetSimpleAchievementsForUser(TEST_OLD_ACC_URL, appIds); double completion = DataAnalyzer.CalculateAchievementPercentage(achievementList); Assert.AreEqual(0.0978, completion); }
public async Task FindTotalGameWorth() { ApiHelper api = ApiHelper.Instance; api.SetKey(API_KEY); var data = await api.GetGamesForUser(TEST_OLD_ACC_URL, true); var appIds = data.Select(sgm => sgm.appid).ToList(); var detailedData = await api.GetDetailedGameInfos(appIds); double worth = DataAnalyzer.CalculateTotalGameWorth(detailedData); Assert.AreEqual(150.98, worth); }
public TimeTableViewModel(IEnumerable <Data> datas) { //TimeTableList = new ObservableCollection<string[]>(); //for (int i = 0; i < 5; i++) { // TimeTableList.Add(new string[6]); // for (int j = 0; j < 6; j++) { // TimeTableList[i][j] = ""; // } //} foreach (Data e in datas) { DataAnalyzer analyzer = new DataAnalyzer(); var analyzedData = analyzer.DayAnalyze(e.Day); analyzedData.ForEach(dayData => { //TimeTableList.Add(new TimeTableData(dayData[0], dayData[1], e.SubjectName)); if (dayData != null) { //TimeTableList[dayData[0]][dayData[1] - 1] = e.SubjectName; switch (dayData[0]) { case 0: MondaySubj[dayData[1] - 1] = e.SubjectName; break; case 1: TuesdaySubj[dayData[1] - 1] = e.SubjectName; break; case 2: WednesdaySubj[dayData[1] - 1] = e.SubjectName; break; case 3: ThursdaySubj[dayData[1] - 1] = e.SubjectName; break; case 4: FridaySubj[dayData[1] - 1] = e.SubjectName; break; default: break; } } }); } }
public void AnalyzeTest_ShouldReturnCorrectSumAndIndices(double expectedDouble, int[] maxIndices, int[] badIndices, string path) { var analyzer = new DataAnalyzer(path); var expectedMaxSum = (decimal)expectedDouble; var expectedMaxIndices = maxIndices.ToList(); var expectedBadIndices = badIndices.ToList(); analyzer.Analyze(); var maxSumValueEqual = analyzer.MaxSum == expectedMaxSum; var actualMaxIndices = analyzer.MaxSumIndices; var actualBadIndices = analyzer.BadStringsIndices; var indicesEqual = expectedMaxIndices.SequenceEqual(actualMaxIndices); var actual = maxSumValueEqual && indicesEqual; Assert.IsTrue(actual); }
public FlightJoystick(IFileIterator fileIterator, DataAnalyzer dataAnalyzer) { this.fileIterator = fileIterator; this.dataAnalyzer = dataAnalyzer; // reposition the knob when we read new data fileIterator.OnLineChanged += Update; // init size and position // radius is half the width (diameter) padRadius = JOYSTICK_SIZE / 2; knobRadius = padRadius / 2; center = padRadius - knobRadius; // set the initial position to the center KnobX = KnobY = center; }
//[TestMethod] public async Task FindLeastWorthGame_ShouldBeFuri() { ApiHelper api = ApiHelper.Instance; api.SetKey(API_KEY); var data = await api.GetGamesForUser(TEST_OLD_ACC_URL, true); var appids = data.Select(d => d.appid).ToList(); var detailedData = await api.GetDetailedGameInfos(appids); var value = DataAnalyzer.FindMostWorthGame(data, detailedData); Assert.AreEqual("Nier", value.detailedGame.name); Assert.AreEqual(10, value.value); }
public void TestGetSensorThreshold() { DataAnalyzer da = new DataAnalyzer(); var act1 = da.GetSensorThreshold(new uint[] { 17, 18 }); Assert.AreEqual(2, act1.Count); Assert.AreEqual(2, act1[0].LevelNumber); Assert.AreEqual(1, act1[1].LevelNumber); var act2 = da.GetSensorThreshold(null); Assert.AreEqual(0, act2.Count); var act3 = da.GetSensorThreshold(new uint[] {}); Assert.AreEqual(0, act3.Count); }
public void RequestDataFromAPI() { try { SensorPacket[] sensorData = new SensorPacket[6]; ManualControlPacket manualControls = new ManualControlPacket(); AutomationPacket automationData = new AutomationPacket(); foreach (string path in _apiPaths) { string result = _apiCaller.GetGreenhouseData(path); switch (path) { case "/api/sensors": sensorData = JsonConvert.DeserializeObject <SensorPacket[]>(result); break; case "/api/manualcontrols": manualControls = JsonConvert.DeserializeObject <ManualControlPacket>(result); break; case "/api/automation": automationData = JsonConvert.DeserializeObject <AutomationPacket>(result); break; case "/api/state": bool success = _apiCaller.PostGreenhouseState(path); if (!success) { Console.WriteLine("Could not successfully POST greenhouse state."); } break; default: break; } } DataAnalyzer analyzer = new DataAnalyzer(); analyzer.ExecuteActions(sensorData, manualControls, automationData); } catch (Exception ex) { Console.WriteLine(ex.Message); } }