Ejemplo n.º 1
0
 /// <summary>
 /// Представить тип строкой русского языка.
 /// </summary>
 /// <param name="typ">тип</param>
 /// <param name="shortVal">сокращённый или полный (например, ст. или статья)</param>
 /// <return>слово</return>
 public static string KindToRusString(InstrumentKind typ, bool shortVal)
 {
     if (typ == InstrumentKind.Appendix)
     {
         return(shortVal ? "прил." : "Приложение");
     }
     if (typ == InstrumentKind.Clause)
     {
         return(shortVal ? "ст." : "Статья");
     }
     if (typ == InstrumentKind.Chapter)
     {
         return(shortVal ? "гл." : "Глава");
     }
     if (typ == InstrumentKind.Item)
     {
         return(shortVal ? "п." : "Пункт");
     }
     if (typ == InstrumentKind.Paragraph)
     {
         return(shortVal ? "§" : "Параграф");
     }
     if (typ == InstrumentKind.Subparagraph)
     {
         return(shortVal ? "подпарагр." : "Подпараграф");
     }
     if (typ == InstrumentKind.DocPart)
     {
         return(shortVal ? "ч." : "Часть");
     }
     if (typ == InstrumentKind.Section)
     {
         return(shortVal ? "раздел" : "Раздел");
     }
     if (typ == InstrumentKind.InternalDocument)
     {
         return("Документ");
     }
     if (typ == InstrumentKind.Subitem)
     {
         return(shortVal ? "пп." : "Подпункт");
     }
     if (typ == InstrumentKind.Subsection)
     {
         return(shortVal ? "подразд." : "Подраздел");
     }
     if (typ == InstrumentKind.ClausePart)
     {
         return(shortVal ? "ч." : "Часть");
     }
     if (typ == InstrumentKind.Indention)
     {
         return(shortVal ? "абз." : "Абзац");
     }
     if (typ == InstrumentKind.Preamble)
     {
         return(shortVal ? "преамб." : "Преамбула");
     }
     return(null);
 }
Ejemplo n.º 2
0
        private static AssetKind ToAssetKind(InstrumentKind kind)
        {
            switch (kind)
            {
            case InstrumentKind.Currency:
                return(AssetKind.Forex);

            case InstrumentKind.CFD:
                return(AssetKind.CFD);

            case InstrumentKind.Metal:
                return(AssetKind.Metal);

            default:
                throw new ArgumentOutOfRangeException(nameof(kind));
            }
        }
Ejemplo n.º 3
0
        public static string ToDeribitString(this InstrumentKind instrumentKind)
        {
            switch (instrumentKind)
            {
            case InstrumentKind.any:
                return("any");

            case InstrumentKind.future:
                return("future");

            case InstrumentKind.option:
                return("option");

            default:
                throw new Exception();
            }
        }
Ejemplo n.º 4
0
 // https://docs.deribit.com/v2/#user-orders-kind-currency-interval
 public static string orders(string instrument, InstrumentKind instrumentKind, 
     CurrencyCode currency, Interval interval)
 {
     return $"user.orders.{instrument}.{instrumentKind}.{currency}.{interval.ToDeribitString()}";
 }
Ejemplo n.º 5
0
        public override string ToString(bool shortVariant, Pullenti.Morph.MorphLang lang, int lev = 0)
        {
            StringBuilder  res = new StringBuilder();
            InstrumentKind ki  = Kind;
            string         str;

            str = Pullenti.Ner.Instrument.Internal.MetaInstrumentBlock.GlobalMeta.KindFeature.ConvertInnerValueToOuterValue(ki.ToString(), lang) as string;
            if (str != null)
            {
                res.Append(str);
                if (Kind2 != InstrumentKind.Undefined)
                {
                    str = Pullenti.Ner.Instrument.Internal.MetaInstrumentBlock.GlobalMeta.KindFeature.ConvertInnerValueToOuterValue(Kind2.ToString(), lang) as string;
                    if (str != null)
                    {
                        res.AppendFormat(" ({0})", str);
                    }
                }
            }
            if (Number > 0)
            {
                if (ki == InstrumentKind.Table)
                {
                    res.AppendFormat(" {0} строк, {1} столбцов", Children.Count, Number);
                }
                else
                {
                    res.AppendFormat(" №{0}", Number);
                    if (SubNumber > 0)
                    {
                        res.AppendFormat(".{0}", SubNumber);
                        if (SubNumber2 > 0)
                        {
                            res.AppendFormat(".{0}", SubNumber2);
                            if (SubNumber3 > 0)
                            {
                                res.AppendFormat(".{0}", SubNumber3);
                            }
                        }
                    }
                    if (MinNumber > 0)
                    {
                        for (int i = res.Length - 1; i >= 0; i--)
                        {
                            if (res[i] == ' ' || res[i] == '.')
                            {
                                res.Insert(i + 1, string.Format("{0}-", MinNumber));
                                break;
                            }
                        }
                    }
                }
            }
            bool ignoreRef = false;

            if (IsExpired)
            {
                res.Append(" (утратить силу)");
                ignoreRef = true;
            }
            else if (ki != InstrumentKind.Editions && ki != InstrumentKind.Approved && (Ref is Pullenti.Ner.Decree.DecreeReferent))
            {
                res.Append(" (*)");
                ignoreRef = true;
            }
            if ((((str = this.GetStringValue(ATTR_NAME)))) == null)
            {
                str = this.GetStringValue(ATTR_VALUE);
            }
            if (str != null)
            {
                if (str.Length > 100)
                {
                    str = str.Substring(0, 100) + "...";
                }
                res.AppendFormat(" \"{0}\"", str);
            }
            else if (!ignoreRef && (Ref is Pullenti.Ner.Referent) && (lev < 30))
            {
                res.AppendFormat(" \"{0}\"", Ref.ToString(shortVariant, lang, lev + 1));
            }
            return(res.ToString().Trim());
        }