当前位置: 首页>>代码示例>>C#>>正文


C# Bar类代码示例

本文整理汇总了C#中Bar的典型用法代码示例。如果您正苦于以下问题:C# Bar类的具体用法?C# Bar怎么用?C# Bar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Bar类属于命名空间,在下文中一共展示了Bar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnBar

	public override void OnBar(Bar bar)
	{
		// if we don't have a position and we have some bars
		// in the bollinger series, try to enter a new trade
		if (!HasPosition)
		{
			if (bbl.Count > 0)
			{
				// if the current bar is below the lower bollinger band
				// buy long to close the gap
				if (Bars.Crosses(bbl, bar) == Cross.Below)
				{
					buyOrder = MarketOrder(OrderSide.Buy, Qty, "Entry");					
					buyOrder.Send();
				}
			}
		}
		else
		{
			// else if we DO have an existing position, and if
			// today's bar is above our entry price (profitable),
			// then close the position with a market order
			if (entryPrice < bar.Close)
			{
				barsFromEntry = 0;
				
				Sell(Qty, "Exit (Take Profit)");
			}
			else
				barsFromEntry++;
		}
	}
开发者ID:heber,项目名称:FreeOQ,代码行数:32,代码来源:code.cs

示例2: LoadMusicData

    void LoadMusicData(string jsonText)
    {
        JsonData data = JsonMapper.ToObject(jsonText);
        JsonData bars = data["bars"];
        _bars = new Bar[bars.Count];
        for (int i = 0; i < bars.Count; i++) {
            _bars[i] = new Bar(confidence: (double)(bars[i]["confidence"]),
                               start: (double)(bars[i]["start"]),
                               duration: (double)(bars[i]["duration"]));
        }

        JsonData beats = data["beats"];
        _beats = new Bar[beats.Count];
        for (int i = 0; i < beats.Count; i++) {
            _beats[i] = new Bar(confidence: (double)(beats[i]["confidence"]),
                               start: (double)(beats[i]["start"]),
                               duration: (double)(beats[i]["duration"]));
        }

        JsonData tatums = data["tatums"];
        _tatums = new Bar[tatums.Count];
        for (int i = 0; i < tatums.Count; i++) {
            _tatums[i] = new Bar(confidence: (double)(tatums[i]["confidence"]),
                               start: (double)(tatums[i]["start"]),
                               duration: (double)(tatums[i]["duration"]));
        }

        JsonData segments = data["segments"];
        _segments = new Bar[segments.Count];
        for (int i = 0; i < segments.Count; i++) {
            _segments[i] = new Bar(confidence: (double)(segments[i]["confidence"]),
                               start: (double)(segments[i]["start"]),
                               duration: (double)(segments[i]["duration"]));
        }
    }
开发者ID:jceipek,项目名称:BlockFish,代码行数:35,代码来源:MusicDataParser.cs

示例3: ExitAlertCreate

		public Alert ExitAlertCreate(Bar exitBar, Position position, double stopOrLimitPrice, string signalName,
			Direction direction, MarketLimitStop exitMarketLimitStop) {

			this.checkThrowEntryBarIsValid(exitBar);
			this.checkThrowPositionToCloseIsValid(position);

			double priceScriptOrStreaming = stopOrLimitPrice;
			OrderSpreadSide orderSpreadSide = OrderSpreadSide.Unknown;
			if (exitMarketLimitStop == MarketLimitStop.Market) {
				priceScriptOrStreaming = this.getStreamingPriceForMarketOrder(exitMarketLimitStop, direction, out orderSpreadSide);
			}

			PositionLongShort longShortFromDirection = MarketConverter.LongShortFromDirection(direction);
			double exitPriceScript = exitBar.ParentBars.SymbolInfo.RoundAlertPriceToPriceLevel(
				priceScriptOrStreaming, true, longShortFromDirection, exitMarketLimitStop);

			Alert alert = new Alert(exitBar, position.Shares, exitPriceScript, signalName,
				direction, exitMarketLimitStop, orderSpreadSide,
				//this.executor.Script,
				this.executor.Strategy);
			alert.AbsorbFromExecutor(executor);
			alert.PositionAffected = position;
			// moved to CallbackAlertFilled - we can exit by TP or SL - and position has no clue which Alert was filled!!!
			//position.ExitCopyFromAlert(alert);
			alert.PositionAffected.ExitAlertAttach(alert);

			return alert;
		}
