本文整理汇总了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;
}