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


C# API.Order類代碼示例

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


Order類屬於OpenQuant.API命名空間,在下文中一共展示了Order類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OnOrderRejected

        public override void OnOrderRejected(Order order)
        {
            EnumOpenClose OpenClose = DualPosition.OrderRejected(order);

            double flag = order.Side == OrderSide.Buy ? 1 : -1;

            if (EnumOpenClose.OPEN == OpenClose)
            {
                // 開倉被拒絕,不再新開倉
                // 有可能是錢不夠
                // 有可能是超出持倉限製
                // 有可能是非交易時間
                TargetPosition -= flag * order.LeavesQty;
                return;
            }

            EnumError error = TextResponse.FromText(order.Text);

            // 無法平倉,不重發單
            // 能出現這個問題是持倉計算錯誤,這已經是策略持倉計算錯誤了
            if (error == EnumError.OVER_CLOSETODAY_POSITION
                || error == EnumError.OVER_CLOSEYESTERDAY_POSITION
                || error == EnumError.OVER_CLOSE_POSITION)
            {
                TargetPosition -= flag * order.LeavesQty;
                return;
            }

            // 當前狀態禁止此項操作,時間不對,應當等下次操作
        }
開發者ID:jimmyhuo,項目名稱:OpenQuant,代碼行數:30,代碼來源:TargetPositionModule.cs

示例2: CheckOpenClose

        public static EnumOpenClose CheckOpenClose(Order order)
        {
            string text = order.Text;
            EnumOpenClose OpenClose = EnumOpenClose.OPEN;

            if (text.StartsWith("{") && text.EndsWith("}"))
            {
                TextParameter parameter = JsonConvert.DeserializeObject<TextParameter>(text);
                switch (parameter.Type)
                {
                    case EnumGroupType.COMMON:
                        {
                            TextCommon t = JsonConvert.DeserializeObject<TextCommon>(text);
                            OpenClose = t.OpenClose;
                        }
                        break;
                    case EnumGroupType.QUOTE:
                        {
                            TextQuote t = JsonConvert.DeserializeObject<TextQuote>(text);
                            OpenClose = t.OpenClose;
                        }
                        break;
                }
            }

            return OpenClose;
        }
開發者ID:jimmyhuo,項目名稱:OpenQuant,代碼行數:27,代碼來源:OpenCloseHelper.cs

示例3: OnOrderFilled

        public override void OnOrderFilled(Order order)
        {
            dualPosition.Filled(order);

            // 檢查倉位是否正確,是否要發新單
            Process();
        }
開發者ID:kit998,項目名稱:OpenQuant,代碼行數:7,代碼來源:TargetPositionModule.cs

示例4: OnOrderRejected

 public override void OnOrderRejected(Order order)
 {
     //lock(this)
     {
         SubOrder(order);
         base.OnOrderRejected(order);
     }
 }
開發者ID:vcfriend,項目名稱:OpenQuant,代碼行數:8,代碼來源:TargetOrderBookModule.cs

示例5: OnOrderPartiallyFilled

 public override void OnOrderPartiallyFilled(Order order)
 {
     //lock (this)
     {
         SubOrder(order);
         base.OnOrderPartiallyFilled(order);
     }
 }
開發者ID:vcfriend,項目名稱:OpenQuant,代碼行數:8,代碼來源:TargetOrderBookModule.cs

示例6: OrderTracker

 public OrderTracker(Order order)
 {
     Order = order;
     this.QuantityToFill = order.Qty;
     this.OriginalPrice = order.Price;
     this.AmountToFill = this.QuantityToFill*this.OriginalPrice;
     FilledAmount = 0;
     FilledQuantity = 0;
 }
開發者ID:aggarwalmanuj,項目名稱:open-quant,代碼行數:9,代碼來源:OrderTracker.cs

示例7: OnOrderCancelled

        public override void OnOrderCancelled(Order order)
        {
            dualPosition.OrderCancelled(order);

            // 追單
            if (!timeHelper.IsTradingTime())
            {
                return;
            }

            ResendOrder(order);
        }
開發者ID:houzhongxu,項目名稱:OpenQuant,代碼行數:12,代碼來源:TargetPositionModule.cs

示例8: OnOrderCancelled

        public override void OnOrderCancelled(Order order)
        {
            dualPosition.OrderCancelled(order);

            // 追單
            if (!IsWorkingTime())
            {
                return;
            }

            ResendOrder(order);
        }
