當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。