开发者ID:sanyaade-fintechnology,项目名称:SquareOne,代码行数:28,代码来源:MarketRealStreaming.cs

示例4: ShouldWork

		public void ShouldWork()
		{
			using (var store = NewDocumentStore())
			{
				store.Conventions.IdentityTypeConvertors.Add(new UInt32Converter());
				using (var session = store.OpenSession())
				{
					var foo = new Foo() { Id = uint.MaxValue };
					foo.Related.Add(uint.MaxValue);
					session.Store(foo);
					var bar = new Bar { Id = uint.MaxValue };
					session.Store(bar);
					session.SaveChanges();
				}
				using (var session = store.OpenSession())
				{
					var foo = session.Query<Foo>()
						.Customize(x=>x.WaitForNonStaleResults())
						.ToList();
					var bar = session.Query<Bar>().ToList();
					//This line blows up
					var foobar = session.Query<Foo>().Include<Foo, Bar>(f => f.Related).ToList();
				}
			}
		}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:25,代码来源:UintId.cs

示例5: RunTest

	static void RunTest (int expected)
	{
		IFoo a = (IFoo) new Bar ();
		Assert.AreEqual (expected, a.Execute (), "#A1");
		Assert.AreEqual (expected, a.Count, "#A2");

		Bar b = new Bar ();
		Assert.AreEqual (expected, b.Execute (), "#B1");
		Assert.AreEqual (expected, b.Count, "#B2");

		Foo c = new Foo ();
		Assert.AreEqual (1, c.Execute (), "#C1");
		Assert.AreEqual (1, c.Count, "#C2");

		Assert.AreEqual (expected, ((IFoo) new Bar ()).Execute (), "#D1");
		Assert.AreEqual (expected, ((IFoo) new Bar ()).Count, "#D2");

		Assert.AreEqual (1, new Bar ().Execute (), "#E1");
		Assert.AreEqual (1, new Bar ().Count, "#E2");

		Assert.AreEqual (1, new Foo ().Execute (), "#F1");
		Assert.AreEqual (1, new Foo ().Count, "#F2");

		Assert.AreEqual (expected, CreateBar ().Execute (), "#G1");
		Assert.AreEqual (expected, CreateBar ().Count, "#G2");
	}
开发者ID:mono,项目名称:gert,代码行数:26,代码来源:test.cs

示例6: OnBar

        /*
        按照股指的时间要求,时间划分是这样的
        9:15
        9:45
        10:15
        10:45
        11:15-11:30 13:00-13:15 两个15分钟被午休隔开了
        13:45
        14:15
        14:45
        15:15 交割日时只到15:00,已经到最后一天了,少15分钟也没什么
        */
        public override void OnBar(Bar bar)
        {
            //只处理15分钟的
            if (900 == bar.Size)
            {
                if (bars == null)
                    bars = new BarSeries();

                bars.Add(bar);

                //在处理11:15-11:30 13:00-13:15这两个15分钟时会合并成一个
                if (bars.Count == 2) // 2 * 15min = 30 min
                {
                    // get OHLC values for 30min bar
                    double open = bars[0].Open;
                    double high = bars.HighestHigh();
                    double low = bars.LowestLow();
                    double close = bars[1].Close;
                    long volume = bars[0].Volume + bars[1].Volume;

                    // todo something
                    Bar b = new Bar(bars[0].DateTime, open, high, low, close, volume, 900 * 2);
                    bars30min.Add(b);
                    Console.WriteLine(b);

                    // reset 15min bar series
                    bars = null;
                }
            }
        }
