當前位置: 首頁>>代碼示例>>C#>>正文


C# Bar.IsWithinRegularTradingHours方法代碼示例

本文整理匯總了C#中OpenQuant.API.Bar.IsWithinRegularTradingHours方法的典型用法代碼示例。如果您正苦於以下問題:C# Bar.IsWithinRegularTradingHours方法的具體用法?C# Bar.IsWithinRegularTradingHours怎麽用?C# Bar.IsWithinRegularTradingHours使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OpenQuant.API.Bar的用法示例。


在下文中一共展示了Bar.IsWithinRegularTradingHours方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OnBarOpen

        public override void OnBarOpen(Bar bar)
        {
            if (!bar.IsWithinRegularTradingHours(Instrument.Type))
            {
                return;
            }

            if (bar.Size == PeriodConstants.PERIOD_DAILY)
            {
                return;
            }

            PublishOpenBar(bar);

            base.OnBarOpen(bar);
        }
開發者ID:aggarwalmanuj,項目名稱:open-quant,代碼行數:16,代碼來源:QuotingStrategy.cs

示例2: IsItOkToHandleBar

        protected bool IsItOkToHandleBar(Bar bar)
        {
            if (!bar.IsWithinRegularTradingHours(Instrument.Type))
            {
                LoggingUtility.WriteTraceFormat(this, "Bar is not within regular trading hours: {0}", bar);
                return false;
            }

            return true;
        }
開發者ID:aggarwalmanuj,項目名稱:open-quant,代碼行數:10,代碼來源:BaseStrategy.BarProcessing.cs

示例3: OnBarOpen

        public override void OnBarOpen(Bar bar)
        {
            if (!bar.IsWithinRegularTradingHours(Instrument.Type))
            {
                return;
            }

            if (bar.Size == PeriodConstants.PERIOD_DAILY)
            {
                // Since we will like to capture any gaps in the current day
                // open and corresponding effects of ATR calculations
                OnBar(bar);
            }
            else if (bar.BeginTime.Date >= CurrentValidityDateTime.Date)
            {
                OnBar(bar);
            }

            base.OnBarOpen(bar);
        }
開發者ID:aggarwalmanuj,項目名稱:open-quant,代碼行數:20,代碼來源:BaseStrategy.cs

示例4: OnBar

        public override void OnBar(Bar bar)
        {
            if (!bar.IsWithinRegularTradingHours(Instrument.Type))
            {
                return;
            }
            else
            {
                DataManager.Add(Instrument, bar);
            }

            try
            {
                CurrentBarRef = bar;

                if (bar.Size == PeriodConstants.PERIOD_DAILY)
                {
                    if (CurrentDailyBarSeries.Count <= AtrPeriod)
                    {
                        return;
                    }
                }

                if (bar.Size == CurrentExecutionTimePeriodInSeconds)
                {
                    int[] periods = new[]
                    {
                        SlowMaPeriod,
                        FastMaPeriod,
                        StochasticsDPeriod,
                        StochasticsKPeriod,
                        StochasticsSmoothPeriod
                    };

                    int maxPeriod = periods.Max();

                    if (CurrentExecutionBarSeries.Count <= maxPeriod)
                    {
                        return;
                    }
                }

                // If everything is filled - then exit:
                if (IsStrategyOrderFilled)
                    return;

                CurrentClosePrice = bar.Close;

                if (bar.Size == PeriodConstants.PERIOD_DAILY)
                {
                    CurrentAtrPrice = DailyAtrIndicator.Last;
                    if (CurrentClosePrice > 0 && IsBarCloseEnoughForLogging(bar))
                    {
                        LoggingUtility.WriteInfoFormat(this,
                            "Setting ATR to {0:c} which is {1:p} of the last close price {2:c}",
                            CurrentAtrPrice,
                            CurrentAtrPrice / CurrentClosePrice,
                            CurrentClosePrice);
                    }
                }

                if (bar.Size == PeriodConstants.PERIOD_DAILY)
                {
                    // We do not need to worry about any other type of bar
                    return;
                }

                if (bar.Size == CurrentExecutionTimePeriodInSeconds)
                {
                    // Ensure that intraday indicators are evaluated
                    GetIsStochInBullishMode(bar);
                    GetIsStochInBearishMode(bar);
                    GetIsEmaInBearishMode(bar);
                    GetIsEmaInBullishMode(bar);
                }

                if (CurrentAtrPrice <= 0)
                {
                    // need the ATR to process further
                    return;
                }

                if (CurrentAskPrice <= 0)
                {
                    // need the Ask to process further
                    return;
                }

                if (CurrentBidPrice <= 0)
                {
                    // need the Bid to process further
                    return;
                }

                if (GetCurrentDateTime() < CurrentValidityDateTime)
                {
                    return;
                }

                // 1. If the order is not triggered yet - then check when is the right time to trigger the order
//.........這裏部分代碼省略.........
開發者ID:aggarwalmanuj,項目名稱:open-quant,代碼行數:101,代碼來源:BaseStrategy.cs


注:本文中的OpenQuant.API.Bar.IsWithinRegularTradingHours方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。