開發者ID:kit998,項目名稱:OpenQuant,代碼行數:12,代碼來源:TargetPositionModule.cs

示例9: SQ_OrderManager_OrderListUpdated

		private static void SQ_OrderManager_OrderListUpdated(object sender, EventArgs e)
		{
			OpenQuant.orders.Clear();
			Map.OQ_SQ_Order.Clear();
			Map.SQ_OQ_Order.Clear();
			foreach (SingleOrder singleOrder in OrderManager.Orders.All)
			{
				Order order = new Order(singleOrder);
				OpenQuant.orders.Add(order);
				Map.OQ_SQ_Order[order] = singleOrder;
				Map.SQ_OQ_Order[singleOrder] = order;
			}
		}
開發者ID:houzhongxu,項目名稱:OpenQuant.API,代碼行數:13,代碼來源:OpenQuant.cs

示例10: CheckOpenClose

        public static EnumOpenClose CheckOpenClose(Order order)
        {
            string text = order.Text;
            EnumOpenClose OpenClose = EnumOpenClose.OPEN;

            if (text.StartsWith("{") && text.EndsWith("}"))
            {
                TextCommon parameter = JsonConvert.DeserializeObject<TextCommon>(text);
                OpenClose = parameter.OpenClose;
            }

            return OpenClose;
        }
開發者ID:vcfriend,項目名稱:OpenQuant,代碼行數:13,代碼來源:OpenCloseHelper.cs

示例11: AdjustPostOrderProcessing

        protected override void AdjustPostOrderProcessing(Order order)
        {
            if (IsLegComplete)
                return;

            double temp = FilledAmount - AmountToFill;
            if (temp < order.AvgPrice)
            {
                Log.WriteDebugLog(
                    LegName,
                    this.Instrument,
                    string.Format("The remainder amount is {0:c2} which is less than the price {1:c2}. So finalizing ther leg", temp, order.AvgPrice));

                FilledAmount = AmountToFill;
            }
        }
開發者ID:aggarwalmanuj,項目名稱:open-quant,代碼行數:16,代碼來源:AmountTradeLeg.cs

示例12: OnOrderCancelled

        // 這下麵有問題,不能這麽直接減,因為撤單可能隻是中間狀態,後麵還要補上來的
        // 而其它狀態可以認為單子改變,可以修改了
        // 但如果是手動撤單,因為目標掛單沒減,會再自動重掛
        // 但如果這麽一減,想掛單的數就少了,係統的撤單重掛功能就無效了
        public override void OnOrderCancelled(Order order)
        {
            //lock(this)
            {
                // 如果不是通過雙向持倉工具,而是手工下單,就不會記錄下來
                // 這樣還是有問題,如果是使用的雙向持倉工具,手工下單就會出錯

                // 有這個單子,是調整所產生,不改變掛單表
                if (!cancelList.Remove(order))
                {
                    // 沒有找到,表示非調整,要改變掛單表
                    SubOrder(order);
                }
                    
                base.OnOrderCancelled(order);
            }
        }
開發者ID:huangzhengyong,項目名稱:OpenQuant,代碼行數:21,代碼來源:TargetOrderBookModule.cs

示例13: 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

示例14: SubOrder

        private void SubOrder(Order order)
        {
            // 市價不會掛單,所以不會記錄到目標掛單助手中
            if (order.Type != OrderType.Limit)
                return;

            double price = order.Price;
            double size = order.LastQty;

            //lock(this)
            {
                if (order.Side == OrderSide.Buy)
                {
                    TargetOrderBook.Buy.Change(price, -size);
                }
                else
                {
                    TargetOrderBook.Sell.Change(price, -size);
                }
            }
        }
開發者ID:huangzhengyong,項目名稱:OpenQuant,代碼行數:21,代碼來源:TargetOrderBookModule.cs

示例15: CheckLongShort

 public static PositionSide CheckLongShort(Order order,EnumOpenClose OpenClose)
 {
     if (EnumOpenClose.OPEN == OpenClose)
     {
         if (order.Side == OrderSide.Buy)
         {
             return PositionSide.Long;
         }
     }
     else
     {
         if (order.Side == OrderSide.Buy)
         {
         }
         else
         {
             return PositionSide.Long;
         }
     }
     return PositionSide.Short;
 }
開發者ID:vcfriend,項目名稱:OpenQuant,代碼行數:21,代碼來源:OpenCloseHelper.cs


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