本文整理汇总了C#中OrderSide类的典型用法代码示例。如果您正苦于以下问题:C# OrderSide类的具体用法?C# OrderSide怎么用?C# OrderSide使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OrderSide类属于命名空间,在下文中一共展示了OrderSide类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:aggarwalmanuj,项目名称:open-quant,代码行数:7,代码来源:BaseStrategy.Public.Methods.cs
示例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("---------------------------");
}
开发者ID:aggarwalmanuj,项目名称:open-quant,代码行数:7,代码来源:LoggingUtility.cs
示例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;
}
开发者ID:ForTrade,项目名称:OpenQuant,代码行数:35,代码来源:PriceHelper.cs
示例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;
}
开发者ID:romkatv,项目名称:BitfinexAPI,代码行数:7,代码来源:BitfinexApi.cs
示例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;
}
开发者ID:kit998,项目名称:OpenQuant,代码行数:8,代码来源:PriceHelper.cs
示例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));
}
}
开发者ID:houzhongxu,项目名称:OpenQuant.API,代码行数:12,代码来源:EnumConverter.cs
示例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;
}
}
开发者ID:aggarwalmanuj,项目名称:open-quant,代码行数:51,代码来源:BaseStrategy.OrderHandling.cs
示例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;
}
开发者ID:ForTrade,项目名称:CSharp,代码行数:14,代码来源:Order.cs
示例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));
}
开发者ID:aggarwalmanuj,项目名称:open-quant,代码行数:14,代码来源:QuantityTradeLeg.cs
示例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));
}
开发者ID:aggarwalmanuj,项目名称:open-quant,代码行数:14,代码来源:AmountTradeLeg.cs
示例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;
}
开发者ID:jimmyhuo,项目名称:OpenQuant,代码行数:15,代码来源:DualPosition.cs
示例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;
}
开发者ID:aggarwalmanuj,项目名称:open-quant,代码行数:22,代码来源:BaseStrategyOld.cs
示例13: Cancel
public double Cancel(OrderSide Side)
{
lock (this)
{
double qty;
if (Side == OrderSide.Buy)
{
qty = Buy.Cancel();
}
else
{
qty = Sell.Cancel();
}
return qty;
}
}
开发者ID:shankshhm,项目名称:OpenQuant,代码行数:16,代码来源:DualPosition.cs
示例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;
}
开发者ID:aggarwalmanuj,项目名称:open-quant,代码行数:19,代码来源:StopPriceManager.cs
示例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;
}
开发者ID:wukan1986,项目名称:StingrayOQ,代码行数:25,代码来源:Helpers.cs
示例16: IsStopPriceMet
internal bool IsStopPriceMet(double lastPrice, double stopPrice, OrderSide orderSide, StopPriceCalculationStrategy stopStrategy, string info)
{
bool stopMet = false;
if (lastPrice <= 0)
{
LoggingUtility.WriteWarn(logConfig,
string.Format("Cannot calculate stop price condition for LAST price {0:c}",
lastPrice));
return stopMet;
}
if (stopPrice <= 0)
{
LoggingUtility.WriteVerbose(logConfig,
string.Format("Cannot calculate stop price condition for STOP price {0:c}",
stopPrice));
return stopMet;
}
if (orderSide == OrderSide.Buy)
stopMet = lastPrice > stopPrice;
else
stopMet = lastPrice < stopPrice;
if (stopMet)
LoggingUtility.WriteInfo(
logConfig,
string.Format(
"[{4}] Stop price of {0:c} was met on {1} side by last close price of {2:c} based on {3} strategy",
stopPrice,
orderSide,
lastPrice,
stopStrategy,
info));
return stopMet;
}
开发者ID:aggarwalmanuj,项目名称:open-quant,代码行数:38,代码来源:StopPriceTriggerCalculator.cs
示例17: ArePriceActionIndicatorsInFavorableMode
private bool ArePriceActionIndicatorsInFavorableMode(OrderSide orderAction)
{
bool areIndicatorsFavorable = false;
bool isEmaFired = false;
bool isStochFired = false;
string expectingIndicatorMode = string.Empty;
bool almostInd = false;
if (orderAction == OrderSide.Buy)
{
expectingIndicatorMode = "Bullish";
isEmaFired = IsEmaCrossUp && !IsEmaAlmostCrossDn;
isStochFired = IsNormalizedStochInBullishMode;
almostInd = IsEmaAlmostCrossDn;
// We are buying - check for bullish signs
areIndicatorsFavorable = (isEmaFired && isStochFired) ||
(IsStochInOverBoughtMode && !IsEmaAlmostCrossDn) ||
(IsStochInOverSoldMode && IsEmaAlmostCrossUp && !IsEmaAlmostCrossDn) ||
(IsStochInOverSoldMode && isEmaFired);
}
else
{
expectingIndicatorMode = "Bearish";
isEmaFired = IsEmaCrossDn && !IsEmaAlmostCrossUp;
isStochFired = IsNormalizedStochInBearishMode;
almostInd = IsEmaAlmostCrossUp;
// We are selling - check for bullish signs
areIndicatorsFavorable = (isEmaFired && isStochFired) ||
(IsStochInOverSoldMode && !IsEmaAlmostCrossUp) ||
(IsStochInOverBoughtMode && IsEmaAlmostCrossDn && !IsEmaAlmostCrossUp) ||
(IsStochInOverBoughtMode && isEmaFired);
}
string emaPart = string.Format("EMA({0}x{1})=({2:F4}x{3:F4})={4}. ALMOST EMA={5}",
FastMaPeriod,
SlowMaPeriod,
FastEmaIndicator.Last,
SlowEmaIndicator.Last,
isEmaFired.ToString().ToUpper(),
almostInd.ToString().ToUpper());
string stochPart = string.Format("STOCH({0},{1},{2})=(K={3:F4},D={4:F4})={5}",
StochasticsKPeriod,
StochasticsDPeriod,
StochasticsSmoothPeriod,
KSlowIndicator.Last,
DSlowIndicator.Last,
isStochFired.ToString().ToUpper());
string logMessage = string.Format("INDICATORS (Expecting={0})={1} ({2}, {3})",
expectingIndicatorMode,
areIndicatorsFavorable.ToString().ToUpper(),
emaPart,
stochPart
);
if (areIndicatorsFavorable)
{
LoggingUtility.WriteInfo(this, logMessage);
}
else
{
WriteInfrequentDebugMessage(logMessage);
}
return areIndicatorsFavorable;
}
开发者ID:aggarwalmanuj,项目名称:open-quant,代码行数:68,代码来源:BaseStrategy.IndicatorProcessing.cs
示例18: GetAutoPlacedOrderName
protected string GetAutoPlacedOrderName(OrderSide orderSide, string info, string instrument)
{
if (string.IsNullOrEmpty(info))
return string.Format("{0} order for {1}", orderSide, instrument);
else
return string.Format("{0} ({1}) order {2}", orderSide, info, instrument);
}
开发者ID:aggarwalmanuj,项目名称:open-quant,代码行数:7,代码来源:BaseStrategy.cs
示例19: CreateOrder
/// <summary>
///
/// </summary>
/// <param name="orderSide"></param>
/// <param name="qty"></param>
/// <param name="name"></param>
/// <param name="limitPrice"></param>
/// <returns></returns>
protected Order CreateOrder(OrderSide orderSide, double qty, string name, double? limitPrice)
{
Order returnValue = null;
if (UseMarketOrder)
returnValue = MarketOrder(orderSide, qty, name + "--MARKET--");
else
returnValue = LimitOrder(orderSide, qty, limitPrice.Value, name);
return returnValue;
}
开发者ID:aggarwalmanuj,项目名称:open-quant,代码行数:19,代码来源:BaseStrategy.cs
示例20: GetDetails
public IEnumerable<OrderBookDetail> GetDetails(OrderSide.Simplified side, int count)
{
if (side == OrderSide.Simplified.Sell)
return Sides[(int) side].Values.OrderBy(o => o.Price).Take(count).Reverse();
else
return Sides[(int) side].Values.OrderByDescending(o => o.Price).Take(count);
}
开发者ID:btccdev,项目名称:btcc-pro-websocket-client-csharp,代码行数:7,代码来源:OrderBookBuilder.cs
注:本文中的OrderSide类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论