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


C# Order.Send方法代码示例

本文整理汇总了C#中OpenQuant.API.Order.Send方法的典型用法代码示例。如果您正苦于以下问题:C# Order.Send方法的具体用法?C# Order.Send怎么用?C# Order.Send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenQuant.API.Order的用法示例。


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

示例1: OnBar

	public override void OnBar(Bar bar)
	{
		// good practice to check if a series has the date you are interested in before you try 
		// to use it
		if (b.Contains(bar))
		{
			// if we don't have a position and prices are below the lower band, open a long position
			if (!HasPosition)
			{
				if (b[bar.DateTime] * 100 <= BLevel)
				{
					buyOrder = BuyOrder(Qty, "Entry");
					buyOrder.Send();
				}
			}
			else
			{
				barsFromEntry++;

				// if we _have_ reached the exit day (4 days after entry), cancel the profit target 
				// sell order, and issue a new market order to close the position now.
				if (barsFromEntry == MaxDuration)
				{
					barsFromEntry = 0;

					// cancel existing sell order if there is one
					if (sellOrder != null)
						sellOrder.Cancel();

					Sell(Qty, "Exit (Max Duration)");
				}
			}
		}
	}
开发者ID:heber,项目名称:FreeOQ,代码行数:34,代码来源:code.cs

示例2: OnBarOpen

	public override void OnBarOpen(Bar bar)
	{
		// we need to let the first bar go by before we can
		// calculate the breakout limit
		if (prevClose != -1)
		{
			// if we do not have a position, then cancel the
			// previous limit order (it is out of date)
			if (!HasPosition)
			{
				if (buyOrder != null)
					buyOrder.Cancel();

				// now try to enter a trade by setting a limit order
				// to automatically buy in if the big 4% jump arrives.
				// This order will reside on the exchange servers, and 
				// will execute during the day if the limit is triggered.
				double breakout_fraction = 1 + (BreakoutPercent / 100);
				double breakout_price = prevClose * breakout_fraction;
				buyOrder = BuyStopOrder(Qty, breakout_price, "Entry");	
				buyOrder.Send();
			}

				// if we have a position open, then close it now. 
				// Now (which is the leading edge of today's daily bar)
				// is the start of the day after the trade was opened.
			else
				Sell(Qty, "Exit");
		}
	}
开发者ID:heber,项目名称:FreeOQ,代码行数:30,代码来源:code.cs

示例3: OnPositionOpened

	public override void OnPositionOpened()
	{
		// when we open a position, immediately issue a limit order 
		// for our 1% profit target
		double target_price = sellOrder.AvgPrice * (1 - ProfitTarget / 100);
		buyOrder = BuyLimitOrder(Qty, target_price, "Exit (Take Profit)");
		buyOrder.Send();
	}
开发者ID:heber,项目名称:FreeOQ,代码行数:8,代码来源:code.cs

示例4: UpdateExitLimit

	private void UpdateExitLimit()
	{
		// cancel old exit point order, if it exists
		if (sellOrder != null)
			sellOrder.Cancel();
		// Issue a new order with the latest SMA value. This is 
		// kind of a "trailing SMA sell order" that follows the SMA.
		sellOrder = SellLimitOrder(Qty, sma.Last, "Exit");		
		sellOrder.Send();
	}
开发者ID:heber,项目名称:FreeOQ,代码行数:10,代码来源:code.cs

示例5: HandleBarOpen

        /// <summary>
        /// 
        /// </summary>
        /// <param name="bar"></param>
        public virtual void HandleBarOpen(Bar bar)
        {
            if (bar.BeginTime >= triggerTime)
            {
                if (openPrice == null)
                {
                    openPrice = bar.Open;
                }

                if (!HasPosition && closingOrder == null)
                {
                    OrderSide? side = null;
                    double targetPrice = openPrice.Value;
                    double targetQuantity = 0;

                    if (longPositionQuantity.HasValue && longPositionQuantity.Value > 0)
                    {
                        side = OrderSide.Sell;
                        targetPrice = GetSlippageAdjustedPrice(openPrice.Value, side.Value);
                        targetQuantity = longPositionQuantity.Value;
                    }

                    if (shortPositionQuantity.HasValue && shortPositionQuantity.Value > 0)
                    {
                        side = OrderSide.Buy;
                        targetPrice = GetSlippageAdjustedPrice(openPrice.Value, side.Value);
                        targetQuantity = shortPositionQuantity.Value;
                    }

                    targetPrice = RoundPrice(targetPrice);

                    if (side.HasValue)
                    {
                        closingOrder = LimitOrder(side.Value, targetQuantity, targetPrice, "Auto closing order");

                        LogOrder("Closing", Instrument.Symbol, side.Value, targetQuantity, targetPrice);

                        if (AutoSubmit)
                            closingOrder.Send();
                    }
                }
            }
        }
