/// <inheritdoc/> public void AddOrUpdateQuote(IQuote quote) { // TODO: Concurrency Notes - We execute this action only when the removalAll for this symbol is not in progress // When the RemoveQuote for this GUID is not in progress // When the Trade Execution this symbol is not in progress // When the Add or Update for this GUID is not in progress // Extra notes: Always the locking is for a given stock SYMBOL / GUID depending on the operation // The time complexity if proportional to log2(no. of items for that quote's symbol) if (quote == null) { throw new ArgumentNullException(NULL_QUOTE_ARGUMENT_MESSAGE); } if (IsExpiredQuote(quote)) { throw new ArgumentException(EXPIRED_QUOTE_MESSAGE); } if (quote.Id != null) { if (!quoteBook.ContainsKey(quote.Id)) { throw new KeyNotFoundException(NO_ACTIVE_QUOTE_MESSAGE); } UpdateQuote(quote); } else { AddQuote(Guid.NewGuid(), quote); } }
public QuotesPageViewModel(IQuote quoteObject, INavigationService navigationService) { Quotes = new ObservableCollection <Quote>(); quoteInstance = quoteObject; LoadQuotes(); NavigationService = navigationService; }
public void Setup() { quote1 = new Quote { Id = Guid.NewGuid(), AvailableVolume = 1500, ExpirationDate = DateTime.Now.AddDays(2), Price = 9.5, Symbol = "DEF" }; quote2 = new Quote { Id = Guid.NewGuid(), AvailableVolume = 1700, ExpirationDate = DateTime.Now.AddDays(2), Price = 10, Symbol = "DEF" }; quote3 = new Quote { Id = Guid.NewGuid(), AvailableVolume = 1000, ExpirationDate = DateTime.Now.AddDays(3), Price = 9, Symbol = "DEF" }; quotes = new List <IQuote>(); quotes.Add(quote1); quotes.Add(quote2); quotes.Add(quote3); }
public void AccurateForMoreCarpets() { //6b746c7d - 754d - 4049 - 9c5c - f2abfe73f9d3 9 80 25 2000 $6,668.67 //67b751bb - de92 - 4d4d - 8e33 - 13b535fc9bbd 9 25 75 1875 $5,388.74 //de4d199e - ce50 - 47e9 - 993f - ffb47d071db2 9 90 20 1800 $4,672.48 //e181f408 - 3f56 - 40d8 - 9149 - d12a06aeea18 9 20 70 1400 $4,251.46 //grade 9 float expectedPriceResult = (float)((6668.67m + 5388.74m + 4672.48m + 4251.46m) * 1.4m); string[] expectedCarpetIdArray = { "6b746c7d-754d-4049-9c5c-f2abfe73f9d3", "67b751bb-de92-4d4d-8e33-13b535fc9bbd", "de4d199e-ce50-47e9-993f-ffb47d071db2", "e181f408-3f56-40d8-9149-d12a06aeea18" }; IQuote lowestQuote = _joust.GetQuote(new int[] { 7000, 0, 0, 9 }); Assert.Equal(expectedPriceResult, lowestQuote.Price); Assert.Equal(expectedCarpetIdArray.Length, lowestQuote.RollOrders.Length); Assert.Contains <string>(expectedCarpetIdArray[0], lowestQuote.RollOrders); Assert.Contains <string>(expectedCarpetIdArray[1], lowestQuote.RollOrders); Assert.Contains <string>(expectedCarpetIdArray[2], lowestQuote.RollOrders); Assert.Contains <string>(expectedCarpetIdArray[3], lowestQuote.RollOrders); }
private void QuoteUpdate(string exchangeName, string dataSource, IQuote quote) { string sSymbolId = quote.SymbolId; int iIndex = source.IndexOf(sSymbolId); _QuoteInfo cQuoteInfo = null; double dPrice = quote.RealTick.Price; if (iIndex == -1) { if (sSymbolId.Length == 0) { return; } else { cQuoteInfo = new _QuoteInfo(exchangeName, dataSource, sSymbolId, quote.SymbolName, dPrice); source.Add(cQuoteInfo); } } else { cQuoteInfo = source.GetItemAt(iIndex); } cQuoteInfo.SetPrice(dPrice); cQuoteInfo.SetVolume(quote.RealTick.Volume); cQuoteInfo.SetTime(quote.RealTick.Time.TimeOfDay); }
/// <summary> /// Updates controls which are set to use multi currency. /// </summary> /// <param name="quote">The quote.</param> /// <param name="exchangeRate">The exchange rate.</param> private void UpdateMultiCurrencyExchangeRate(IQuote quote, double exchangeRate) { var systemInfo = ApplicationContext.Current.Services.Get <ISystemOptionsService>(true); string baseCode = ""; if (!string.IsNullOrEmpty(systemInfo.BaseCurrency)) { baseCode = systemInfo.BaseCurrency; } var currencyCode = EntityFactory.GetById <IExchangeRate>(lueCurrencyCode.LookupResultValue); string exhangeCode = currencyCode != null ? currencyCode.CurrencyCode : quote.CurrencyCode; curBaseSubTotal.CurrentCode = baseCode; curBaseTotal.CurrentCode = baseCode; curBaseTax.CurrentCode = baseCode; curBaseDiscount.CurrentCode = baseCode; curBaseShipping.CurrentCode = baseCode; curSubTotal.CurrentCode = exhangeCode; curTotal.CurrentCode = exhangeCode; curDiscount.CurrentCode = exhangeCode; curTax.CurrentCode = exhangeCode; curTax.ExchangeRate = exchangeRate; curShipping.CurrentCode = exhangeCode; curShipping.ExchangeRate = exchangeRate; }
internal void MergeTicks() { string sDataSource = __cDataRequest.DataFeed; AbstractQuoteService cService = QuoteManager.Manager.GetQuoteService(sDataSource); if (cService != null) { if (cService.TradeDate > LastBarTime.Date) { //如果即時報價服務交易日期大於最後 Bars 交易日期, 就合併今日即時資訊 this.Initialized = false; __cDataRequest.Range.To = cService.TradeDate; Indexer.RealtimeIndex = __cCloses.Count - __iRealtimeCount - 1; this.CreateRealtimePeriods(); string sSymbolId = __cDataRequest.Symbol; IQuote cQuote = cService.Storage.GetQuote(sSymbolId); if (cQuote != null) { int iTickCount = cQuote.TickCount; for (int i = iTickCount - 1; i >= 0; i--) { Merge(cQuote.GetTick(i)); } } } else { //盤後分檔與日檔資料已經公布, 不用在合併今日即時資訊 string sSymbolId = __cDataRequest.Symbol; IQuote cQuote = cService.Storage.GetQuote(sSymbolId); if (cQuote != null) { __dOVolume = cQuote.RealTick.Volume; //取得今日即時資訊的總成交量(當 tick 來時會比對tick 總成交量是否比此變數大, 如果比較大就合併到 Bars 內, 所以如果今日已有分日檔資訊, 此欄位需填入今日即時資訊總成交量, 才不會被重複合併到最後一根 Bars) } } } this.Initialized = true; }
public void UpdatePair(IQuote quote) { _pairs.AddOrUpdate( key: quote.AssetPair, addValueFactory: pairCode => AssetPair.Create(quote), updateValueFactory: (pairCode, pair) => pair.ProcessQuote(quote)); }
public PriceQuote(IQuote quote) { Symbol = quote.Symbol; LastPrice = quote.LastPrice; OpenPrice = quote.OpenPrice; LastTime = quote.LastTime; }
private double[] GetLimitPrice(double priceScale) { IQuote cQuote = this.Bars.Quotes; double dReferPrice = (cQuote == null) ? this.Bars.Close.Value : cQuote.ReferPrice; double dPrice1 = dReferPrice * (1 - 漲跌幅交易限制); double dPrice2 = dReferPrice * (1 + 漲跌幅交易限制); return new double[] { Math.Round((Math.Floor(dPrice1 / priceScale) + 1) * priceScale, 2), Math.Round(Math.Floor(dPrice2 / priceScale) * priceScale, 2) }; }
private void TrustUpdate() { IQuote cQuote = __cStorage.GetQuote(__sSymbolId); DOMPrice[] cAsks = cQuote.DOM.Ask; DOMPrice[] cBids = cQuote.DOM.Bid; if (cAsks != null && cBids != null) { int iLength = cAsks.Length; for (int i = 0; i < iLength; i++) { _DOMInfo cDOM = null; if (i < source.Count) { cDOM = source.GetItemAt(i); } else { cDOM = new _DOMInfo(__iDecimalPoint); source.Add(cDOM); } cDOM.SetDOM(cAsks[i], cBids[i]); } } }
public QuotesPageViewModel(IQuote quotes, INavigationService navigationService) { Quotes = new ObservableCollection <Quote>(); _quotes = quotes; LoadQuotes(); NavigationService = navigationService; }
private static StonkValues GetValues(IQuote quote) { StonkValues vals = new StonkValues(quote.Symbol, quote.TimestampUtc, (double)quote.AskPrice, (double)quote.BidPrice); return(vals); }
static void cService_onSubscribeCompleted(object sender, Events.QuoteComplementCompletedEvent e) { //cService.onSubscribeCompleted -= cService_onSubscribeCompleted; System.Console.WriteLine("s " + e.SymbolId); IQuote cQuote = cService.Storage.GetQuote(e.SymbolId); System.Console.WriteLine(cQuote); }
private FuturesContractManager() { _quote = QuoteCenter2.Instance.Quote; _benchmarkBLL = new BenchmarkBLL(); _futurescontractdao = new FuturesContractDAO(); _futuresItems = new List <SecurityItem>(); _benchmarks = new List <Benchmark>(); }
public Security(XmlRpcStruct security, XmlRpcStruct quote) : this(security) { if (quote == null) this.latestQuote = null; else this.latestQuote = new Quote(quote); }
protected void lnkLinkQuote_Click(object sender, EventArgs e) { var page = Page as EntityPage; if (page != null && page.EntityContext != null) { if (page.EntityContext.EntityType == typeof(IQuote)) { IQuote quote = EntityFactory.GetRepository <IQuote>().Get(page.EntityContext.EntityID); if (quote != null) { IAccount account = quote.Account; // First validation is if the associated Account is Synced if (account == null || account.ErpExtId == null) { // If associated Account is not in Sync throw error throw new ValidationException(GetLocalResourceObject("Error_Account_NotPromoted").ToString()); } // Second Validation is if the Quote had line items var quoteItems = quote.QuoteItems; if (quoteItems == null || quoteItems.Count() <= 0) { throw new ValidationException(GetLocalResourceObject("Error_Quote_NoLineItems").ToString()); } IBackOffice backOffice = Utilities.GetBackOfficeByLogicalID(quote.ErpLogicalId); if (backOffice == null) { backOffice = Utilities.GetBackOfficeByLogicalID(account.ErpLogicalId); } //Get the BOD Mapping from SalesOrder entity. IBODMapping bodMapping = Utilities.GetBODMappingByEntityBackoffice(GetLocalResourceObject("Quote_EntityName").ToString(), backOffice); if (bodMapping != null && bodMapping.IsActive == true && bodMapping.OutboundOnCreate == false) { throw new ValidationException(String.Format(GetLocalResourceObject("OutBoundCreate.Caption").ToString())); } string caption = GetLocalResourceObject("lblLinkQuote.Caption").ToString(); DialogService.SetSpecs(200, 200, 250, 600, "QuoteSalesOrderPromotion", caption, true); string id = GetSelectedRecord(); if (!String.IsNullOrEmpty(id)) { DialogService.DialogParameters.Remove("LinkAccountSelectedId"); DialogService.DialogParameters.Add("LinkAccountSelectedId", id); DialogService.ShowDialog(); if (quote.SyncStatus == GetLocalResourceObject("lblLinkQuote.Caption").ToString()) { lblLinkQuote.Visible = false; imgLinkQuote.Visible = false; } } } else { throw new ValidationException(GetLocalResourceObject("Error_QuoteNotFound").ToString()); } } } }
/// <summary> /// Blocks until a quote can be dequeued from the queue/ /// </summary> /// <returns>An IQuote</returns> public IQuote GetNextQuote() { IQuote quote = null; while (this.queue.TryDequeue(out quote) != true) { } return(quote); }
public async Task <int> FillQuotes(IEnumerable <IQuote> quotes, IQuote last) { var res = await GetQuotes( quotes.First().Timestamp.AddMinutes(-30), quotes.Last().Timestamp); if (res.Count == 0) { foreach (var quote in quotes) { quote.Btc = last?.Btc ?? 0; quote.Eur = last?.Eur ?? 0; quote.Usd = last?.Usd ?? 0; quote.Cny = last?.Cny ?? 0; quote.Jpy = last?.Jpy ?? 0; quote.Krw = last?.Krw ?? 0; quote.Eth = last?.Eth ?? 0; quote.Gbp = last?.Gbp ?? 0; } } else { var i = 0; foreach (var quote in quotes) { if (quote.Timestamp < res[0].Timestamp) { quote.Btc = last?.Btc ?? 0; quote.Eur = last?.Eur ?? 0; quote.Usd = last?.Usd ?? 0; quote.Cny = last?.Cny ?? 0; quote.Jpy = last?.Jpy ?? 0; quote.Krw = last?.Krw ?? 0; quote.Eth = last?.Eth ?? 0; quote.Gbp = last?.Gbp ?? 0; } else { while (i < res.Count - 1 && quote.Timestamp >= res[i + 1].Timestamp) { i++; } quote.Btc = res[i].Btc; quote.Eur = res[i].Eur; quote.Usd = res[i].Usd; quote.Cny = res[i].Cny; quote.Jpy = res[i].Jpy; quote.Krw = res[i].Krw; quote.Eth = res[i].Eth; quote.Gbp = res[i].Gbp; } } } return(quotes.Count()); }
public void AddOrUpdateQuote(IQuote quote) { if (!(quote is T quoteExtended)) { throw new ArgumentOutOfRangeException(nameof(quote)); } AddOrUpdateQuote(quoteExtended); }
public void AddQuoteInitial_Test() { quote = BuildQuote("FRC", 177.38, 1000, DateTime.Today.AddDays(1)); quoteManager.AddOrUpdateQuote(quote); var addedQuote = quoteManager.GetBestQuoteWithAvailableVolume("FRC"); Assert.AreEqual(quote, addedQuote); }
internal QuoteExtended(IQuote quote) { Id = quote.Id; Symbol = quote.Symbol; Price = quote.Price; AvailableVolume = quote.AvailableVolume; ExpirationDate = quote.ExpirationDate; ExpirationTimestamp = ExpirationDate.ToUnixTimestamp(); }
/// <summary> /// Updates an exisiting quote /// </summary> /// <param name="quote"></param> /// <exception cref="ArgumentException">Throws an exception if the quote is not found or if it's an invalid quote</exception> private void UpdateQuote(IQuote quote) { // Here I took liberty of updating the baseQuote's date as well from the quote which is not called out in the requirement // This is because I thought we may in some cases where we want to extend or decrease the expiry time // This type of Remove and Add opertions keeps the integrity of the 2 internal data structures - quoteBook and the symbolsQuoteBook RemoveQuote((Guid)quote.Id); AddQuote(quote); }
public void AddQuote(IQuote quote) { _quotes.Add(quote); if (++_samplesCount == _bufferSize) { FinancialDataManager.Instance.AddQuotes(_quotes, false); _quotes.Clear(); _samplesCount = 0; } }
/// <summary> /// Get the quotes /// </summary> /// <param name="pageLevel"></param> /// <param name="model"></param> private void GetQuote(int pageLevel, BlogListViewModel model) { GetQuotePosition(pageLevel, model); IQuote quote = _quoteService.GetQuotes(pageLevel); if (quote != null) { model.Quote = quote.Summary; model.QuotesAuthor = quote.Author?.FirstName + " " + quote.Author?.LastName; } }
private void CreateIndexOptions(DateTime date) { if (logger.IsInfoEnabled) { logger.Info("開始轉換指數型選擇權資料..."); } List <string> cStocks = __cExchange.GetProductClassify(ESymbolCategory.IndexOption); foreach (string sStock in cStocks) { int iIndex = sStock.LastIndexOf("."); if (iIndex > -1) { iIndex -= 2; if (sStock[iIndex] >= 'A') { continue; //沒有轉換代號的選擇權全部都不要轉換 } } AbstractProductProperty cProperty = __cExchange.GetProperty(sStock, "Mitake"); if (cProperty != null) { IQuote cQuote = MitakeStorage.Storage.GetQuote(sStock); if (cQuote != null) { SeriesSymbolData cMSeries = CreateSeries(sStock, EResolution.Minute, date); SeriesSymbolData cDSeries = CreateSeries(sStock, EResolution.Day, date); int iLast = cQuote.TickCount - 1; if (iLast >= 0) { for (int i = iLast; i >= 0; i--) { ITick cTick = cQuote.GetTick(i); if (cTick != null) { cMSeries.Merge(cTick); cDSeries.Merge(cTick); } } FileAdapter cAdapter = new FileAdapter(Settings.GlobalSettings.Settings.DataPath, false); cAdapter.Write(cMSeries); cAdapter.Write(cDSeries); System.Console.Write("Convert... {0} ", sStock); System.Console.CursorLeft = 0; } } } } }
public static IQuote Copy(this IQuote original) { return(new Quote { Id = original.Id, Symbol = original.Symbol, Price = original.Price, AvailableVolume = original.AvailableVolume, ExpirationDate = original.ExpirationDate }); }
private async Task ProcessQuote(IQuote entry) { try { _cacheService.UpdatePair(entry); } catch (Exception ex) { await _log.WriteErrorAsync(Constants.ComponentName, null, null, ex); } }
private void QuoteService_onCompleted(object sender, QuoteComplementCompletedEvent e) { AbstractQuoteService cService = QuoteManager.Manager.GetQuoteService(e.DataSource); IQuote cQuote = cService.Storage.GetQuote(e.SymbolId); if (cQuote != null) { QuoteUpdate(e.ExchangeName, e.DataSource, cQuote); //更新報價 RefreshGrid(); } }
public void AddOrUpdateQuote(IQuote quote) { if (_quoteRepository.Contains(quote.Id)) { _quoteRepository.Update(quote); } else { _quoteRepository.Add(quote); } }
private static void VerifyQuote( IQuote quote, decimal rate, int amount, decimal monthlyRepayment, decimal totalRepayment) { const decimal amountPrecision = 0.01m; const decimal ratePrecision = 0.0001m; quote.Rate.Should().BeApproximately(rate, ratePrecision); quote.RequestedAmount.Should().Be(amount); quote.MonthlyRepayment.Should().BeApproximately(monthlyRepayment, amountPrecision); quote.TotalRepayment.Should().BeApproximately(totalRepayment, amountPrecision); }
public Security(XmlRpcStruct security) { IDataAccess data = DataAccessFactory.GetDataAccess(); this.isin = (string)security["ISIN"]; this.symbol = (string)security["SYMBOL"]; this.name = (string)security["NAME"]; this.exchange = data.GetExchangeBySymbol((string)security["EXCHANGE"]); this.visible = (Convert.ToInt32(security["VISIBLE"]) == 1) ? true : false; this.suspended = (Convert.ToInt32(security["SUSPENDED"]) == 1) ? true : false; this.latestQuote = null; }
private void QuoteUpdate(string exchangeName, string dataSource, IQuote quote) { string sSymbolName = quote.SymbolName; int iIndex = source.IndexOf(sSymbolName); _QuoteInfo cQuoteInfo = null; double dPrice = quote.RealTick.Price; if (iIndex == -1) { string sSymbolId = quote.SymbolId; if (sSymbolId.Length == 0) { return; } else { cQuoteInfo = new _QuoteInfo(exchangeName, dataSource, sSymbolId, dPrice); cQuoteInfo.SymbolName = quote.SymbolName; source.Add(cQuoteInfo); } } else { cQuoteInfo = source.GetItemAt(iIndex); } cQuoteInfo.SetPrice(dPrice); cQuoteInfo.SetVolume(quote.RealTick.Volume); cQuoteInfo.SetTime(quote.RealTick.Time.TimeOfDay); }
/// <summary> /// 建構子 /// </summary> /// <param name="exchangeName">交易所簡稱</param> /// <param name="dataSource">報價元件名稱</param> /// <param name="quote">報價資訊</param> public QuoteEvent(string exchangeName, string dataSource, IQuote quote) { __sExchangeName = exchangeName; __sDataSource = dataSource; __cQuote = quote; }
public RfqUpdate(RfqState rfqState, IQuote quote, IExecutionReport executionReport) { RfqState = rfqState; Quote = quote; ExecutionReport = executionReport; }
/* ---------------------------------------- * STATEMACHINE TRANSITION HANDLERS * * All internal logic should be handled here. * For server calls, server callbacks (ie. responses, errors, etc) * are only allowed to transition the state machine * ---------------------------------------*/ private void OnEntryQuoted(IQuote quote) { _rfqUpdateSubject.OnNext(new RfqUpdate(RfqState.Quoted, quote, null)); }
public QuoteMessage(IQuote quote) { Price = quote.price; SymbolName = quote.symbol.name; timestamp = quote.timestamp; }
public void AddQuote(IQuote inQuote) { //TODO: Add code to detect whether this quote already exists. this.Quotes.Add(inQuote); }
public IQuote GetLatestQuote() { if (latestQuote == null) { IDataAccess data = DataAccessFactory.GetDataAccess(); latestQuote = data.GetLatestQuoteFromSecurity(isin); } return latestQuote; }