public async Task <IReadOnlyList <YesterdayCandleData> > GetStocks(CancellationToken ct) { Console.WriteLine("START SEARCHING"); var allStocks = await _contextProvider.Do(ctx => ctx.MarketStocksAsync(), ct); ct.ThrowIfCancellationRequested(); var acceptable = new List <YesterdayCandleData>(); var meetAmount = 0; foreach (var stock in allStocks.Instruments) { CandlePayload?candle = await MeetRequirements(stock, ct).ConfigureAwait(false); if (candle != null) { var data = YesterdayCandleData.Create(stock, candle); acceptable.Add(data); Console.WriteLine(data); meetAmount++; } } Console.WriteLine($"Meet: {meetAmount}/{allStocks.Instruments.Count}"); var topVolumes = PossibleVariants(acceptable); LogTopVolumes(topVolumes); return(topVolumes); }
public StockFollower(YesterdayCandleData stock, ContextProvider contextProvider, Action <PlacedOrder> addOrder, Status?status = null) { Stock = stock; _contextProvider = contextProvider; _addOrder = addOrder; if (status != null) { Status = status; } }
public static decimal Half(this YesterdayCandleData candle) => (candle.Open - candle.Close) / 2;
public static decimal Part(this YesterdayCandleData candle, decimal percent) => (candle.Open - candle.Close) / 100M * percent;