开发者ID:huangzhengyong,项目名称:OpenQuant,代码行数:42,代码来源:Non-natural_TimeBar_code.cs

示例7: Add

 public void Add(Bar bar)
 {
     var barsWithInstrumentId = this.bars[bar.InstrumentId] = this.bars[bar.InstrumentId] ?? new IdArray<IdArray<BarSeries>>(8);
     var barsWithInstrumentIdAndType = barsWithInstrumentId[(int)bar.Type] = barsWithInstrumentId[(int)bar.Type] ?? new IdArray<BarSeries>();
     var barsWithInstrumentIdAndTypeAndSize = barsWithInstrumentIdAndType[(int)bar.Size] = barsWithInstrumentIdAndType[(int)bar.Size] ?? new BarSeries("", "", -1, -1);
     barsWithInstrumentIdAndTypeAndSize.Add(bar);
 }
开发者ID:fastquant,项目名称:fastquant.dll,代码行数:7,代码来源:DataStore.cs

示例8: BoolVariable

        /// <summary>
        /// Creates a new boolean variable in a given bar.
        /// </summary>
        /// <param name="bar">The bar to create the boolean variable in.</param>
        /// <param name="initialValue">The initial value of the variable.</param>
        /// <param name="def">An optional definition string for the new variable.</param>
        public BoolVariable(Bar bar, Boolean initialValue = false, String def = null)
            : base(bar, InitBoolVariable, def)
        {
            Validating += (s, e) => { e.Valid = true; };

            ValidateAndSet(initialValue);
        }
开发者ID:TomCrypto,项目名称:AntTweakBar.NET,代码行数:13,代码来源:BoolVariable.cs

示例9: run

        void run()
        {
            Bar b  = new Bar();
            Foo f = b.create();
            FooBar fb = new FooBar();
            FooBar2 fb2 = new FooBar2();

            String s;
            s = fb.used();
            if ( s != ("Foo::pang();Bar::pong();Foo::pong();FooBar::ping();"))
              throw new Exception("bad FooBar::used" + " - " + s);

            s = fb2.used();
            if ( s != ("FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();"))
              throw new Exception("bad FooBar2::used");

            s = b.pong();
            if ( s != ("Bar::pong();Foo::pong();Bar::ping();"))
              throw new Exception("bad Bar::pong");

            s = f.pong();
            if ( s != ("Bar::pong();Foo::pong();Bar::ping();"))
              throw new Exception("bad Foo::pong");

            s = fb.pong();
            if ( s != ("Bar::pong();Foo::pong();FooBar::ping();"))
              throw new Exception("bad FooBar::pong");
        }
开发者ID:abhishekgahlot,项目名称:Python-Fingerprint-Attendance-System,代码行数:28,代码来源:director_protected_runme.cs

示例10: Foo

 public void Foo()
 {
     var bar = new Bar { List = new RxList<string>() };
     bar.List.Add("foobar");
     var json = JsonConvert.SerializeObject(bar);
     var deserializedBar = JsonConvert.DeserializeObject<Bar>(json);
 }
开发者ID:kswoll,项目名称:restless,代码行数:7,代码来源:ExportImportTests.cs

