Exemplo n.º 1
0
        /// <summary>
        /// Calculate Box Width acording to BoxSize
        /// </summary>
        /// <param name="boxConfig"></param>
        /// <param name="priceCache"></param>
        /// <returns></returns>
        private List <BoxSize> CalculateBoxes(List <BoxSize> boxConfig, IMicrographCache priceCache)
        {
            var graphData = priceCache.GetGraphData();

            // Only send pairs with graph data
            var filtered = boxConfig.Where(c => graphData.ContainsKey(c.AssetPair));

            // Get Volatility
            var Volatility = GetVolatilities();

            // Calculate BoxWidth according to average prices
            // BoxWidth = average(asset.midprice) * Box.PriceSize from database
            var retval = (from b in filtered
                          select new BoxSize
            {
                AssetPair = b.AssetPair,
                BoxesPerRow = b.BoxesPerRow,
                BoxHeight = b.BoxHeight,
                TimeToFirstBox = b.TimeToFirstBox,
                BoxWidth = CalcBoxWidth(b.AssetPair, graphData[b.AssetPair], Volatility[b.AssetPair], b.ScaleK, b.BoxWidth),
                SaveHistory = b.SaveHistory,
                GameAllowed = b.GameAllowed
            }).ToList();

            return(retval);
        }
Exemplo n.º 2
0
        public Dictionary <string, Price[]> InitChartData()
        {
            // Request data from RabbitMq and forward it.

            try
            {
                return(_micrographCacheService.GetGraphData());
            }
            catch (Exception ex)
            {
                LogError("InitChartData", ex);
                return(null);
            }
        }