private static Order Deviation(Order order, OrderDeviationMode mode, int threshold, OrderDeviationMethod method, OrderPriceAdjustMethod adjustMethod, byte slippage, byte maxTry) { var info = GetOrderInfo(order); if (mode == OrderDeviationMode.Disabled) { info.DeviationMode = mode; } else { switch (info.DeviationMode) { case OrderDeviationMode.QuoteAndTrade: case OrderDeviationMode.Trade: case OrderDeviationMode.Time: info.DeviationMode |= mode; break; default: info.DeviationMode = mode; break; } } info.DeviationInfo.Threshold = threshold; info.DeviationInfo.Method = method; info.DeviationInfo.PriceAdjustMethod = adjustMethod; info.DeviationInfo.Slippage = slippage; info.DeviationInfo.MaxTry = maxTry; return(order); }
public static Order OpenShort(this Strategy strategy, Instrument instrument, double qty, OrderPriceAdjustMethod method = OrderPriceAdjustMethod.MatchPrice) { double price = GetOrderPrice(instrument, OrderSide.Sell, method); return(OpenShort(strategy, instrument, qty, price)); }
public static Order Market2Limit(this Order order, OrderPriceAdjustMethod method, byte slippage = 1) { var info = GetOrderInfo(order); info.Market2Limit.PriceAdjustMethod = method; info.Market2Limit.Slippage = slippage; return(order); }
public void LoadForm(BinaryReader reader) { PriceAdjustMethod = (OrderPriceAdjustMethod)reader.ReadByte(); Method = (OrderDeviationMethod)reader.ReadByte(); Slippage = reader.ReadByte(); MaxTry = reader.ReadByte(); TryCount = reader.ReadByte(); Threshold = reader.ReadInt32(); }
private static double GetOrderPrice(Instrument instrument, OrderSide side, OrderPriceAdjustMethod method) { var rules = instrument.GetTradingRules(); double price; if (rules.HasMarketOrder) { price = Double.NaN; } else { if (side == OrderSide.Buy) { price = method == OrderPriceAdjustMethod.MatchPrice ? instrument.Ask.Price : instrument.GetUpperLimitPrice(); } else { price = method == OrderPriceAdjustMethod.MatchPrice ? instrument.Bid.Price : instrument.GetLowerLimitPrice(); } } return(price); }
public static Order TradeDeviation(this Order order, byte priceOffset, OrderPriceAdjustMethod adjustMethod = OrderPriceAdjustMethod.MatchPrice, byte slippage = 1, byte maxTry = 3) { return(PriceDeviation(order, priceOffset, OrderDeviationMode.Trade, adjustMethod, slippage, maxTry)); }
public static Order TimeDeviation(this Order order, int timeout, OrderPriceAdjustMethod adjustMethod = OrderPriceAdjustMethod.MatchPrice, byte slippage = 1, byte maxTry = 3) { return(Deviation(order, OrderDeviationMode.Time, timeout, OrderDeviationMethod.PriceAdjust, adjustMethod, slippage, maxTry)); }
private static Order PriceDeviation(Order order, byte priceOffset, OrderDeviationMode mode, OrderPriceAdjustMethod adjustMethod = OrderPriceAdjustMethod.MatchPrice, byte slippage = 1, byte maxTry = 3) { return(Deviation(order, mode, priceOffset, OrderDeviationMethod.PriceAdjust, adjustMethod, slippage, maxTry)); }
public static OrderList CloseShort(this Strategy strategy, Instrument instrument, double qty, OrderPriceAdjustMethod method = OrderPriceAdjustMethod.MatchPrice) { return(CloseShort(strategy, instrument, qty, GetOrderPrice(instrument, OrderSide.Buy, method))); }
public static OrderList CloseShort(this InstrumentStrategy strategy, double qty, OrderPriceAdjustMethod method = OrderPriceAdjustMethod.MatchPrice) { return(CloseShort(strategy, strategy.Instrument, qty, method)); }
public static Order OpenLong(this InstrumentStrategy strategy, double qty, OrderPriceAdjustMethod method = OrderPriceAdjustMethod.MatchPrice) { return(OpenLong(strategy, strategy.Instrument, qty, method)); }
public OrderAgent DefaultMarket2Limit(OrderPriceAdjustMethod method, byte slippage = 0) { Info.Market2Limit.PriceAdjustMethod = method; Info.Market2Limit.Slippage = slippage; return(this); }