public AnalyticData ProcessData() { AnalyticData data = new AnalyticData(); Streak currentStreak = Streak.Up; Streak previousRound = Streak.NoData; int currentStreakCount = 0; decimal priceAccumulator = 0; long volumeAccumulator = 0; Dictionary <int, int> sequenceDist = new Dictionary <int, int>(); data.Symbol = Symbol; data.RoundsCount = this.PriceSeries.Count; InitAnalytics(data); foreach (PriceData round in PriceSeries) { priceAccumulator += RoundPriceAvg(round); volumeAccumulator += round.Volume; MinsMaxs(data, round); StreakCalculator(data, ref currentStreak, ref previousRound, ref currentStreakCount, round, sequenceDist); } CalculateAverages(sequenceDist, data, volumeAccumulator, priceAccumulator, data.RoundsCount); return(data); }
private void MinsMaxs(AnalyticData data, PriceData round) { if (round.MaxPrice >= data.MaxPrice) { data.MaxPrice = round.MaxPrice; data.MaxPriceDate = round.Date; } if (round.MinPrice <= data.MinPrice) { data.MinPrice = round.MinPrice; data.MinPriceDate = round.Date; } if (round.MinPrice <= data.MinPrice) { data.MinPrice = round.MinPrice; data.MinPriceDate = round.Date; } if (round.Volume >= data.MaxVolume) { data.MaxVolume = round.Volume; data.MaxVolumeDate = round.Date; } if (round.Volume <= data.MinVolume) { data.MinVolume = round.Volume; data.MinVolumeDate = round.Date; } }
public virtual IList <IAnalytic> Stop(string enteredText, TimeSpan elapsed, bool isPeeking) { var analyses = new List <IAnalytic>(); AnalyticData data = new AnalyticData { TextShown = this.Sequence, TextEntered = enteredText, Elapsed = elapsed }; foreach (var analyticType in _analysesToRun) { var analysis = BaseAnalytic.Create(analyticType, data); analysis.Compute(); analyses.Add(analysis); } if (!isPeeking) { this.Analysis = new List <IAnalytic>(analyses); } return(analyses); }
public void AddEvent(string data) { AnalyticData log = new AnalyticData(data); this.sessionTimerData.Add(log); Debug.Log(log.readableTimeStamp + " : " + log.input); }
public void given_timespan_in_s_chars_per_sec_accurate_for_whole_numbers(string text, int numSeconds, int expected) { var time = new TimeSpan(0, 0, 0, numSeconds); var data = new AnalyticData() { Elapsed = time, TextEntered = text }; var speed = new Speed(data); speed.Compute(); Assert.That(speed.CharsPerSecond, Is.EqualTo(expected), string.Format("text {0} in {1}s should be {2}", text, numSeconds, expected)); }
public void given_timespan_in_s_wpm_accurate_for_fractions(int numSeconds, string text, double expected) { var time = new TimeSpan(0, 0, 0, numSeconds); var data = new AnalyticData() { Elapsed = time, TextEntered = text }; var speed = new Speed(data); speed.Compute(); Assert.That(speed.WordsPerMinute, Is.EqualTo(expected), string.Format("text {0} in {1}s should be {2}", text, numSeconds, expected)); }
private void InitAnalytics(AnalyticData data) { data.AvgDownsideStreakCount = 0; data.AvgUpsideStreakCount = 0; data.DownsideRoundsCount = 0; data.UpsideRoundsCount = 0; data.MaxDownsideStreakCount = 0; data.MaxUpsideStreakCount = 0; data.MaxPrice = 0; data.MaxVolume = 0; data.MinPrice = decimal.MaxValue; data.MinVolume = long.MaxValue; data.Sequence = new List <string>(); }
public void ProcessXMLData(XElement fileXML, int analyticReportAuxId) { IEnumerable <XElement> elems = fileXML.Descendants("section"); foreach (XElement x in elems) { AnalyticData analyticData = new AnalyticData { Section = x.Attribute("name").Value, Quantity = x.Attribute("count") == null ? 0 : Convert.ToInt32(x.Attribute("count").Value), AnalyticReportAuxId = analyticReportAuxId }; AnalyticDataDB.CreateObject(analyticData).SaveAnalyticData(); } }
private void StreakCalculator(AnalyticData data, ref Streak currentStreak, ref Streak previousRound, ref int currentStreakCount, PriceData round, Dictionary <int, int> sequenceDist) { if (round.ClosingPrice > round.OpenPrice) { data.UpsideRoundsCount++; if (currentStreak == Streak.Down && previousRound == Streak.Up) { data.Sequence.Add($"{currentStreakCount}U"); UpdateSequenceDictionary(sequenceDist, -currentStreakCount); if (currentStreakCount > data.MaxDownsideStreakCount) { data.MaxDownsideStreakCount = currentStreakCount; } currentStreakCount = 2; currentStreak = Streak.Up; } else { currentStreakCount++; } previousRound = Streak.Up; } else if (round.ClosingPrice <= round.OpenPrice) { data.DownsideRoundsCount++; if (currentStreak == Streak.Up && previousRound == Streak.Down) { data.Sequence.Add($"{currentStreakCount}D"); UpdateSequenceDictionary(sequenceDist, currentStreakCount); if (currentStreakCount > data.MaxUpsideStreakCount) { data.MaxUpsideStreakCount = currentStreakCount; } currentStreakCount = 2; currentStreak = Streak.Down; } else { currentStreakCount++; } previousRound = Streak.Down; } }
public void given_timespan_in_s_chars_per_sec_accurate_for_fractions() { var time = new TimeSpan(0, 0, 0, 6); var data = new AnalyticData() { Elapsed = time, TextEntered = "ab" }; var speed = new Speed(data); speed.Compute(); double notRoundedExpected = (double)2 / 6; Assert.That(speed.CharsPerSecond, Is.Not.EqualTo(notRoundedExpected)); double roundedExpected = Math.Round((double)2 / 6, Constants.PRECISION_FOR_DECIMALS); Assert.That(speed.CharsPerSecond, Is.EqualTo(roundedExpected)); }
public void GetSession(int _sessionNumber) { data = dataList[_sessionNumber]; Debug.Log(data.pcName); line.SetVertexCount(data.lookLocation.Count - 1); for (int i = 0; i < data.lookLocation.Count - 1; i++) { line.SetPosition(i, data.lookLocation[0]); } playerPos.SetVertexCount(data.playerEyePos.Count - 1); for (int i = 0; i < data.playerEyePos.Count - 1; i++) { playerPos.SetPosition(i, data.playerEyePos[0]); } TextInfo tnfo = TextInfoPool.instance.PoolingText(); tnfo.info.text = "Player Pos"; tnfo.info.color = Color.cyan; tnfo.info.rectTransform.position = data.playerEyePos[0]; sessionNo = _sessionNumber; ShowObjectInfo(); if (data.lookAt == null) { Debug.Log("data.lookat didn't work"); } else { Debug.Log("lookat count " + data.lookAt.Count); } if (data.time == null) { Debug.Log("time didnlt work"); } else { foreach (CustomKVP kvp in data.time) { scene.text = "Scene Name: " + kvp.key + "\nTime in Scene: " + kvp.value; // Debug.Log("Scene name and Time spent "+kvp.key + " " + kvp.value); } } }
private void CalculateAverages(Dictionary <int, int> sequenceDist, AnalyticData data, long volumeAccumulator, decimal priceAccumulator, int roundCount) { data.AvgVolume = volumeAccumulator / roundCount; data.AvgPrice = (priceAccumulator / roundCount).TwoDecimalValues(); //int upCount = 0; //int upSum = 0; //int downCount = 0; //int downSum = 0; //foreach (int streak in sequenceDist.Keys) //{ // if(streak < 0) // { // downCount++; // downSum += sequenceDist[streak]; // } //} }
private AnalyticDataDB(AnalyticData _analyticData) => analyticData = _analyticData;
public static LootCrateOpenDialog SpawnLootCrateOpeningDialog(LootCrateType crateType, int amount, Camera hudCamera, Dialog.OnClose onClose, AnalyticData data) { if (Singleton <GameManager> .Instance.GetGameState() == GameManager.GameState.Undefined) { return(null); } LootCrateOpenDialog lootCrateOpenDialog = LootCrateOpenDialog.CreateLootCrateOpenDialog(); if (lootCrateOpenDialog != null && hudCamera != null) { lootCrateOpenDialog.transform.position = hudCamera.transform.position + Vector3.forward * 2.5f; lootCrateOpenDialog.gameObject.SetActive(true); lootCrateOpenDialog.onClose += onClose; lootCrateOpenDialog.AddLootCrate(crateType, amount, data, false, 0); } return(lootCrateOpenDialog); }