public async Task Should_Return_Price_Async()
        {
            TickerPrice ticker    = null;
            var         symbol    = "LTCBTC";
            var         cacheMock = new Mock <IExchangeIntegrationCache>(MockBehavior.Strict);

            cacheMock.Setup(repo => repo.GetAsync <TickerPrice>(ExchangesIntegratedType.Binance, symbol))
            .ReturnsAsync(ticker);

            cacheMock.Setup(c => c.AddAsync(It.IsAny <IEnumerable <TickerPrice> >(),
                                            ExchangesIntegratedType.Binance,
                                            It.IsAny <Func <TickerPrice, string> >()))
            .Returns(Task.CompletedTask);

            var clientMock = new Mock <IBinanceIntegrationClient>(MockBehavior.Strict);

            clientMock.Setup(c => c.GetTickerPricesAsync())
            .ReturnsAsync(new[] { new TickerPrice {
                                      Price = "1", Symbol = symbol
                                  } });

            var strategy = new BinanceIntegrationStrategy(cacheMock.Object, clientMock.Object);
            var price    = await strategy.GetCurrentPriceAsync("LTC", "BTC");

            Assert.True(price > 0);
        }
        public async Task Should_Return_Exception_When_Symbol_Not_Exists_In_Exchange_Async()
        {
            TickerPrice ticker    = null;
            var         symbol    = "nuncaterajsdhjkdhsajkdh";
            var         cacheMock = new Mock <IExchangeIntegrationCache>(MockBehavior.Strict);

            cacheMock.Setup(repo => repo.GetAsync <TickerPrice>(ExchangesIntegratedType.Binance, symbol))
            .ReturnsAsync(ticker);

            cacheMock.Setup(c => c.AddAsync(It.IsAny <IEnumerable <TickerPrice> >(),
                                            ExchangesIntegratedType.Binance,
                                            It.IsAny <Func <TickerPrice, string> >()))
            .Returns(Task.CompletedTask);

            var clientMock = new Mock <IBinanceIntegrationClient>(MockBehavior.Strict);

            clientMock.Setup(c => c.GetTickerPricesAsync())
            .ReturnsAsync(new[] { new TickerPrice {
                                      Price = "1", Symbol = "LTCBTC"
                                  } });

            var strategy = new BinanceIntegrationStrategy(cacheMock.Object, clientMock.Object);
            var ex       = await Assert.ThrowsAsync <InvalidOperationException>(async() => await strategy.GetCurrentPriceAsync("nuncatera", "jsdhjkdhsajkdh"));

            Assert.Equal($"symbol {symbol} not exists in Binance", ex.Message);
        }
Exemplo n.º 3
0
        public async Task Should_Return_Exception_When_Symbol_Not_Exists_In_Exchange_Async()
        {
            TickerPrice ticker    = null;
            var         symbol    = "nuncatera-jsdhjkdhsajkdh";
            var         cacheMock = new Mock <IExchangeIntegrationCache>(MockBehavior.Strict);

            cacheMock.Setup(repo => repo.GetAsync <TickerPrice>(ExchangesIntegratedType.KuCoin, symbol))
            .ReturnsAsync(ticker);

            cacheMock.Setup(repo => repo.AddAsync(It.IsAny <TickerPrice>(),
                                                  ExchangesIntegratedType.KuCoin,
                                                  It.IsAny <string>()))
            .Returns(Task.CompletedTask);

            var clientMock = new Mock <IKuCoinIntegrationClient>(MockBehavior.Strict);

            clientMock.Setup(c => c.GetTickerPriceAsync(symbol))
            .ReturnsAsync(new ResponseData <TickerPrice> {
                Code = "200", Data = null
            });

            var strategy = new KuCoinIntegrationStrategy(cacheMock.Object, clientMock.Object);
            var ex       = await Assert.ThrowsAsync <InvalidOperationException>(async() => await strategy.GetCurrentPriceAsync("nuncatera", "jsdhjkdhsajkdh"));

            Assert.Equal($"symbol {symbol} not exists in KuCoin", ex.Message);
        }
Exemplo n.º 4
0
        public IEXClientFixture()
        {
            Client = new IEXClient("pk_71ba0d8d98ed4d2caac8089588d62973");

            var t = Client.GetOptions("TEUM");

            t.Wait();

            Options = t.Result;

            var dt = Client.GetOptionDetails("TEUM", "201909");

            dt.Wait();

            OptionDetails = dt.Result;

            var price = Client.GetPrice("TEUM");

            price.Wait();

            Price = price.Result;

            var active = Client.GetMostActive();

            active.Wait();

            MostActive = active.Result;

            var search = Client.Search("stitch");

            search.Wait();

            SearchResults = search.Result;
        }
