Пример #1
0
        private async Task <Unit> PriceUpdated(Ticker ticker)
        {
            if (!IsInTestMode)
            {
                await _traderGrain.UpdateTrades(TraderState.Trades);

                await _hubNotifier.UpdateTicker(ticker);
            }
            return(Unit.Default);
        }
Пример #2
0
        public async Task <Unit> UpdateOrder(CryptoOrder cryptoOrder)
        {
            if (!IsInTestMode)
            {
                await _traderGrain.UpdateTrades(TraderState.Trades);

                var traderData = await _traderGrain.GetTraderData();

                traderData.CurrentTicker = Ticker;
                await _hubNotifier.UpdateTrader(traderData);
            }
            return(await Task.FromResult(Unit.Default));
        }
Пример #3
0
        public async Task <Unit> UpdatePrice(Ticker ticker)
        {
            if (IsInTestMode)
            {
                (_cryptoApi as FakeBittrexApi)?.UpdateBuyOrders(Ticker);
            }

            Ticker = ticker;
            if (_firstTicker == null)
            {
                _firstTicker = Ticker;
            }
            if (_tickerIndex == 1784)
            {
                Console.WriteLine("found one");
            }
            _tickerIndex++;
            if (ticker.Timestamp == default)
            {
                ticker.Timestamp = DateTime.UtcNow;
            }
            Debug.WriteLine($"Update {_tickerIndex}\t{ticker.Bid}\t{ticker.Bid.GetReadablePercentageChange(_firstTicker.Bid)}%");

            await UpdateTrades();

            if (!IsInTestMode)
            {
                await _traderGrain.UpdateTrades(Trades);

                await _hubNotifier.UpdateTicker(ticker);
            }

            if (IsInTestMode)
            {
                (_cryptoApi as FakeBittrexApi)?.UpdateSellOrders(Ticker);
            }
            return(Unit.Default);
        }
Пример #4
0
        public async Task StartAsync()
        {
            _traderGrain = _orleansClient.GetGrain <ITraderGrain>(Market);
            await _traderGrain.UpdateTrades(new List <Trade>());

            await _traderGrain.SetMarketAsync(Market);

            var traderState = await _traderGrain.GetTraderData();

            Trades = traderState.Trades ?? new List <Trade>();

            Strategy.Settings = TraderSettings.Default;
            if (Trades.Count == 0)
            {
                Trades.Add(new Trade {
                    Status = TradeStatus.Empty
                });
            }
        }
Пример #5
0
        public async Task StartAsync()
        {
            Strategy     = new HoldUntilPriceDropsStrategy();
            _traderGrain = _orleansClient.GetGrain <ITraderGrain>(Market);
            await _traderGrain.UpdateTrades(new List <Trade>());

            await _traderGrain.SetMarketAsync(Market);

            TraderState = await _traderGrain.GetTraderData();

            TraderState.Trades = TraderState.Trades ?? new List <Trade>();

            Strategy.Settings = TraderSettings.Default;
            if (TraderState.Trades.Count == 0)
            {
                TraderState.Trades.Add(new Trade {
                    Status = TradeStatus.Empty
                });
            }
            _cryptoBroker.Initialize(TraderState);
        }