Exemple #1
0
        // Setters

        // ctor
        public SampleParams(String[] args)
        {
            // Get parameters with short keys
            mInstrument = GetArgument(args, "i");

            // If parameters with short keys are not specified, get parameters with long keys
            if (string.IsNullOrEmpty(mInstrument))
            {
                mInstrument = GetArgument(args, "instrument");
            }

            mTimeframe = GetArgument(args, "timeframe");

            string sOpenPriceCandlesMode = GetArgument(args, "candlesmode");

            mOpenPriceCandlesMode = sOpenPriceCandlesMode == "firsttick" ?
                                    OpenPriceCandlesMode.OpenPriceFirstTick : OpenPriceCandlesMode.OpenPricePrevClose;

            string sQuotesCount = GetArgument(args, "count");

            if (!Int32.TryParse(sQuotesCount, out mQuotesCount))
            {
                mQuotesCount = -1;
            }
            else if (mQuotesCount <= 0)
            {
                mQuotesCount = -1;
            }

            ConvertDates(args);
        }
Exemple #2
0
            public SampleParams(NameValueCollection args)
            {
                string sDateFormat = "MM.dd.yyyy HH:mm:ss";

                mInstrument = GetRequiredArgument(args, "Instrument");
                mTimeframe  = GetRequiredArgument(args, "Timeframe");

                string sDateFrom = args["DateFrom"];
                bool   bIsDateFromNotSpecified = false;

                if (!DateTime.TryParseExact(sDateFrom, sDateFormat, CultureInfo.InvariantCulture,
                                            DateTimeStyles.None, out mDateFrom))
                {
                    bIsDateFromNotSpecified = true;
                    mDateFrom = Candleworks.PriceHistoryMgr.Constants.ZERODATE; // ZERODATE
                }
                else
                {
                    if (DateTime.Compare(mDateFrom, DateTime.UtcNow) >= 0)
                    {
                        throw new Exception(string.Format("Sorry, \"DateFrom\" value {0} should be in the past; " +
                                                          "please fix the value in the configuration file", sDateFrom));
                    }
                }

                string sDateTo = args["DateTo"];

                if (!DateTime.TryParseExact(sDateTo, sDateFormat, CultureInfo.InvariantCulture,
                                            DateTimeStyles.None, out mDateTo))
                {
                    mDateTo = Candleworks.PriceHistoryMgr.Constants.ZERODATE; // ZERODATE
                }
                else
                {
                    if (!bIsDateFromNotSpecified && DateTime.Compare(mDateFrom, mDateTo) >= 0)
                    {
                        throw new Exception(string.Format("Sorry, \"DateTo\" value {0} should be later than \"DateFrom\" value {1}; " +
                                                          "please fix the value in the configuration file", sDateTo, sDateFrom));
                    }
                }

                string sQuotesCount = args["Count"];

                if (!Int32.TryParse(sQuotesCount, out mQuotesCount))
                {
                    mQuotesCount = -1;
                }
                else if (mQuotesCount <= 0)
                {
                    mQuotesCount = -1;
                }

                string sOpenPriceCandlesMode = args["OpenPriceCandlesMode"];

                mOpenPriceCandlesMode = sOpenPriceCandlesMode == "firsttick" ?
                                        OpenPriceCandlesMode.OpenPriceFirstTick : OpenPriceCandlesMode.OpenPricePrevClose;
            }