Ejemplo n.º 1
0
        public static object SYMBOLNAME_OPTION(
            [ExcelArgument(Description = "に対応するオプション銘柄コードを取得する", Name = "限月")] string DerivMonth,
            [ExcelArgument(Description = "に対応するオプション銘柄コードを取得する", Name = "プット/コール区分")] string PutOrCall,
            [ExcelArgument(Description = "に対応するオプション銘柄コードを取得する", Name = "権利行使価格")] string StrikePrice)
        {
            string json = null;

            try
            {
                string ResultMessage = Validate.ValidateRequiredAll(DerivMonth, PutOrCall, StrikePrice);
                if (!string.IsNullOrEmpty(ResultMessage))
                {
                    return(ResultMessage);
                }

                Tuple <DateTime, string> tpl;
                var tplKey = string.Format("{0}-{1}-{2}", DerivMonth, PutOrCall, StrikePrice);
                if (_symbolNameOptionCache.TryGetValue(tplKey, out tpl))
                {
                    // ArrayResizerで3回元の関数が呼び出されるので、キャッシュでAPIの呼び出し回数を抑える
                    if ((DateTime.Now - tpl.Item1).TotalSeconds < 1)
                    {
                        json = tpl.Item2;
                    }
                }

                if (string.IsNullOrEmpty(json))
                {
                    json = middleware.GetSymbolNameOption(DerivMonth, PutOrCall, StrikePrice);
                    _symbolNameOptionCache[tplKey] = Tuple.Create(DateTime.Now, json);
                }

                object[] array = SymbolName.SymbolNameCheck(json);

                return(XlCall.Excel(XlCall.xlUDF, "Resize", array));
            }
            catch (Exception exception)
            {
                if (exception.InnerException == null)
                {
                    return(exception.Message);
                }
                else
                {
                    return(exception.InnerException.Message);
                }
            }
        }
Ejemplo n.º 2
0
        public static object SYMBOLNAME_FUTURE(
            [ExcelArgument(Description = "に対応する先物銘柄コードを取得する", Name = "先物コード")] string FutureCode,
            [ExcelArgument(Description = "に対応する先物銘柄コードを取得する", Name = "限月")] string DerivMonth)
        {
            string json = null;

            try
            {
                string ResultMessage = Validate.ValidateRequired(FutureCode, DerivMonth);
                if (!string.IsNullOrEmpty(ResultMessage))
                {
                    return(ResultMessage);
                }

                Tuple <DateTime, string> tpl;
                var tplKey = FutureCode + "-" + DerivMonth;
                if (_symbolNameFutureCache.TryGetValue(tplKey, out tpl))
                {
                    // ArrayResizerで3回元の関数が呼び出されるので、キャッシュでAPIの呼び出し回数を抑える
                    if ((DateTime.Now - tpl.Item1).TotalSeconds < 1)
                    {
                        json = tpl.Item2;
                    }
                }

                if (string.IsNullOrEmpty(json))
                {
                    json = middleware.GetSymbolNameFuture(FutureCode, DerivMonth);
                    _symbolNameFutureCache[tplKey] = Tuple.Create(DateTime.Now, json);
                }

                object[] array = SymbolName.SymbolNameCheck(json);

                return(XlCall.Excel(XlCall.xlUDF, "Resize", array));
            }
            catch (Exception exception)
            {
                if (exception.InnerException == null)
                {
                    return(exception.Message);
                }
                else
                {
                    return(exception.InnerException.Message);
                }
            }
        }