Exemple #1
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);
        }
Exemple #2
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}");
        }
        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);
        }
Exemple #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);
        }
Exemple #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);
        }
        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);
        }
Exemple #7
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;
        }