本文整理汇总了C#中OrderSide类的典型用法代码示例。如果您正苦于以下问题:C# OrderSide类的具体用法?C# OrderSide怎么用?C# OrderSide使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OrderSide类属于命名空间,在下文中一共展示了OrderSide类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAutoPlacedOrderName
protected string GetAutoPlacedOrderName(OrderType orderType, OrderSide orderSide, string info, string instrument, int retrials, string ibAccountNumber)
{
if (string.IsNullOrEmpty(info))
return string.Format("ACCT: {4} -- {0}: {1} order for {2} [#{3}]", orderType, orderSide, instrument, retrials, ibAccountNumber);
else
return string.Format("ACCT: {5} -- {0}: {1} ({2}) order {3} [#{4}]", orderType, orderSide, info, instrument, retrials, ibAccountNumber);
}
示例2: LogOrder
internal static void LogOrder(LoggingConfig config, string orderName, OrderSide orderSide, double qty, double price, int retryCount)
{
Console.WriteLine("---------------------------");
string message = string.Format("{0} - {1} {2} @ {3} for {4:C}", orderName, orderSide, qty, price, qty * price);
Console.WriteLine(string.Format(ORDER_STRING, DateTime.Now, config.Instrument.Symbol, message, retryCount));
Console.WriteLine("---------------------------");
}
示例3: GetMatchPrice
public double GetMatchPrice(Strategy strategy, OrderSide side)
{
Quote quote = strategy.Quote;
Trade trade = strategy.Trade;
Bar bar = strategy.Bar;
if (quote != null)
{
if (side == OrderSide.Buy)
{
if (quote.Ask != 0)
return quote.Ask;
}
else
{
if (quote.Bid != 0)
return quote.Bid;
}
}
if (trade != null)
if (trade.Price != 0)
return trade.Price;
if (bar != null)
{
if (bar.Close != 0)
return bar.Close;
if (bar.Open != 0)
return bar.Open;
}
return 0;
}
示例4: ExecuteOrder
public NewOrderResponse ExecuteOrder(OrderSymbol symbol, decimal amount, decimal price, OrderExchange exchange, OrderSide side, OrderType type)
{
NewOrderRequest req = new NewOrderRequest(Nonce, symbol, amount, price, exchange, side, type);
string response = SendRequest(req,"POST");
NewOrderResponse resp = NewOrderResponse.FromJSON(response);
return resp;
}
示例5: GetKeyByPrice
public int GetKeyByPrice(double price, OrderSide Side)
{
price = Math.Min(price, UpperLimitPrice);
price = Math.Max(price, LowerLimitPrice);
int index = (int)((Side == OrderSide.Buy) ? Math.Ceiling(price / TickSize) : Math.Floor(price / TickSize));
return index;
}
示例6: Convert
internal static Side Convert(OrderSide side)
{
switch (side)
{
case OrderSide.Buy:
return Side.Buy;
case OrderSide.Sell:
return Side.Sell;
default:
throw new ArgumentException(string.Format("Unsupported OrderSide - {0}", side));
}
}
示例7: ReAdjustTheNumberOfRetrialsConsumed
private void ReAdjustTheNumberOfRetrialsConsumed(double lastPrice, OrderSide orderSide)
{
double originalOpeningPrice = EffectiveOriginalOpeningPriceAtStartOfStrategy;
if (lastPrice <= 0)
{
LoggingUtility.WriteWarn(LoggingConfig,
string.Format("Cannot calculate stop price condition for LAST price {0:c}",
lastPrice));
return;
}
bool needToReadjustRetryCount = true;
if (orderSide == OrderSide.Buy)
{
needToReadjustRetryCount = lastPrice > originalOpeningPrice;
}
else
{
needToReadjustRetryCount = lastPrice < originalOpeningPrice;
}
if (!needToReadjustRetryCount)
return;
double absPriceDiff=0;
double atrPriceDiff=0;
absPriceDiff = Math.Abs(lastPrice - originalOpeningPrice);
if (EffectiveAtrPrice > 0)
atrPriceDiff = absPriceDiff/EffectiveAtrPrice;
// Retrial consumed has already been incremented by 1. So substract 1 from overall count calculated
int retriesConsumed = Convert.ToInt32(atrPriceDiff/AdverseMovementInPriceAtrThreshold) - 1;
if (retriesConsumed > 0 && EffectiveOrderRetriesConsumed < retriesConsumed)
{
EffectiveOrderRetriesConsumed = retriesConsumed;
LoggingUtility.WriteInfo(
LoggingConfig,
string.Format(
"Incrementing the EffectiveOrderRetriesConsumed to {0} because the price {1:c} has moved {2} ATR in adverse direction from the original opening price of {3:c}",
retriesConsumed, lastPrice, atrPriceDiff, originalOpeningPrice));
if (EffectiveOrderRetriesConsumed >= MaximumRetries)
EffectiveOrderRetriesConsumed = MaximumRetries;
}
}
示例8: Order
public Order(IExecutionProvider provider, Instrument instrument, OrderType type, OrderSide side, double qty, double price = 0.0, double stopPx = 0.0, TimeInForce timeInForce = TimeInForce.Day, string text = "")
: this()
{
this.provider = provider;
this.instrument = instrument;
this.type = type;
this.side = side;
this.qty = qty;
this.price = price;
this.stopPx = stopPx;
this.timeInForce = timeInForce;
this.text = text;
this.portfolio = null;
}
示例9: QuantityTradeLeg
public QuantityTradeLeg(int idx, Instrument instrument, OrderSide orderSide, double qty)
: base(idx, instrument, orderSide)
{
this.QuantityToFill = qty;
this.LegName = string.Format("Q{0}.{1}.{2}.{3}",
this.Index,
this.Instrument.Symbol.ToUpper(),
this.OrderSide,
this.QuantityToFill);
Log.WriteInfoLog(LegName,
this.Instrument,
string.Format("Quantity leg generated to {0} {1:N2} units", this.OrderSide.ToString().ToUpper(), this.QuantityToFill));
}
示例10: AmountTradeLeg
public AmountTradeLeg(int idx, Instrument instrument, OrderSide orderSide, double amt)
: base(idx, instrument, orderSide)
{
this.AmountToFill = amt;
this.LegName = string.Format("A{0}.{1}.{2}.{3:c}",
this.Index,
this.Instrument.Symbol.ToUpper(),
this.OrderSide,
this.AmountToFill);
Log.WriteInfoLog(LegName,
this.Instrument,
string.Format("Amount leg generated to {0} {1:c2}", this.OrderSide.ToString().ToUpper(), this.AmountToFill));
}
示例11: CanClose
public EnumOpenClose CanClose(OrderSide Side, double qty)
{
bool bCanClose = false;
if (Side == OrderSide.Buy)
{
bCanClose = Short.CanClose(qty);
}
else
{
bCanClose = Long.CanClose(qty);
}
if (bCanClose)
return EnumOpenClose.CLOSE;
return EnumOpenClose.OPEN;
}
示例12: GetSlippageAdjustedPrice
/// <summary>
///
/// </summary>
/// <param name="price"></param>
/// <param name="orderType"></param>
/// <returns></returns>
protected double GetSlippageAdjustedPrice(double price, OrderSide orderType)
{
double slippageAmount = price * NextBarSlippagePercentage / 100;
double targetPrice = price;
if (orderType == OrderSide.Buy)
{
targetPrice = targetPrice + slippageAmount;
}
else
{
targetPrice = targetPrice - slippageAmount;
}
return targetPrice;
}
示例13: Cancel
public double Cancel(OrderSide Side)
{
lock (this)
{
double qty;
if (Side == OrderSide.Buy)
{
qty = Buy.Cancel();
}
else
{
qty = Sell.Cancel();
}
return qty;
}
}
示例14: IsEntryStopPriceMet
internal bool IsEntryStopPriceMet(double lastPrice, double stopPrice, OrderSide orderSide)
{
bool stopMet = false;
if (orderSide == OrderSide.Buy)
stopMet = lastPrice >= stopPrice;
else
stopMet = lastPrice <= stopPrice;
if (stopMet)
LoggingUtility.WriteInfo(
logConfig,
string.Format(
"Stop price of {0:c} was met on {1} side by last close price of {2:c}",
stopPrice,
orderSide,
lastPrice));
return stopMet;
}
示例15: ActionSideToOrderSide
// These converters convert OQ enums to IB enums and back
// all follow the same pattern
// if a conversion is not possible they return false.
// the caller is expected to create an error message and ignore
// the class containing the enum which is not convertible
public static bool ActionSideToOrderSide(ActionSide action, out OrderSide side)
{
side = OrderSide.Buy;
switch (action)
{
case ActionSide.Buy:
side = OrderSide.Buy;
break;
case ActionSide.Sell:
side = OrderSide.Sell;
break;
case ActionSide.SShort:
side = OrderSide.Sell;
break;
case ActionSide.Undefined:
default:
return false;
}
return true;
}