public BarsCountEnumerator(DataFeed dataFeed, IStorage storage, string symbol, PriceType priceType, BarPeriod period, DateTime startTime, int barsNumber, int preferredBufferSize) : base(dataFeed, storage, symbol, priceType, period, startTime, preferredBufferSize) { this.barsNumber = barsNumber; this.Reset(); }
public override LoadUpdatesResult LoadUpdates(PriceType type, bool forceUpdate) { var xmlPriceLoader = new XmlPriceLoader(_colorCodeBuilder); var oldPriceLoader = new NewestFileSystemPriceLoader(xmlPriceLoader); var newPriceLoader = new SingleFilePriceLoader(xmlPriceLoader); PriceLoadResult newPriceLoadResult; PriceLoadResult oldPriceLoadResult = null; switch (type) { case PriceType.Stock: newPriceLoadResult = newPriceLoader.Load<StockXmlItemList>(PriceUrl); if (!forceUpdate) { oldPriceLoadResult = oldPriceLoader.Load<StockXmlItemList>(ArchiveDirectory); } break; case PriceType.Full: newPriceLoadResult = newPriceLoader.Load<FullXmlItemList>(PriceUrl); if (!forceUpdate) { oldPriceLoadResult = oldPriceLoader.Load<FullXmlItemList>(ArchiveDirectory); } break; case PriceType.Discount: throw new NotImplementedException(); default: throw new ArgumentOutOfRangeException(); } return new LoadUpdatesResult(newPriceLoadResult, oldPriceLoadResult, newPriceLoadResult.Success); }
public PriceUpdateResult Process(Diff diff, PriceType priceType) { try { switch (priceType) { case PriceType.Stock: Log.Info("Price type is stock. New items are excluded from processing"); diff.NewItems.Clear(); break; case PriceType.Full: break; case PriceType.Discount: diff.NewItems.Values.ToList().ForEach(p => { p.OnSale = true; p.DiscountValue = DiscountValue; }); diff.UpdatedItems.Values.ToList().ForEach(p => { p.OnSale = true; p.DiscountValue = DiscountValue; }); break; } IProcessor processor = new PriceWebServiceProcessor(_apiUrl, _apiAccessToken); if (diff.NewItems.Any()) { Log.Debug("Building retail prices for new items"); diff.NewItems.Values.ToList().ForEach(p => p.RetailPrice = _retailPriceBuilder.Build(p)); Log.Debug("Adding items"); processor.Process(diff.NewItems, GeneratedPriceType.NewItems, priceType); } if (diff.UpdatedItems.Any()) { Log.Debug("Building retail prices for updated items"); diff.UpdatedItems.Values.ToList().ForEach(p => p.RetailPrice = _retailPriceBuilder.Build(p)); Log.Debug("Updating items"); processor.Process(diff.UpdatedItems, GeneratedPriceType.SameItems, priceType); } if (diff.DeletedItems.Any()) { Log.Debug("Deleting items"); processor.Process(diff.DeletedItems, GeneratedPriceType.DeletedItems, priceType); } return new PriceUpdateResult(PriceUpdateResultStatus.Ok); } catch (PhotoLoadException) { return new PriceUpdateResult(PriceUpdateResultStatus.PhotoLoadFailed); } catch (ProcessAbortedException) { return new PriceUpdateResult(PriceUpdateResultStatus.ProcessAborted); } catch (Exception ex) { Log.Error("Price processing error", ex); return new PriceUpdateResult(PriceUpdateResultStatus.InternalError); } }
public static double Price(OptionType optionType, double Fwd, double K, double T, double r, double σ, PriceType priceType = PriceType.Price) { double std = σ * Math.Sqrt(T); double DF = Math.Exp(-r * T); double d1 = (Math.Log(Fwd / K) + 0.5*std*std ) / std; double d2 = d1 - std; switch(priceType) { case PriceType.Price: if (optionType == OptionType.Call) return DF * ( Fwd * N(d1) - K * N(d2) ); else if (optionType == OptionType.Put) return DF * ( K * N(-d2) - Fwd * N(-d1) ); break; case PriceType.Δ: return DF * Fwd * N(d1); case PriceType.Vega: return DF * Fwd * Math.Sqrt(T) * Nprime(d1); case PriceType.Γ: return 1 / ( DF * Fwd * std ) * Nprime(d1); } throw new Exception(); }
public BarsTimeIntervalEnumerator(DataFeed dataFeed, IStorage storage, string symbol, PriceType priceType, BarPeriod period, DateTime startTime, DateTime endTime, int preferredBufferSize) : base(dataFeed, storage, symbol, priceType, period, startTime, preferredBufferSize) { this.endTime = endTime; this.Reset(); }
public PriceSelector(Ticker ticker, PriceType type) { ticker.Tick += args => { if (PriceTick != null) PriceTick(type == PriceType.Bid ? args.Bid : args.Ask); }; }
/// <summary> /// The constructor takes snapshot from manager. /// </summary> /// <param name="snapshot">a snapshot instance</param> /// <param name="storage"></param> /// <param name="symbol"></param> /// <param name="periodicity"></param> /// <param name="priceType"></param> /// <exception cref="System.ArgumentNullException">if snapshot is null</exception> public Snapshot(Snapshot snapshot, DataFeedStorage storage, string symbol, BarPeriod periodicity, PriceType priceType) { if (snapshot == null) throw new ArgumentNullException(nameof(snapshot)); if (storage == null) throw new ArgumentNullException(nameof(storage)); this.IsFeedLoggedOn = snapshot.IsFeedLoggedOn; this.IsTradeLoggedOn = snapshot.IsTradeLoggedOn; this.AccountInfo = snapshot.AccountInfo; this.FeedSessionInfo = snapshot.FeedSessionInfo; this.TradeSessionInfo = snapshot.TradeSessionInfo; this.TradeRecords = snapshot.TradeRecords; this.Positions = snapshot.Positions; this.Quotes = snapshot.Quotes; this.Symbols = snapshot.Symbols; this.storage = storage; this.symbol = symbol; this.periodicity = periodicity; this.priceType = priceType; this.synchronizer = snapshot.synchronizer; }
public override decimal GetPrice(PriceType priceType) { decimal price = 0m; foreach (Ticket t in TicketList) { decimal ticketPrice = t.GetPrice(priceType); price += ticketPrice; } return price; }
public static FxPriceType ToFxPriceType(PriceType type) { if (type == PriceType.Bid) return FxPriceType.Bid; else if (type == PriceType.Ask) return FxPriceType.Ask; var message = string.Format("Incorrect price type: expected Bid or Ask, but received = {0}", type); throw new ArgumentException("type", message); }
protected override void addIndicators() { MAMethodType ma1Method = (MAMethodType)this["MA1Method"]; MAMethodType ma2Method = (MAMethodType)this["MA2Method"]; PriceType ma1apply = (PriceType)this["MA1Apply"]; PriceType ma2apply = (PriceType)this["MA2Apply"]; addIndicator("MA1", new MovingAverage(container.DefaultInstrument, container.DefaultPeriod, (int)this["MA1"], ma1Method, ma1apply)); addIndicator("MA2", new MovingAverage(container.DefaultInstrument, container.DefaultPeriod, (int)this["MA2"], ma2Method, ma2apply)); }
public void Process(Dictionary<string, PriceItem> priceItems, GeneratedPriceType generatedPriceType, PriceType processingPriceType) { Log.Debug("Connecting to API"); _apiFactory.InitFactories(_apiUrl, _accessToken); _productUpdater = new ProductUpdater(_apiFactory); _productRemover = new ProductRemover(_apiFactory); _productCreator = new ProductCreator(_apiFactory); ProcessDiff(priceItems, generatedPriceType, processingPriceType); }
private float DrawPrice(Rect rect, Tradeable trad) { rect = rect.Rounded(); if (Mouse.IsOver(rect)) { Widgets.DrawHighlight(rect); } PriceType priceType = GetPriceTypeFor(trad); float finalPrice = CalcRequestedItemPrice(trad); TooltipHandler.TipRegion(rect, new TipSignal(() => GetPriceTooltip(faction, negotiator, trad, finalPrice), trad.GetHashCode() * 297)); switch (priceType) { case PriceType.VeryCheap: GUI.color = new Color(0, 1, 0); break; case PriceType.Cheap: GUI.color = new Color(0.5f, 1, 0.5f); break; case PriceType.Normal: GUI.color = Color.white; break; case PriceType.Expensive: GUI.color = new Color(1, 0.5f, 0.5f); break; case PriceType.Exorbitant: GUI.color = new Color(1, 0, 0); break; } string label = finalPrice.ToStringMoney("F2"); Rect priceTextArea = new Rect(rect); priceTextArea.xMax -= 5f; priceTextArea.xMin += 5f; if (Text.Anchor == TextAnchor.MiddleLeft) { priceTextArea.xMax += 300f; } if (Text.Anchor == TextAnchor.MiddleRight) { priceTextArea.xMin -= 300f; } Widgets.Label(priceTextArea, label); GUI.color = Color.white; return(finalPrice); }
public Product(string productName, int productcode, string description, decimal price, PriceType priceType, ProductCategory[] categories, int internalID) { this.productName = productName; this.productCode = productcode; this.description = description; this.price = price; this.priceType = priceType; this.categories = categories; this.internalID = internalID; }
private MarketQuotes( Uid uid, ContractQuotesMap contractQuotes, PriceType priceType, QuantityType quantityType) { _uid = uid; _contractQuotes = contractQuotes; _priceType = priceType; _quantityType = quantityType; }
public static float PriceMultiplier(this PriceType pType) { return(pType switch { PriceType.VeryCheap => 0.4f, PriceType.Cheap => 0.7f, PriceType.Normal => 1f, PriceType.Expensive => 2f, PriceType.Exorbitant => 5f, _ => - 1f, });
public double GetWithoutVAT(double value, PriceType priceType = PriceType.Sale) { if (BusinessDomain.AppConfiguration.VATIncluded) { double vatValue = Currency.Round((value * VatRate) / (100 + VatRate), priceType); value -= vatValue; } return(value); }
public OrderItem(int n, Item item, PriceType priceType, Order order) { this.n = n; name = item.Name; price = item.GetPrice(priceType); productId = item.ProductId; receiptId = item.ReceiptId; itemId = item.Id; this.order = order; }
public Product(string productName, int productcode, string description, decimal price, PriceType priceType, ProductCategory[] categories, int internalID) { this.productName = productName; this.productCode = productcode; this.description = description; this.price = price; this.priceType = priceType; this.categories = categories; this.internalID = internalID; }
public DataHistoryInfo GetHistoryBars(string symbol, DateTime time, int barsNumber, PriceType priceType, BarPeriod period, int timeoutInMilliseconds) { this.VerifyInitialized(); var info = Native.FeedServer.GetHistoryBars(this.handle, symbol, time, barsNumber, priceType, period.ToString(), (uint)timeoutInMilliseconds); foreach (var bar in info.Bars) { bar.To = bar.From + period; } return info; }
private double CalculateVAT(double price, PriceType type) { if (BusinessDomain.AppConfiguration.RoundedPrices && !BusinessDomain.AppConfiguration.VATIncluded) { price = Currency.Round(price, type); } return(BusinessDomain.AppConfiguration.VATIncluded ? (price * VatRate) / (100d + VatRate) : (price * VatRate) / 100d); }
public virtual decimal GetPrice(PriceType type) { if (type == PriceType.Price1) { return(price1); } if (type == PriceType.Price2) { return(price2); } return(price3); }
public override bool Equals(object obj) { var item = obj as Price; if (item == null) { return(false); } return(PriceType.Equals(item.PriceType) && HorsePrices.SequenceEqual(item.HorsePrices)); }
/// <summary> /// Initializes a new instance of the <see cref="BarSpecification"/> class. /// </summary> /// <param name="period">The specification period.</param> /// <param name="barStructure">The specification resolution.</param> /// <param name="priceType">The specification quote type.</param> /// <exception cref="ArgumentOutOfRangeException">If the period is not positive (> 0).</exception> public BarSpecification( int period, BarStructure barStructure, PriceType priceType) { Debug.PositiveInt32(period, nameof(period)); this.Period = period; this.BarStructure = barStructure; this.PriceType = priceType; this.Duration = CalculateDuration(period, barStructure); }
public double GetMovingAverage(string assetCode, int days, PriceType priceType) { days *= -1; var prices = new List <double>(); for (var i = -1; i >= days; --i) { prices.Add(GetPrice(assetCode, priceType, i)); } return(prices.Average()); }
public static void AddPriceSpot(PlotLine2D line_plot_2d, PriceSet price_set, PriceType price_type, Color color) { IReadOnlyList <Price> prices = price_set.Prices; IReadOnlyList <double> time = price_set.Ticks; double[] signal = new double[prices.Count]; Parallel.For(0, prices.Count, index => { signal[index] = prices[index].GetPrice(price_type); }); AddSignal(line_plot_2d, time, signal, color); }
public async Task InsertOrMergeAsync(IEnumerable <IFeedCandle> candles, PriceType priceType, TimeInterval interval) { // Group by row var groups = candles .GroupBy(candle => new { pKey = candle.PartitionKey(priceType), rowKey = candle.RowKey(interval) }); // Update rows foreach (var group in groups) { await InsertOrMergeAsync(group, group.Key.pKey, group.Key.rowKey, interval); } }
public QuotePolicyDetail(Instrument instrument, DataRow quotePolicy) { this.id = (Guid)quotePolicy["QuotePolicyID"]; this.priceType = (PriceType)(byte)quotePolicy["PriceType"]; this.autoAdjustPoints = (int)quotePolicy["AutoAdjustPoints"]; this.spreadPoints = (int)quotePolicy["SpreadPoints"]; this.isOriginHiLo = (bool)quotePolicy["IsOriginHiLo"]; this.overrideHigh = null; this.overrideLow = null; this.SetCrossRef(instrument); }
public QuotePolicyDetail(Instrument instrument, XmlNode quotePolicy) { this.id = XmlConvert.ToGuid(quotePolicy.Attributes["QuotePolicyID"].Value); this.priceType = (PriceType)XmlConvert.ToByte(quotePolicy.Attributes["PriceType"].Value); this.autoAdjustPoints = XmlConvert.ToInt32(quotePolicy.Attributes["AutoAdjustPoints"].Value); this.spreadPoints = XmlConvert.ToInt32(quotePolicy.Attributes["SpreadPoints"].Value); this.isOriginHiLo = XmlConvert.ToBoolean(quotePolicy.Attributes["IsOriginHiLo"].Value); this.overrideHigh = null; this.overrideLow = null; this.SetCrossRef(instrument); }
private bool Form_LoadData(object sender, object data) { if (data == null) { return(false); } if (!(data is List <CancelRedoItem>)) { return(false); } //Get the price type PriceType spotBuyPrice = PriceTypeHelper.GetPriceType(this.cbSpotBuyPrice); PriceType spotSellPrice = PriceTypeHelper.GetPriceType(this.cbSpotSellPrice); PriceType futureBuyPrice = PriceTypeHelper.GetPriceType(this.cbFuturesBuyPrice); PriceType futureSellPrice = PriceTypeHelper.GetPriceType(this.cbFuturesSellPrice); EntrustPriceType shPriceType = EntrustPriceTypeHelper.GetPriceType(this.cbSHExchangePrice); EntrustPriceType szPriceType = EntrustPriceTypeHelper.GetPriceType(this.cbSZExchangePrice); _secuDataSource.Clear(); var cancelSecuItems = data as List <CancelRedoItem>; foreach (var cancelRedoItem in cancelSecuItems) { if (cancelRedoItem.SecuType == SecurityType.Stock && cancelRedoItem.EDirection == EntrustDirection.BuySpot) { cancelRedoItem.EPriceSetting = spotBuyPrice; } else if (cancelRedoItem.SecuType == SecurityType.Stock && cancelRedoItem.EDirection == EntrustDirection.BuySpot) { cancelRedoItem.EPriceSetting = spotSellPrice; } else if (cancelRedoItem.SecuType == SecurityType.Futures && cancelRedoItem.EDirection == EntrustDirection.SellOpen) { cancelRedoItem.EPriceSetting = futureSellPrice; } else if (cancelRedoItem.SecuType == SecurityType.Futures && cancelRedoItem.EDirection == EntrustDirection.BuyClose) { cancelRedoItem.EPriceSetting = futureBuyPrice; } SetEntrustPriceType(cancelRedoItem, shPriceType, szPriceType); _secuDataSource.Add(cancelRedoItem); } //update the quote QueryQuote(); return(true); }
public double TimeFrameGetPrice(IntervalPeriod periodInterval, PriceType priceType, int index = 0) { bardata = TimeFrameRequest <BarData>(periodInterval); var price = 0D; if (bardata != null && bardata.Count > 0) { price = bardata.GetValue(priceType, index); } return(price); }
public ItemDto(Item item, PriceType priceType) { Id = item.Id; Name = item.Name; Price = item.GetPrice(priceType); Rest = item.Rest; Manufacter = item.Manufacter; Pack = item.Pack; Category = item.Category.Name; Date = item.Date; ReceiptId = item.ReceiptId; ProductId = item.ProductId; }
public static string GetPriceTypeKey(PriceType type) { switch (type) { case PriceType.None: return("none"); case PriceType.Real: return("real"); case PriceType.Ads: return("ads"); default: throw new System.ArgumentOutOfRangeException("type"); } }
public static string ToString(this PriceType type) { if (type == PriceType.Buy) { return("Buy"); } else if (type == PriceType.Sell) { return("Sell"); } Console.WriteLine("Unrecognized PriceType"); return(""); }
internal TeamBunk(string code, decimal discountOrParValue, PriceType mode, string ei, string description) : base(code, ei) { if (mode == PriceType.Price) { _fare = Utility.Calculator.Round(discountOrParValue, 1); } else { _discount = discountOrParValue; } _description = description ?? string.Empty; }
internal static DS.PriceType ToDsPriceType(PriceType type) { switch (type) { case PriceType.Mean: return(DS.PriceType.Unspecified); case PriceType.Bid: return(DS.PriceType.Bid); case PriceType.Ask: return(DS.PriceType.Ask); default: throw new NotSupportedException($"Can't convert {type} to data server price type"); } }
public void Update(product product, PriceItem item, PriceType processingPriceType) { _stockProcessor.UpdateStockValue(item, product); UpdateMetaInfo(item, product); if (processingPriceType == PriceType.Stock) { UpdateProductPriceAndActivity(item, product); } if (processingPriceType == PriceType.Discount) { UpdateDiscountInfo(item, product); } }
/// <summary> /// The method synchronizes bars. /// </summary> /// <param name="symbol"></param> /// <param name="priceType"></param> /// <param name="period"></param> /// <param name="startTime"></param> /// <param name="endTime"></param> public void Synchronize(string symbol, PriceType priceType, BarPeriod period, DateTime startTime, DateTime endTime) { if (this.source == null) { throw new InvalidOperationException("Can't synchronize in offline mode."); } var manager = this.GetOrCreateHistoryManager(symbol); var periodicity = StorageConvert.ToPeriodicity(period); var fxPriceType = StorageConvert.ToFxPriceType(priceType); manager.SynchronizeBars(this.source, symbol, periodicity, fxPriceType, startTime, endTime, false, NullCallback); }
public void UpdateAdjustOutMaterial(DataTable dtAdjustOutMaterial, PriceType enWHPriceType) { foreach (DataRow drAdjustOutMaterial in dtAdjustOutMaterial.Rows) { if (drAdjustOutMaterial.RowState != DataRowState.Deleted) { string sSql = @"SELECT WH_InStoreMaterialDetail.*,Material.MaterialName,MaterialUOM.MaterialUomID,QuantityReject From WH_InStoreMaterialDetail LEFT JOIN Material on Material.ItemCode = WH_InStoreMaterialDetail.ItemCode LEFT JOIN MaterialUOM on WH_InStoreMaterialDetail.UOMID = MaterialUOM.UOMID AND MaterialUOM.ItemCode = WH_InStoreMaterialDetail.ItemCode AND MaterialUOM.IsBaseUOM = 1 LEFT JOIN WH_AdjustOutMaterial ON WH_AdjustOutMaterial.InStockMaterialID = WH_InStoreMaterialDetail.InStockMaterialID WHERE WH_InStoreMaterialDetail.InStockMaterialID = '" + drAdjustOutMaterial["InStockMaterialID"].ToString() + "'"; DataTable dtTempInfo = BaseDataAccess.GetDataTable(sSql); if (dtTempInfo.Rows.Count > 0) { //订单编号 drAdjustOutMaterial["POID"] = dtTempInfo.Rows[0]["POID"]; drAdjustOutMaterial["WH_AdjustOutMaterial__POID"] = dtTempInfo.Rows[0]["POID"]; //库存 drAdjustOutMaterial["QuantityInBin"] = dtTempInfo.Rows[0]["QuantityInBin"]; //库位 drAdjustOutMaterial["BINID"] = dtTempInfo.Rows[0]["BINID"]; drAdjustOutMaterial["WH_AdjustOutMaterial__BINID"] = dtTempInfo.Rows[0]["BINID"]; //制造编号 drAdjustOutMaterial["PartNO"] = dtTempInfo.Rows[0]["PartNO"]; drAdjustOutMaterial["ItemCode"] = dtTempInfo.Rows[0]["ItemCode"]; //盘亏数量 // drAdjustOutMaterial["QuantityReject"] = dtTempInfo.Rows[0]["QuantityReject"] ; //单位 drAdjustOutMaterial["MaterialUomID"] = dtTempInfo.Rows[0]["MaterialUomID"]; drAdjustOutMaterial["WH_AdjustOutMaterial__MaterialUomID"] = dtTempInfo.Rows[0]["UomID"]; if (enWHPriceType == PriceType.TYPE_PO) { //基本单位单价(本) drAdjustOutMaterial["UnitPriceNatural"] = dtTempInfo.Rows[0]["UnitPricePONatural"]; //基本单位单价(核) drAdjustOutMaterial["UnitPriceStandard"] = dtTempInfo.Rows[0]["UnitPricePOStandard"]; } else if (enWHPriceType == PriceType.TYPE_Average) { //基本单位单价(本) drAdjustOutMaterial["UnitPriceNatural"] = dtTempInfo.Rows[0]["AveragePriceNatural"]; //基本单位单价(核) drAdjustOutMaterial["UnitPriceStandard"] = dtTempInfo.Rows[0]["AveragePriceStandard"]; } //物资名称 drAdjustOutMaterial["MaterialName"] = dtTempInfo.Rows[0]["MaterialName"]; } } } }
public static PriceType GetPriceType(string priceTypeId) { PriceType priceType = PriceType.Market; if (priceTypeId != null && !string.IsNullOrEmpty(priceTypeId)) { if (Enum.IsDefined(typeof(PriceType), priceTypeId)) { priceType = (PriceType)Enum.Parse(typeof(PriceType), priceTypeId); } } return(priceType); }
public static ProductPrice GetLatestPrice(int productID, PriceType priceType) { using (var db = OnlineStoreDbContext.Entity) { var query = from item in db.ProductPrices where item.ProductID == productID && item.PriceType == priceType orderby item.LastUpdate descending select item; return(query.FirstOrDefault()); } }
public SplitPaymentArticleComparable(Guid oid, string designation, decimal priceFinal, decimal price, decimal vat, Guid vatExemptionReason, Guid placeOid, Guid tableOid, PriceType priceType) { this.oid = oid; this.designation = designation; // Used Split Values with FinalTotal this.priceFinal = priceFinal; // Used to send to ArticleBag this.price = price; this.vat = vat; this.vatExemptionReason = vatExemptionReason; this.placeOid = placeOid; this.tableOid = tableOid; this.priceType = priceType; }
private static Price CalculateAutoClosePrice(Order order, PriceType priceType) { Debug.Assert(order.IsOpen); SpecialTradePolicyDetail policy = order.Owner.SpecialTradePolicyDetail(); Settings.Instrument instrument = order.Owner.SettingInstrument(); OrderLevelRiskBase autoCloseBase = priceType == PriceType.Limit ? policy.AutoLimitBase : policy.AutoStopBase; decimal autoCloseThreshold = priceType == PriceType.Limit ? policy.AutoLimitThreshold : policy.AutoStopThreshold; if (autoCloseBase == OrderLevelRiskBase.None) { return(null); } else if (autoCloseBase == OrderLevelRiskBase.Necessary) { return(CalculateForOrderLevelRiskNecessay(order, autoCloseThreshold, instrument, priceType)); } else { Price basePrice = order.ExecutePrice; if (autoCloseBase == OrderLevelRiskBase.SettlementPrice) { TradeDay tradeDay = Settings.Setting.Default.GetTradeDay(); if (order.Owner.ExecuteTime > tradeDay.BeginTime) { return(null); } else { basePrice = (order.IsBuy ? instrument.DayQuotation.Buy : instrument.DayQuotation.Sell); } } int autoClosePips = (int)autoCloseThreshold; if (order.SetPriceMaxMovePips > 0 && order.SetPriceMaxMovePips < autoClosePips) { autoClosePips = order.SetPriceMaxMovePips; } if (order.IsBuy == (priceType == PriceType.Limit)) { return(Price.Add(basePrice, autoClosePips, !instrument.IsNormal)); } else { return(Price.Subtract(basePrice, autoClosePips, !instrument.IsNormal)); } } }
protected void btnSave_Click(object sender, EventArgs e) { if (valiate()) { PriceType priceType = PriceType.Price; decimal subordinateCommission = 0; decimal professionCommission = 0; decimal internalCommission = 0; decimal price = 0; if (radPrice.Checked) { priceType = PriceType.Price; price = decimal.Parse(this.txtPrice.Text); if (!string.IsNullOrWhiteSpace(this.txtSubordinateCommission.Text)) { subordinateCommission = decimal.Parse(this.txtSubordinateCommission.Text); } if (!string.IsNullOrWhiteSpace(this.txtProfessionCommission.Text)) { professionCommission = decimal.Parse(this.txtProfessionCommission.Text); } if (!string.IsNullOrWhiteSpace(this.txtInternalCommission.Text)) { internalCommission = decimal.Parse(this.txtInternalCommission.Text); } } if (radLapse.Checked) { priceType = PriceType.Subtracting; price = decimal.Parse(this.txtLapse.Text) / 100; if (!string.IsNullOrWhiteSpace(this.txtSubordinateCommission.Text)) { subordinateCommission = decimal.Parse(this.txtSubordinateCommission.Text) / 100; } if (!string.IsNullOrWhiteSpace(this.txtProfessionCommission.Text)) { professionCommission = decimal.Parse(this.txtProfessionCommission.Text) / 100; } if (!string.IsNullOrWhiteSpace(this.txtInternalCommission.Text)) { internalCommission = decimal.Parse(this.txtInternalCommission.Text) / 100; } } PolicyManageService.UpdateSpecialPolicyPrice(Guid.Parse(hidIds.Value), priceType, price, subordinateCommission, internalCommission, professionCommission, this.CurrentUser.UserName); QuerySpecialPolicy(pager.CurrentPageIndex); } QuerySpecialPolicy(pager.CurrentPageIndex); }
internal override void Initialize(Manager manager, IStrategyLog log, string symbol, PriceType priceType, BarPeriod periodicity) { if (manager == null) throw new ArgumentNullException("manager"); if (log == null) throw new ArgumentNullException("log"); this.manager = manager; this.log = log; this.symbol = symbol; this.priceType = priceType; this.periodicity = periodicity; this.manager.Updated += this.OnUpdated; }
public async Task InsertOrMergeAsync(IFeedCandle candle, PriceType priceType, TimeInterval interval) { // Get candle table entity var partitionKey = CandleTableEntity.GeneratePartitionKey(priceType); var rowKey = CandleTableEntity.GenerateRowKey(candle.DateTime, interval); var entity = await _tableStorage.GetDataAsync(partitionKey, rowKey) ?? new CandleTableEntity(partitionKey, rowKey); // Merge candle entity.MergeCandle(candle, interval); // Update await _tableStorage.InsertOrMergeAsync(entity); }
private static bool GetCachedMovingAverage(string stockName, PriceType priceType, int days, out double[] movingAverage) { var key = GetSmaKey(stockName, priceType, days); if (cachedMovingAverages.ContainsKey(key)) { movingAverage = cachedMovingAverages[key]; return(true); } else { movingAverage = null; return(false); } }
// trailing stop constructor public TradingStrategy(ulong init_price, ulong stoppx, double price_offset_percentage, ulong order_size_as_maker = 0) { _priceType = PriceType.TRAILING_STOP; _strategySide = OrderSide.SELL; _trailing_stop_entry_price = init_price; _stop_price = stoppx; _stoppx_offset_percentage = price_offset_percentage; Debug.Assert(price_offset_percentage > 0 && price_offset_percentage < 100); _trailing_stop_high_price = (ulong)(Math.Round(stoppx / 1e8 / (1 - price_offset_percentage / 100), 3) * 1e8); _trailing_stop_cap_price = (ulong)(Math.Round(init_price / 1e8 * (1 + price_offset_percentage / 100), 3) * 1e8); _maxOrderSize = order_size_as_maker > 0 ? order_size_as_maker : _minOrderSize * 100; _buyTargetPrice = 0; _sellTargetPrice = 0; _startTime = Util.ConvertToUnixTimestamp(DateTime.Now); }
public static async Task<decimal> FetchPriceAsync(int typeId, int region = -1, int system = -1, PriceType type = PriceType.sell, PriceMeasure measure = PriceMeasure.min) { try { var webClient = new WebClient(); var uri = GetUriForRequest(typeId, region, system); var xml = await webClient.DownloadStringTaskAsync(uri); var xdoc = XDocument.Parse(xml); return Decimal.Parse(xdoc.Descendants(type.ToString()).Single().Descendants(measure.ToString()).Single().Value); } catch (Exception e) { Console.Error.WriteLine(e); return -1; } }
private ContractQuotes( Uid uid, IEnumerable<Quote> bids, IEnumerable<Quote> offers, IEnumerable<Execution> executions, Execution? lastExecution, PriceType priceType, QuantityType quantityType) { _uid = uid; _bids = GetQuoteDict(bids, Price.BidOrder); _offers = GetQuoteDict(offers, Price.OfferOrder); _executions = new List<Execution>(executions); _lastExecution = lastExecution; _priceType = priceType; _quantityType = quantityType; }
public override LoadUpdatesResult LoadUpdates(PriceType type, bool forceUpdate) { var priceFormat = GetPriceFormat(_priceFormatFile); var csvPriceLoader = new CsvPriceLoader(_priceEncoding, priceFormat); var newPriceLoader = new SingleFilePriceLoader(csvPriceLoader); var newPriceLoadResult = newPriceLoader.Load<string>(PriceUrl); PriceLoadResult oldPriceLoadResult = null; if (!forceUpdate) { var oldPriceLoader = new NewestFileSystemPriceLoader(csvPriceLoader); oldPriceLoadResult = oldPriceLoader.Load<string>(ArchiveDirectory); } return new LoadUpdatesResult(newPriceLoadResult, oldPriceLoadResult, newPriceLoadResult.Success); }
public ExchangeQuotation(Manager.Common.Settings.QuotePolicyDetail detail, Manager.Common.Settings.Instrument instrument) { this.QuotationPolicyId = detail.QuotePolicyId; this.InstruemtnId = detail.InstrumentId; this.InstrumentCode = instrument.Code; this.OriginInstrumentCode = instrument.OriginCode; this.PriceType = detail.PriceType; this.AutoAdjustPoints1 = detail.AutoAdjustPoints; this.AutoAdjustPoints2 = int.Parse(detail.AutoAdjustPoints2); this.AutoAdjustPoints3 = int.Parse(detail.AutoAdjustPoints3); this.AutoAdjustPoints4 = int.Parse(detail.AutoAdjustPoints4); this.SpreadPoints1 = detail.SpreadPoints; this.SpreadPoints2 = int.Parse(detail.SpreadPoints2); this.SpreadPoints3 = int.Parse(detail.SpreadPoints3); this.SpreadPoints4 = int.Parse(detail.SpreadPoints4); this.MaxAuotAdjustPoints = detail.MaxAutoAdjustPoints; this.MaxSpreadPoints = detail.MaxSpreadPoints; this.IsOriginHiLo = detail.IsOriginHiLo; this.IsAutoFill = instrument.IsAutoFill; this.IsPriceEnabled = instrument.IsPriceEnabled; this.IsAutoEnablePrice = instrument.IsAutoEnablePrice; this.OrderTypeMask = instrument.OrderTypeMask; this.AcceptLmtVariation = instrument.AcceptLmtVariation; this.AutoDQMaxLot = instrument.AutoDQMaxLot; this.AlertVariation = instrument.AlertVariation; this.DqQuoteMinLot = instrument.DqQuoteMinLot; this.MaxDQLot = instrument.MaxDQLot; this.NormalWaitTime = instrument.NormalWaitTime; this.AlertWaitTime = instrument.AlertWaitTime; this.MaxOtherLot = instrument.MaxOtherLot; this.CancelLmtVariation = instrument.CancelLmtVariation; this.MaxMinAdjust = instrument.MaxMinAdjust; this.PenetrationPoint = instrument.PenetrationPoint; this.PriceValidTime = instrument.PriceValidTime; this.AutoCancelMaxLot = instrument.AutoCancelMaxLot; this.AutoAcceptMaxLot = instrument.AutoAcceptMaxLot; }
private void setComboBoxItemOHLC(ComboBox combo, PriceType priceType) { combo.Text = priceType.ToString(); }
static HistoryInfo GetBarsInfo(string symbol, PriceType priceType, BarPeriod period) { return FdkHelper.Wrapper.ConnectLogic.Storage.Online.GetBarsInfo(symbol, priceType, period); }
static Bar[] CalculateBarsForSymbolArrayRangeTime( string symbol, PriceType priceType, DateTime startTime, DateTime endTime, BarPeriod barPeriod) { return FdkHelper.Wrapper.ConnectLogic.Storage.Online.GetBars(symbol, priceType, barPeriod, startTime, endTime).ToArray(); }
public static DataTable GetProductsByType(TypeFlag type, int count, PriceType priceType) { var priceField = priceType.ToString(); string sqlCmd = "select Top(@count) Product.ProductId, Product.ArtNo, Name, BriefDescription, " + "(CASE WHEN Offer.ColorID is not null THEN (Select TOP(1) PhotoName From [Catalog].[Photo] WHERE ([Photo].ColorID = Offer.ColorID or [Photo].ColorID is null) and [Product].[ProductID] = [Photo].[ObjId] and Type=@Type order by main desc, PhotoSortOrder) ELSE (Select TOP(1) PhotoName From [Catalog].[Photo] WHERE [Product].[ProductID] = [Photo].[ObjId] and Type=@Type order by main desc, PhotoSortOrder) END) AS Photo, " + "(CASE WHEN Offer.ColorID is not null THEN (Select TOP(1) [Photo].[Description] From [Catalog].[Photo] WHERE ([Photo].ColorID = Offer.ColorID or [Photo].ColorID is null) and [Product].[ProductID] = [Photo].[ObjId] and Type=@Type) ELSE (Select TOP(1) [Photo].[Description] From [Catalog].[Photo] WHERE [Product].[ProductID] = [Photo].[ObjId] and Type=@Type AND [Photo].[Main] = 1) END) AS PhotoDesc, " + "Discount, Ratio, RatioID, AllowPreOrder, Recomended, New, BestSeller, OnSale, UrlPath, " + "ShoppingCartItemID, " + (SettingsCatalog.UseLastPrice ? string.Format("(CASE WHEN ProductPrice IS NULL THEN {0} ELSE ProductPrice END) as Price, ", priceField) : string.Format("{0} as Price, ", priceField) ) + "(Select Max(Offer.Amount) from catalog.Offer Where ProductId=[Product].[ProductID]) as Amount," + " Offer.OfferID, Offer.ColorID, MinAmount, " + (SettingsCatalog.ComplexFilter ? "(select [Settings].[ProductColorsToString]([Product].[ProductID])) as Colors": "null as Colors") + " from Catalog.Product " + "LEFT JOIN [Catalog].[Offer] ON [Product].[ProductID] = [Offer].[ProductID] and Offer.main=1 " + "LEFT JOIN Catalog.Photo on Product.ProductID=Photo.ObjId and Type=@Type and Photo.main=1 " + "LEFT JOIN [Catalog].[ShoppingCart] ON [Catalog].[ShoppingCart].[OfferID] = [Catalog].[Offer].[OfferID] AND [Catalog].[ShoppingCart].[ShoppingCartType] = @ShoppingCartType AND [ShoppingCart].[CustomerID] = @CustomerId " + "Left JOIN [Catalog].[Ratio] on Product.ProductId=Ratio.ProductID and Ratio.CustomerId=@CustomerId " + "LEFT JOIN [Customers].[LastPrice] ON [LastPrice].[ProductId] = [Product].[ProductId] AND [LastPrice].[CustomerId] = @CustomerId " + "where {0} and Enabled=1 and CategoryEnabled=1 and [Settings].[CountCategoriesByProduct](Product.ProductID) > 0 order by {1}"; switch (type) { case TypeFlag.Bestseller: sqlCmd = string.Format(sqlCmd, "Bestseller=1", "SortBestseller"); break; case TypeFlag.New: sqlCmd = string.Format(sqlCmd, "New=1", "SortNew"); break; case TypeFlag.Discount: sqlCmd = string.Format(sqlCmd, "Discount>0", "SortDiscount"); break; default: throw new NotImplementedException(); } return SQLDataAccess.ExecuteTable(sqlCmd, CommandType.Text, new SqlParameter {ParameterName = "@count", Value = count}, new SqlParameter("@CustomerId", CustomerSession.CustomerId.ToString()), new SqlParameter("@Type", PhotoType.Product.ToString()), new SqlParameter("@ShoppingCartType", ShoppingCartType.Compare)); }
internal void SetValue(Source source_, PriceType priceType_, double? value_) { switch (source_) { case Source.DS: { switch (priceType_) { case PriceType.Price: DSPrice = value_; break; case PriceType.Yield: DSYield = value_; break; case PriceType.MMS: DSMMS = value_; break; case PriceType.Spread: DSSpread = value_; break; case PriceType.TrueSpread: DSTrueSpread = value_; break; } } break; case Source.MLP: { switch (priceType_) { case PriceType.Price: MLPPrice = value_; break; case PriceType.Yield: MLPYield = value_; break; case PriceType.MMS: MLPMMS = value_; break; case PriceType.Spread: MLPSpread = value_; break; case PriceType.TrueSpread: MLPTrueSpread = value_; break; } } break; } }
/// <summary> /// Starts execution of MqlAdapter. /// </summary> /// <param name="address">Server address.</param> /// <param name="username">User name.</param> /// <param name="password">Password.</param> /// <param name="location">Storage and logs location.</param> /// <param name="symbol">Symbol.</param> /// <param name="priceType">Price type.</param> /// <param name="periodicity">Periodicity.</param> /// <param name="adapter">Mql adapter.</param> public MqlLauncher(string address, string username, string password, string location, string symbol, PriceType priceType, string periodicity, MqlAdapter adapter) : base(address, username, password, location, symbol, priceType, periodicity, adapter) { }
/// <summary> /// 获得某个类型的票价 /// </summary> /// <param name="type"></param> /// <returns></returns> public override decimal GetPrice(PriceType type) { var tp = GetTicketPrice(type); if (tp == null) return 0; return tp.Price; }
public ProgramItemCommand(string name, int plu, TaxGr taxGr, int dep, int group, decimal price, decimal quantity = 9999, PriceType priceType = PriceType.FixedPrice) { Command = 107; Data = (new object[] { "P", plu, taxGr, dep, group, (int)priceType, price, "", quantity, "", "", "", "", name }).StringJoin("\t"); }
/// <summary> /// The method takes the full snapshot of the manager state. /// </summary> /// <returns></returns> public Snapshot TakeSnapshot(string symbol, PriceType priceType, BarPeriod periodicity) { lock (this.synchronizer) { var result = new Snapshot(this.Snapshot, this.storage, symbol, periodicity, priceType); return result; } }