public static bool AllowAccept(OrderTask orderTask,QuotePolicyDetail quotePolicyDetail,string origin,int acceptDQVariation) { //Allow: (isNormal = IsBuy), SetPrice >= Calculated.Quotepolicy.Ask, SetPrice <= Calculated.Quotepolicy.Bid InstrumentClient instrument = orderTask.Transaction.Instrument; Price ask = null; Price bid = null; Price marketOriginPrice = new Price(origin, instrument.NumeratorUnit, instrument.Denominator); marketOriginPrice = marketOriginPrice + acceptDQVariation; if (quotePolicyDetail.PriceType == PriceType.WatchOnly) { int diffValue = instrument.GetSourceAskBidDiffValue(); bid = marketOriginPrice; ask = bid + diffValue; } else if (quotePolicyDetail.PriceType == PriceType.OriginEnable) { bid = marketOriginPrice + quotePolicyDetail.AutoAdjustPoints + (0 - quotePolicyDetail.SpreadPoints); var diffValue = instrument.GetSourceAskBidDiffValue(); ask = bid + (Math.Abs(diffValue)) + (quotePolicyDetail.SpreadPoints); } else { bid = marketOriginPrice + (quotePolicyDetail.AutoAdjustPoints); ask = bid + (quotePolicyDetail.SpreadPoints); } Price setPrice = new Price(orderTask.SetPrice, instrument.NumeratorUnit, instrument.Denominator); if(instrument.IsNormal == (orderTask.IsBuy == BuySell.Buy)) { if (ask != null) { return setPrice > ask; } } else { if (bid != null) { return setPrice < bid; } } return false; }
public bool AllowAccept(OrderTask orderTask,QuotePolicyDetail quotePolicyDetail, bool isBuy, string marketPrice, int acceptDQVariation) { InstrumentClient instrument = orderTask.Transaction.Instrument; Price marketPricePrice = Price.CreateInstance(marketPrice, instrument.NumeratorUnit, instrument.Denominator); marketPricePrice = marketPricePrice + acceptDQVariation; if (quotePolicyDetail.PriceType == PriceType.OriginEnable) { marketPricePrice = marketPricePrice + quotePolicyDetail.AutoAdjustPoints + (0 - quotePolicyDetail.SpreadPoints); } else { marketPricePrice = marketPricePrice + (quotePolicyDetail.AutoAdjustPoints); } Price setPrice = new Price(orderTask.SetPrice, instrument.NumeratorUnit, instrument.Denominator); if (instrument.IsNormal == isBuy) { if (marketPricePrice != null) { return setPrice > marketPricePrice; } } else { if (marketPricePrice != null) { return setPrice < marketPricePrice; } } return false; }
internal ExchangeQuotation GetExchangeQuotation(string exchangeCode, QuotePolicyDetail quotePolicyDetail) { List<ExchangeQuotation> exchangeQuotations = null; if(this._ExchangeQuotations.TryGetValue(exchangeCode,out exchangeQuotations)) { ExchangeQuotation exchangeQuotation = exchangeQuotations.SingleOrDefault(P => P.QuotationPolicyId == quotePolicyDetail.QuotePolicyId && P.InstruemtnId == quotePolicyDetail.InstrumentId); return exchangeQuotation; } else { return null; } }
internal ExchangeQuotation GetExchangeQuotation(string exchangeCode, QuotePolicyDetail quotePolicyDetail) { if (this.ExchangeSettingManagers.ContainsKey(exchangeCode)) { ExchangeQuotation exchangeQuotation = this.ExchangeSettingManagers[exchangeCode].ExchangeQuotations[quotePolicyDetail.QuotePolicyId][quotePolicyDetail.InstrumentId]; return exchangeQuotation; } else { return null; } }
private void SubtractBuySellLot(InstrumentClient instrument, QuotePolicyDetail quotePolicyDetail, bool isBuy, decimal lotBalance) { instrument.BuyLot -= isBuy ? lotBalance : 0; instrument.SellLot -= !isBuy ? lotBalance : 0; if (quotePolicyDetail != null) { quotePolicyDetail.BuyLot -= isBuy ? lotBalance : 0; quotePolicyDetail.SellLot -= !isBuy ? lotBalance : 0; } }