示例11: BuildItem

        /// <summary>
        /// 构建插件单元
        /// </summary>
        /// <param name="caller">调用者</param>
        /// <param name="context">上下文,用于存放在构建时需要的组件</param>
        /// <param name="element">插件单元</param>
        /// <param name="subItems">被构建的子对象列表</param>
        /// <returns>构建好的插件单元</returns>
        public object BuildItem(object caller, WorkItem context, AddInElement element, ArrayList subItems)
        {
            if (element.Configuration.Attributes["label"] == null)
                throw new AddInException(String.Format("没有为类型为 \"{0}\" 的插件单元{1}提供label属性。",
                    element.ClassName, element.Id));

            string label = element.Configuration.Attributes["label"];
            BarManager barManager = context.Items.Get<BarManager>(UIExtensionSiteNames.Shell_Bar_Manager);
            if (barManager == null)
                throw new UniframeworkException("未定义框架外壳的工具条管理器。");

            Bar item = new Bar(barManager, label);
            item.BarName = element.Name;
            item.DockStyle = BarDockStyle.Top; // 默认停靠在顶部
            if (element.Configuration.Attributes["dockstyle"] != null) {
                string dockStyle = element.Configuration.Attributes["dockstyle"];
                item.DockStyle = (BarDockStyle)Enum.Parse(typeof(BarDockStyle), dockStyle);
            }

            // 是否让工具栏显示整行
            if (element.Configuration.Attributes["wholerow"] != null)
                item.OptionsBar.UseWholeRow = bool.Parse(element.Configuration.Attributes["wholerow"]);
            if (element.Configuration.Attributes["allowcustomization"] != null)
                item.OptionsBar.AllowQuickCustomization = bool.Parse(element.Configuration.Attributes["allowcustomization"]);
            if (element.Configuration.Attributes["register"] != null) {
                bool register = bool.Parse(element.Configuration.Attributes["register"]);
                if (register)
                    context.UIExtensionSites.RegisterSite(BuilderUtility.CombinPath(element.Path, element.Id), item); // 此处可能抛出异常
            }

            return item;
        }
开发者ID:wuyingyou,项目名称:uniframework,代码行数:40,代码来源:XtraBarBuilder.cs

示例12: Aggregate

 public Aggregate(Service1 one, Service2 two, Foo foo, Bar bar)
 {
     this.one = one;
     this.two = two;
     this.foo = foo;
     this.bar = bar;
 }
开发者ID:sbendiola,项目名称:sandbox,代码行数:7,代码来源:TestLayering.cs

示例13: Adapter

        public void Adapter(Bar barTarget)
        {
            m_BarItems = new List<BarItem>();
            BandItemLinks2(barTarget.ItemLinks, ref m_BarItems);

            System.Windows.Forms.Application.Idle += new EventHandler(Application_Idle);
        }
开发者ID:hy1314200,项目名称:HyDM,代码行数:7,代码来源:CommandAdapter.cs

示例14: FloatVariable

        /// <summary>
        /// Creates a new single-precision floating-point variable in a given bar.
        /// </summary>
        /// <param name="bar">The bar to create the floating-point variable in.</param>
        /// <param name="initialValue">The initial value of the variable.</param>
        /// <param name="def">An optional definition string for the new variable.</param>
        public FloatVariable(Bar bar, Single initialValue = 0, String def = null)
            : base(bar, InitFloatVariable, def)
        {
            Validating += (s, e) => { e.Valid = (Min <= e.Value) && (e.Value <= Max); };

            ValidateAndSet(initialValue);
        }
开发者ID:TomCrypto,项目名称:AntTweakBar.NET,代码行数:13,代码来源:FloatVariable.cs

示例15: OnNewBar

        private void OnNewBar(object sender, BarEventArgs args)
        {
            if (NewBar != null)
            {
                CThostFtdcDepthMarketDataField DepthMarket;
                Instrument inst = InstrumentManager.Instruments[args.Instrument.Symbol];
                string altSymbol = inst.GetSymbol(Name);

                Bar bar = args.Bar;
                if (_dictDepthMarketData.TryGetValue(altSymbol, out DepthMarket))
                {
                    bar = new Bar(args.Bar);
                    bar.OpenInt = (long)DepthMarket.OpenInterest;
                }

                if (null != MarketDataFilter)
                {
                    Bar b = MarketDataFilter.FilterBar(bar, args.Instrument.Symbol);
                    if (null != b)
                    {
                        NewBar(this, new BarEventArgs(b, args.Instrument, this));
                    }
                }
                else
                {
                    NewBar(this, new BarEventArgs(bar, args.Instrument, this));
                }
            }
        }
开发者ID:jjgeneral,项目名称:OpenQuant-CTP,代码行数:29,代码来源:CTPProvider.MarketDataProvider.OQ3.cs


注:本文中的Bar类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。