Esempio n. 1
0
        public void PersistenceTest()
        {
            IPersistence persister = new Persistence();

            List <IBar> bars = BarMocks.UpMove(1000, (double)100);

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            foreach (var bar in bars)
            {
                bar.BarId = 0;

                bar.Period = 100;

                Felix.Models.BarCreationRequest request = new Felix.Models.BarCreationRequest("YMH18", bar);

                persister.PersistBar(request);
            }

            stopwatch.Stop();

            Debug.WriteLine($"adding {bars.Count} bars took {stopwatch.ElapsedMilliseconds}");

            persister.Stop();

            //DateTime later = DateTime.Now;

            //Debug.WriteLine($"{bars.Count} bars took {later-now}");
        }
Esempio n. 2
0
        public async Task MultiBarServerTest()
        {
            List <IBar> bars = BarMocks.UpMove(1000, (double)100).ToList();

            BarPipeServer server = new BarPipeServer();

            int i = 0;

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            foreach (var bar in bars)
            {
                bar.BarId = 0;

                bar.Period = 100;

                BarService.AddBar(symbol, bar);
            }

            stopwatch.Stop();

            Debug.WriteLine($"this took {stopwatch.ElapsedMilliseconds}");

            Thread.Sleep(15000);
        }
Esempio n. 3
0
        public void DataCreationTests()
        {
            List <IBar> upTrendBars = BarMocks.UpMove(5, 100.00);

            List <IBarDatum> upTrendBarData = upTrendBars.ToBarDatum().ToList();

            var moveAlpha = Move.Open(moves.Count, upTrendBarData.First(), 2)
                            .Close(upTrendBarData.Last());

            Assert.IsNotNull(moveAlpha);

            Assert.IsTrue(moveAlpha.TrendType == 2);

            IBarDatum startBar = upTrendBarData.First();

            IBarDatum endBar = upTrendBarData.Last();

            Assert.IsTrue(moveAlpha.Start == startBar);

            Assert.IsTrue(moveAlpha.End == endBar);

            Assert.IsTrue(moveAlpha.StartIndex == startBar.Index);

            Assert.IsTrue(moveAlpha.EndIndex == endBar.Index);

            double expectedRange = endBar.High - startBar.Low;

            Assert.IsTrue(moveAlpha.Range == expectedRange);
        }
Esempio n. 4
0
        public void ClientTest()
        {
            IBar bar = BarMocks.UpMove(1, (double)100).ToList().First();

            Felix.Models.BarCreationRequest request = new Felix.Models.BarCreationRequest("YMH18", bar);

            IFelixHttpClient client = new FelixHttpClient();

            int barId = client.CreateBar(request).Result;

            Assert.IsTrue(barId > 0);
        }
Esempio n. 5
0
        public void AddBarTest()
        {
            client.BaseAddress = new Uri("http://localhost:9000/");

            client.DefaultRequestHeaders.Accept.Clear();

            client.DefaultRequestHeaders.Accept.Add(
                new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")
                );

            IBar bar = BarMocks.UpMove(1, (double)100).ToList().First();

            int newId = CreateBar(bar).Result;

            Assert.IsTrue(newId > 0);
        }
Esempio n. 6
0
        private void InitializeMoves()
        {
            List <IBar> upTrendBars = BarMocks.UpMove(5, 100.00);

            List <IBarDatum> upTrendBarData = upTrendBars.ToBarDatum().ToList();

            bars.AddRange(upTrendBarData);

            var moveAlpha = Move.Open(moves.Count, upTrendBarData.First(), 2)
                            .Close(upTrendBarData.Last());

            moves.Add(moveAlpha);

            IBarDatum last = moveAlpha.End;

            List <IBar> downTrend = BarMocks.DownMove(3, last.High - 10);

            List <IBarDatum> downData = downTrend.ToBarDatum().ToList();

            bars.AddRange(downData);

            var moveBeta = Move.Open(moves.Count, downData.First(), 3)
                           .Close(downData.Last());

            moves.Add(moveBeta);

            last = moveBeta.End;

            upTrendBars = BarMocks.UpMove(5, last.Low + 10);

            upTrendBarData = upTrendBars.ToBarDatum().ToList();

            bars.AddRange(upTrendBarData);

            var moveGamma = Move.Open(moves.Count, upTrendBarData.First(), 2)
                            .Close(upTrendBarData.Last());

            moves.Add(moveGamma);
        }
Esempio n. 7
0
        public void WaveTest()
        {
            InitializeMoves();

            IBarDatum lastTrendBar = moves.Last().End;

            List <IBar> testBar = BarMocks.DownMove(1, lastTrendBar.High - 5);

            List <IBarDatum> testDatum = testBar.ToBarDatum().ToList();

            bars.ForEach(b => moveManager.Insert(b));

            var ir = moveManager.Highs.Where(b => b.High < testDatum.First().Low)
                     .Select(b => b.High).ToList();

            var lowBarQuery = moveManager.Lows.Where(b => b.Low < testDatum.First().Low)
                              .Select(b => b.Low).ToList();

            ir.AddRange(lowBarQuery);

            Assert.IsTrue(ir.Count == 2);
        }
Esempio n. 8
0
        public async Task PersistAsyncTest()
        {
            var t = Task.Run(() =>
            {
                try
                {
                    List <IBar> bars = BarMocks.UpMove(1, (double)100);

                    DateTime now = DateTime.Now;

                    Felix.Models.BarCreationRequest request = new Felix.Models.BarCreationRequest("YMH18", bars.First());

                    persister.PersistBarAsTask(request);
                }
                catch (Exception e)
                {
                    Debug.WriteLine($"{e.Message}");

                    Debugger.Break();
                }
            });

            await t;
        }