Example #1
0
        /// <summary>
        /// To get the file name by the type of data.
        /// </summary>
        /// <param name="dataType">Data type.</param>
        /// <param name="arg">The parameter associated with the <paramref name="dataType" /> type. For example, <see cref="CandleMessage.Arg"/>.</param>
        /// <returns>The file name.</returns>
        public static string GetFileName(Type dataType, object arg)
        {
            if (dataType == null)
            {
                throw new ArgumentNullException("dataType");
            }

            if (dataType.IsSubclassOf(typeof(CandleMessage)))
            {
                return("candles_{0}_{1}".Put(dataType.Name.Replace("Message", string.Empty), TraderHelper.CandleArgToFolderName(arg)));
            }
            else
            {
                if (arg != null && arg.Equals(ExecutionTypes.Trade))
                {
                    arg = ExecutionTypes.Order;
                }

                var fileName = _fileNames.TryGetValue(Tuple.Create(dataType, arg));

                if (fileName == null)
                {
                    throw new NotSupportedException(LocalizedStrings.Str2872Params.Put(dataType.FullName));
                }

                return(fileName);
            }
        }
        /// <summary>
        /// To get the file name by the type of data.
        /// </summary>
        /// <param name="dataType">Data type.</param>
        /// <param name="arg">The parameter associated with the <paramref name="dataType" /> type. For example, <see cref="CandleMessage.Arg"/>.</param>
        /// <returns>The file name.</returns>
        public static string GetFileName(Type dataType, object arg)
        {
            if (dataType == null)
            {
                throw new ArgumentNullException(nameof(dataType));
            }

            if (dataType.IsCandleMessage())
            {
                return("candles_{0}_{1}".Put(dataType.Name.Replace("Message", string.Empty), TraderHelper.CandleArgToFolderName(arg)));
            }
            else
            {
                var fileName = _fileNames.TryGetValue(DataType.Create(dataType, arg));

                if (fileName == null)
                {
                    throw new NotSupportedException(LocalizedStrings.Str2872Params.Put(dataType.FullName));
                }

                return(fileName);
            }
        }
Example #3
0
        //private void CandleManagerStopped(CandleSeries series)
        //{
        //	if (series == this)
        //		Stopped.SafeInvoke();
        //}

        //private void CandleManagerProcessing(CandleSeries series, Candle candle)
        //{
        //	if (series == this)
        //		ProcessCandle.SafeInvoke(candle);
        //}

        ///// <summary>
        ///// Release resources.
        ///// </summary>
        //protected override void DisposeManaged()
        //{
        //	base.DisposeManaged();

        //	if (CandleManager != null)
        //		CandleManager.Stop(this);
        //}

        /// <summary>
        /// Returns a string that represents the current object.
        /// </summary>
        /// <returns>A string that represents the current object.</returns>
        public override string ToString()
        {
            return(CandleType.Name + "_" + Security + "_" + TraderHelper.CandleArgToFolderName(Arg));
        }
Example #4
0
        /// <summary>
        /// Получить название файла по типу данных.
        /// </summary>
        /// <param name="dataType">Тип маркет-данных.</param>
        /// <param name="arg">Параметр, ассоциированный с типом <paramref name="dataType"/>. Например, <see cref="CandleMessage.Arg"/>.</param>
        /// <returns>Название файла.</returns>
        public static string CreateFileName(Type dataType, object arg)
        {
            if (dataType == null)
            {
                throw new ArgumentNullException("dataType");
            }

            if (dataType == typeof(ExecutionMessage))
            {
                switch ((ExecutionTypes)arg)
                {
                case ExecutionTypes.Tick:
                    return("trades");

                case ExecutionTypes.Order:
                case ExecutionTypes.Trade:
                    return("execution");

                case ExecutionTypes.OrderLog:
                    return("orderLog");

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            else if (dataType == typeof(QuoteChangeMessage))
            {
                return("quotes");
            }
            else if (dataType == typeof(Level1ChangeMessage))
            {
                return("security");
            }
            else if (dataType == typeof(NewsMessage))
            {
                return("news");
            }
            else if (dataType.IsSubclassOf(typeof(CandleMessage)))
            {
                return("candles_{0}_{1}".Put(dataType.Name.Replace("Message", string.Empty), TraderHelper.CandleArgToFolderName(arg)));
            }
            else
            {
                throw new NotSupportedException(LocalizedStrings.Str2872Params.Put(dataType.FullName));
            }
        }
        /// <summary>
        /// To get the file name by the type of data.
        /// </summary>
        /// <param name="dataType">Data type.</param>
        /// <param name="arg">The parameter associated with the <paramref name="dataType" /> type. For example, <see cref="CandleMessage.Arg"/>.</param>
        /// <param name="format">Storage format. If set an extension will be added to the file name.</param>
        /// <returns>The file name.</returns>
        public static string GetFileName(Type dataType, object arg, StorageFormats?format = null)
        {
            if (dataType == null)
            {
                throw new ArgumentNullException(nameof(dataType));
            }

            string fileName;

            if (dataType.IsCandleMessage())
            {
                fileName = "candles_{0}_{1}".Put(dataType.Name.Remove(nameof(Message)), TraderHelper.CandleArgToFolderName(arg));
            }
            else
            {
                fileName = _fileNames.TryGetValue(DataType.Create(dataType, arg));

                if (fileName == null)
                {
                    throw new NotSupportedException(LocalizedStrings.Str2872Params.Put(dataType.FullName));
                }
            }

            if (format != null)
            {
                fileName += GetExtension(format.Value);
            }

            return(fileName);
        }
Example #6
0
        /// <summary>
        /// Получить название файла по типу данных.
        /// </summary>
        /// <param name="dataType">Тип маркет-данных.</param>
        /// <param name="arg">Параметр, ассоциированный с типом <paramref name="dataType"/>. Например, <see cref="Candle.Arg"/>.</param>
        /// <returns>Название файла.</returns>
        public static string CreateFileName(Type dataType, object arg)
        {
            if (dataType == null)
            {
                throw new ArgumentNullException("dataType");
            }

            if (dataType == typeof(ExecutionMessage))
            {
                var execType = (ExecutionTypes)arg;

                switch (execType)
                {
                case ExecutionTypes.Tick:
                    dataType = typeof(Trade);
                    break;

                case ExecutionTypes.Order:
                case ExecutionTypes.Trade:
                    dataType = typeof(Order);
                    break;

                case ExecutionTypes.OrderLog:
                    dataType = typeof(OrderLogItem);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            else if (dataType.IsSubclassOf(typeof(CandleMessage)))
            {
                dataType = dataType.ToCandleType();
            }
            else if (dataType == typeof(QuoteChangeMessage))
            {
                dataType = typeof(MarketDepth);
            }

            if (dataType == typeof(Trade))
            {
                return("trades");
            }
            else if (dataType == typeof(MarketDepth))
            {
                return("quotes");
            }
            else if (dataType == typeof(OrderLogItem))
            {
                return("orderLog");
            }
            else if (dataType == typeof(Level1ChangeMessage))
            {
                return("security");
            }
            else if (dataType == typeof(Order))
            {
                return("execution");
            }
            else if (dataType.IsSubclassOf(typeof(Candle)))
            {
                return("candles_{0}_{1}".Put(dataType.Name, TraderHelper.CandleArgToFolderName(arg)));
            }
            else
            {
                throw new NotSupportedException(LocalizedStrings.Str2872Params.Put(dataType.FullName));
            }
        }