Exemplo n.º 5
0
        public async Task Should_Return_Price_Async()
        {
            TickerPrice ticker    = null;
            var         symbol    = "BTC-USDT";
            var         cacheMock = new Mock <IExchangeIntegrationCache>(MockBehavior.Strict);

            cacheMock.Setup(repo => repo.GetAsync <TickerPrice>(ExchangesIntegratedType.KuCoin, symbol))
            .ReturnsAsync(ticker);

            cacheMock.Setup(repo => repo.AddAsync(It.IsAny <TickerPrice>(),
                                                  ExchangesIntegratedType.KuCoin,
                                                  It.IsAny <string>()))
            .Returns(Task.CompletedTask);

            var clientMock = new Mock <IKuCoinIntegrationClient>(MockBehavior.Strict);

            clientMock.Setup(c => c.GetTickerPriceAsync(symbol))
            .ReturnsAsync(new ResponseData <TickerPrice> {
                Code = "200", Data = new TickerPrice {
                    Price = "1"
                }
            });

            var strategy = new KuCoinIntegrationStrategy(cacheMock.Object, clientMock.Object);
            var price    = await strategy.GetCurrentPriceAsync("BTC", "USDT");

            Assert.True(price > 0);
        }
        public async Task Should_Return_Exception_When_Symbol_Not_Exists_In_Exchange_Async()
        {
            TickerPrice ticker    = null;
            var         symbol    = "nuncatera-jsdhjkdhsajkdh";
            var         cacheMock = new Mock <IExchangeIntegrationCache>(MockBehavior.Strict);

            cacheMock.Setup(repo => repo.GetAsync <TickerPrice>(ExchangesIntegratedType.Coinbase, symbol))
            .ReturnsAsync(ticker);

            cacheMock.Setup(repo => repo.AddAsync(It.IsAny <TickerPrice>(),
                                                  ExchangesIntegratedType.Coinbase,
                                                  It.IsAny <string>()))
            .Returns(Task.CompletedTask);

            var clientMock = new Mock <ICoinbaseIntegrationClient>(MockBehavior.Strict);

            clientMock.Setup(c => c.GetTickerPriceAsync(symbol))
            .ReturnsAsync(new TickerPrice {
                Price = "0"
            });

            var strategy = new CoinbaseIntegrationStrategy(cacheMock.Object, clientMock.Object);
            var price    = await strategy.GetCurrentPriceAsync("nuncatera", "jsdhjkdhsajkdh");

            Assert.Equal(0, price);
        }
        public async Task Should_Return_Price_Async()
        {
            TickerPrice ticker    = null;
            var         symbol    = "BTC-GBP";
            var         cacheMock = new Mock <IExchangeIntegrationCache>(MockBehavior.Strict);

            cacheMock.Setup(repo => repo.GetAsync <TickerPrice>(ExchangesIntegratedType.Coinbase, symbol))
            .ReturnsAsync(ticker);

            cacheMock.Setup(repo => repo.AddAsync(It.IsAny <TickerPrice>(),
                                                  ExchangesIntegratedType.Coinbase,
                                                  It.IsAny <string>()))
            .Returns(Task.CompletedTask);

            var clientMock = new Mock <ICoinbaseIntegrationClient>(MockBehavior.Strict);

            clientMock.Setup(c => c.GetTickerPriceAsync(symbol))
            .ReturnsAsync(new TickerPrice {
                Price = "1"
            });

            var strategy = new CoinbaseIntegrationStrategy(cacheMock.Object, clientMock.Object);
            var price    = await strategy.GetCurrentPriceAsync("BTC", "GBP");

            Assert.Equal(1, price);
        }
Exemplo n.º 8
0
 public IEXClientTests(IEXClientFixture fixture, Xunit.Abstractions.ITestOutputHelper output)
 {
     _options       = fixture.Options;
     _optionDetails = fixture.OptionDetails.ToArray();
     _price         = fixture.Price;
     _client        = fixture.Client;
     _output        = output;
     _mostActive    = fixture.MostActive;
     _search        = fixture.SearchResults;
 }
Exemplo n.º 9
0
 internal void Enrich(TickerPrice p, StockAdvancedStats d)
 {
     Apply(
         new NoteEnrichedWithPrice(
             Guid.NewGuid(),
             this.Id,
             DateTimeOffset.UtcNow,
             p,
             d
             )
         );
 }
Exemplo n.º 10
0
 public ReviewEntry(OwnedStock s)
 {
     Created     = null;
     Ticker      = s.Ticker;
     Description = s.Description;
     Expiration  = null;
     IsExpired   = false;
     ExpiresSoon = false;
     DaysLeft    = null;
     Stats       = null;
     Price       = new TickerPrice();
     IsOption    = false;
     IsNote      = false;
 }
Exemplo n.º 11
0
 public ReviewEntry(OwnedOption o)
 {
     Created     = null;
     Ticker      = o.Ticker;
     Description = o.Description;
     Expiration  = o.Expiration;
     IsExpired   = o.IsExpired;
     ExpiresSoon = o.ExpiresSoon;
     DaysLeft    = o.DaysLeft;
     Stats       = null;
     Price       = new TickerPrice();
     IsOption    = true;
     IsNote      = false;
 }
Exemplo n.º 12
0
        public ReviewEntryGroup(IEnumerable <ReviewEntry> entries, TickerPrice price, StockAdvancedStats stats)
        {
            this.Notes     = new List <ReviewEntry>();
            this.Ownership = new List <ReviewEntry>();
            this.Price     = price;
            this.Ticker    = null;
            this.Stats     = stats;

            foreach (var e in entries.OrderByDescending(e => e.Created))
            {
                this.Ticker = e.Ticker;

                if (e.IsNote)
                {
                    this.Notes.Add(e);
                }
                else
                {
                    this.Ownership.Add(e);
                }
            }
        }
Exemplo n.º 13
0
 internal void Apply(NoteEnrichedWithPrice enriched)
 {
     this.StatsApplied = enriched.When;
     this.Stats        = enriched.Stats;
     this.Price        = enriched.Price;
 }
Exemplo n.º 14
0
 public GridEntry(string ticker, TickerPrice price, StockAdvancedStats stats)
 {
     this.Price  = price.Amount;
     this.Ticker = ticker;
     this.Stats  = stats;
 }
Exemplo n.º 15
0
 public NoteEnrichedWithPrice(Guid id, Guid aggregateId, DateTimeOffset when, TickerPrice price, StockAdvancedStats stats)
     : base(id, aggregateId, when)
 {
     this.Price = price;
     this.Stats = stats;
 }