开发者ID:aggarwalmanuj,项目名称:open-quant,代码行数:47,代码来源:BaseClosingStrategyOld.cs

示例6: OnStopExecuted

	public override void OnStopExecuted(Stop stop)
	{
		// if our trailing stop indicator was executed,
		// issue a market sell order to close the position.
		marketOrder = MarketOrder(OrderSide.Sell, Qty, "Stop Exit");		
		marketOrder.Send();
	}
开发者ID:heber,项目名称:FreeOQ,代码行数:7,代码来源:code.cs

示例7: PlaceSellLimit

	private void PlaceSellLimit() 
	{ 
		// calculate price that satisfies the profit target 
		double sellPrice = buyLimit.AvgPrice * (1 + ProfitTarget / 100); 
             
		sellLimit = SellLimitOrder(Qty, sellPrice, "Exit (Profit Target)");
		sellLimit.Send(); 
	} 
开发者ID:heber,项目名称:FreeOQ,代码行数:8,代码来源:code.cs

示例8: ReversePosition

	private void ReversePosition()
	{
		// reverse the position with a market order
		// Use double the position size to flip the position
		if (Position.Side == PositionSide.Long)
		{
			sellOrder = MarketOrder(OrderSide.Sell, Qty * 2, "Reverse the Position");
			sellOrder.Send();
		}
		else
		{
			buyOrder = MarketOrder(OrderSide.Buy, Qty * 2, "Reverse the Position");
			buyOrder.Send();
		}
	}
开发者ID:heber,项目名称:FreeOQ,代码行数:15,代码来源:code.cs

示例9: ExecuteClosingOrder

        private void ExecuteClosingOrder(long size)
        {
            if (OpenQuantity > 0 && closingOrderQueued)
            {
                OrderSide orderSide = OrderSide.Sell;
                double targetQuantity = 0;
                double targetPrice = 0;

                PriceCalculator priceCalc = new PriceCalculator(LoggingConfig);
                QuantityCalculator qtyCalc = new QuantityCalculator(LoggingConfig);

                targetPrice = priceCalc.Calculate(
                    new PriceCalculatorInput()
                        {
                            CurrentBar = closingInstrument.Bar,
                            PreviousBar = GetPreviousBar(closingInstrument, closingInstrument.Bar, PeriodConstants.PERIOD_MINUTE),
                            Atr = GetAtrValue(Instrument, AtrPeriod, triggerTime.Value),
                            AllowedSlippage = AllowedSlippage,
                            FavorableGap = FavorableGap,
                            FavorableGapAllowedSlippage = FavorableGapAllowedSlippage,
                            UnfavorableGap = UnfavorableGap,
                            UnfavorableGapAllowedSlippage = UnfavorableGapAllowedSlippage,
                            OrderSide = orderSide
                        });

                targetQuantity = qtyCalc.CalculatePositionSizedQuantity(OpenQuantity,
                                                                        new QuantityCalculatorInput()
                                                                            {
                                                                                PositionSizePercentage = PositionSizePercentage,
                                                                                RoundLots = RoundLots
                                                                            });

                targetPrice = priceCalc.RoundPrice(targetPrice, closingInstrument);

                if (targetPrice <= 0 || targetQuantity <= 0)
                    throw new ApplicationException(
                        string.Format("Invalid price of quantity calculated. Price {0:c}, Qty {1}", targetPrice,
                                      targetQuantity));

                string orderName = GetAutoPlacedOrderName(orderSide, "FlipFlop-Closed", closingInstrument.Symbol);

                closingOrder = CreateOrder(orderSide, targetQuantity, orderName, targetPrice);

                LoggingUtility.LogOrder(LoggingConfig, orderName, orderSide, targetQuantity, targetPrice, retryCount);

                if (AutoSubmit)
                    closingOrder.Send();

                if (!AmountIncludesOpenPosition)
                {
                    double proceeds = (targetPrice * targetQuantity);
                    PortfolioAmount = PortfolioAmount + proceeds;
                    LoggingUtility.WriteInfo(LoggingConfig,
                                             string.Format(
                                                 "The sale of {0} for {1:c} have been added to portfolio. New total = {2:c} ",
                                                 closingInstrument.Symbol,
                                                 proceeds, PortfolioAmount));
                }
            }
        }
开发者ID:aggarwalmanuj,项目名称:open-quant,代码行数:60,代码来源:BaseFlipFlopOpeningStrategy.cs


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