Beispiel #1
0
        public List <PriceLevelDto> Calculate(List <Candle> candles, int pivotCount)
        {
            _logId = _batchLog.Start();
            _batchLog.Update(_logId, "Start Pivot Level High");

            var priceLevels = new List <PriceLevelDto>();

            foreach (var candle in candles)
            {
                var pastPivotHigh   = PivotHigh(candle, candle.PastCandles, pivotCount);
                var futurePivotHigh = PivotHigh(candle, candle.FutureCandles, pivotCount);

                if (!pastPivotHigh || !futurePivotHigh)
                {
                    //_batchLog.Update(_logId, $"Missing PastPivotHigh:{pastPivotHigh} FuturePivotHigh:{futurePivotHigh}");
                    continue;
                }

                _batchLog.Update(_logId, $"PivotHigh found: {candle.TimeFrame} {candle.TimeStamp}");

                var p = new PriceLevelDto()
                {
                    TimeStamp   = candle.TimeStamp,
                    Granularity = candle.TimeFrame,
                    Market      = candle.Market,
                    Active      = true,

                    AskPrice      = candle.Top().Ask,
                    AskPriceRange = candle.High.Ask,

                    BidPrice      = candle.Top().Bid,
                    BidPriceRange = candle.High.Bid,

                    Strategy    = "PIVOT HIGH " + pivotCount,
                    BuySell     = "SELL",
                    CandleType  = candle.BodyFillRate().ToString(CultureInfo.InvariantCulture),
                    LastUpdated = DateTime.Now
                };

                priceLevels.Add(p);
            }

            _logger.LogInformation(_batchLog.Print(_logId));

            return(priceLevels);
        }
Beispiel #2
0
 public async Task Add(PriceLevelDto value)
 {
     await Clients.All.Add(value);
 }
Beispiel #3
0
 public async Task Update(PriceLevelDto value)
 {
     await Clients.All.Update(value);
 }
Beispiel #4
0
 public async Task Delete(PriceLevelDto value)
 {
     await Clients.All.Delete(value);
 }
Beispiel #5
0
 public Task Update(PriceLevelDto level)
 {
     _logger.LogInformation($"Update received from TradeService  {level}");
     _context.Clients.All.SendAsync("Update", level);
     return(Task.CompletedTask);
 }
Beispiel #6
0
 public Task Delete(PriceLevelDto level)
 {
     _context.Clients.All.SendAsync("Delete", level);
     return(Task.CompletedTask);
 }