当前位置: 首页>>代码示例>>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;未经允许,请勿转载。