本文整理匯總了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;
}
// 當前狀態禁止此項操作,時間不對,應當等下次操作
}
示例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;
}
示例3: OnOrderFilled
public override void OnOrderFilled(Order order)
{
dualPosition.Filled(order);
// 檢查倉位是否正確,是否要發新單
Process();
}
示例4: OnOrderRejected
public override void OnOrderRejected(Order order)
{
//lock(this)
{
SubOrder(order);
base.OnOrderRejected(order);
}
}
示例5: OnOrderPartiallyFilled
public override void OnOrderPartiallyFilled(Order order)
{
//lock (this)
{
SubOrder(order);
base.OnOrderPartiallyFilled(order);
}
}
示例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;
}
示例7: OnOrderCancelled
public override void OnOrderCancelled(Order order)
{
dualPosition.OrderCancelled(order);
// 追單
if (!timeHelper.IsTradingTime())
{
return;
}
ResendOrder(order);
}
示例8: OnOrderCancelled
public override void OnOrderCancelled(Order order)
{
dualPosition.OrderCancelled(order);
// 追單
if (!IsWorkingTime())
{
return;
}
ResendOrder(order);
}
示例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;
}
}
示例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;
}
示例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;
}
}
示例12: OnOrderCancelled
// 這下麵有問題,不能這麽直接減,因為撤單可能隻是中間狀態,後麵還要補上來的
// 而其它狀態可以認為單子改變,可以修改了
// 但如果是手動撤單,因為目標掛單沒減,會再自動重掛
// 但如果這麽一減,想掛單的數就少了,係統的撤單重掛功能就無效了
public override void OnOrderCancelled(Order order)
{
//lock(this)
{
// 如果不是通過雙向持倉工具,而是手工下單,就不會記錄下來
// 這樣還是有問題,如果是使用的雙向持倉工具,手工下單就會出錯
// 有這個單子,是調整所產生,不改變掛單表
if (!cancelList.Remove(order))
{
// 沒有找到,表示非調整,要改變掛單表
SubOrder(order);
}
base.OnOrderCancelled(order);
}
}
示例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();
}
}
}
}
示例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);
}
}
}
示例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;
}