public bool Save(string key, CalculateTechnicalIndicatorResponse response)
        {
            var cachedData = _client.Get <CalculateTechnicalIndicatorResponse>(key);

            if (cachedData == null)
            {
                var expireInTimespan = new TimeSpan(0, 0, 5, 0);
                _client.Add(key, response, expireInTimespan);
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public object Get(CalculateTechnicalIndicator request)
        {
            var response = new CalculateTechnicalIndicatorResponse();

            try
            {
                if (request.Type == IndicatorType.NONE)
                {
                    throw new ArgumentNullException("request", "[IndicatorType] field is empty");
                }
                if (request.Period1 < 0)
                {
                    throw new ArgumentNullException("request", "[Period1] field is negative number");
                }

                var currentChart = _cachingManager.GetCurrentChart("CurrentChart");
                if (currentChart == null)
                {
                    throw new DataException("No information about current chart was found");
                }
                else
                {
                    var cache = _cachingManager.GetTechnicalIndicators(currentChart.ToJson() + request.ToJson());
                    if (cache != null)
                    {
                        return(cache);
                    }
                    else
                    {
                        var cachedMarketData = _cachingManager.GetMarketData(currentChart.ToJson());
                        if (cachedMarketData == null)
                        {
                            throw new DataException("No market data for current chart was found. Please run GET /marketdata first.");
                        }
                        else
                        {
                            var parameters = IndicatorParametersFactory.Create(request.Type, request.Period1, request.Period2, request.Period3);
                            var result     = _technicalIndicatorsProvider.CalculateIndicator(cachedMarketData.Data, parameters);
                            if (result.Success)
                            {
                                response.Success = true;
                                response.Data    = result.Data;
                                _cachingManager.Save(currentChart.ToJson() + request.ToJson(), response);
                            }
                            else
                            {
                                response.ResponseStatus = new ResponseStatus(string.Empty, result.ErrorMessage);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var status = new ResponseStatus();
                status.Message    = ex.Message;
                status.ErrorCode  = ex.Source;
                status.StackTrace = ex.StackTrace;

                response.ResponseStatus = status;
            }

            return(response);
        }
		public object Get(CalculateTechnicalIndicator request)
		{
			var response = new CalculateTechnicalIndicatorResponse();

			try
			{
				if (request.Type == IndicatorType.NONE)
				{
					throw new ArgumentNullException("request", "[IndicatorType] field is empty");
				}
				if (request.Period1 < 0)
				{
					throw new ArgumentNullException("request", "[Period1] field is negative number");
				}

				var currentChart = _cachingManager.GetCurrentChart("CurrentChart");
				if (currentChart == null)
				{
					throw new DataException("No information about current chart was found");
				}
				else
				{
					var cache = _cachingManager.GetTechnicalIndicators(currentChart.ToJson() + request.ToJson());
					if (cache != null)
					{
						return cache;
					}
					else
					{
						var cachedMarketData = _cachingManager.GetMarketData(currentChart.ToJson());
						if (cachedMarketData == null)
						{
							throw new DataException("No market data for current chart was found. Please run GET /marketdata first.");
						}
						else
						{
							var parameters = IndicatorParametersFactory.Create(request.Type, request.Period1, request.Period2, request.Period3);
							var result = _technicalIndicatorsProvider.CalculateIndicator(cachedMarketData.Data, parameters);
							if (result.Success)
							{
								response.Success = true;
								response.Data = result.Data;
								_cachingManager.Save(currentChart.ToJson() + request.ToJson(), response);
							}
							else
							{
								response.ResponseStatus = new ResponseStatus(string.Empty, result.ErrorMessage);
							}
						}
					}
				}
			}
			catch (Exception ex)
			{
				var status = new ResponseStatus();
				status.Message = ex.Message;
				status.ErrorCode = ex.Source;
				status.StackTrace = ex.StackTrace;

				response.ResponseStatus = status;
			}

			return response;
		}
		public bool Save(string key, CalculateTechnicalIndicatorResponse response)
		{
			var cachedData = _client.Get<CalculateTechnicalIndicatorResponse>(key);
			if (cachedData == null)
			{
				var expireInTimespan = new TimeSpan(0, 0, 5, 0);
				_client.Add(key, response, expireInTimespan);
				return true;
			}
			else
			{
				return false;
			}
		}