private double GetRealtimeTrend(SymbolItem smbItem) { double lastPrice = 0; double startPrice = 0; lock (m_LastPrice) { m_LastPrice.TryGetValue(smbItem, out lastPrice); m_StartPrice.TryGetValue(smbItem, out startPrice); } if (lastPrice < startPrice * 0.75 || lastPrice < 10) { return(1.5); } else if (lastPrice > startPrice * 1.25) { return(0.5); } else { return(1); } //more then 1 - need trend to up //less then 1 - need trend to down //1 - simulation }
public void UnsubscribeLevel2(SymbolItem aSymbol) { lock (m_Level2SubscribeSymbol) { m_Level2SubscribeSymbol.Remove(aSymbol); } }
public void UnsubscribeLevel2(SymbolItem aSymbol) { string aSymbolName = BuildSymbolName(aSymbol.Symbol, aSymbol.Type); lock (m_Level2SubscribedSymbol) { if (m_Level2SubscribedSymbol.Contains(aSymbolName)) { m_Level2SubscribedSymbol.Remove(aSymbolName); } } bool isLevel1Subscribed = false; lock (m_Level2SubscribedSymbol) { isLevel1Subscribed = m_SubscribedSymbol.Contains(aSymbolName); } if (!isLevel1Subscribed) { lock (m_DDFSymbols) { m_DDFSymbols.Remove(aSymbolName); } UpdateSubscriberSymbols(); } }
public void SubscribeLevel2(SymbolItem aSymbol) { string aSymbolName = BuildSymbolName(aSymbol.Symbol, aSymbol.Type); bool isAdded = true; lock (m_Level2SubscribedSymbol) { if (!m_Level2SubscribedSymbol.Contains(aSymbolName)) { isAdded = false; m_Level2SubscribedSymbol.Add(aSymbolName); } } if (!isAdded) { lock (m_DDFSymbols) { if (!m_DDFSymbols.Contains(aSymbolName)) { m_DDFSymbols.Add(aSymbolName); isAdded = false; } else { isAdded = true; } } } if (!isAdded) { UpdateSubscriberSymbols(); } }
/// <summary> /// see IDataFeeder interface /// </summary> public void UnSubscribe(SymbolItem aSymbol) { lock (m_SubscribeSymbol) { m_SubscribeSymbol.Remove(aSymbol); } }
/// <summary> /// occurs when data feed sends a quote /// </summary> /// void OnDdfClient_NewQuote(object sender, Client.NewQuoteEventArgs e) { try { string aSymbolName; Instrument aType; Session session = e.Quote.Sessions[Sessions.Combined]; if (!TryParse(e.Quote.Symbol, out aSymbolName, out aType)) { return; } if (NewQuote != null && m_SubscribedSymbol.Contains(aSymbolName)) { SymbolItem aSymbol = new SymbolItem() { DataFeed = Name, Exchange = MarketName, Symbol = aSymbolName, Type = aType }; NewQuote(Name, this.TimeZoneInfo, new Tick { Symbol = aSymbol, //Date = e.Quote.Timestamp.ToUniversalTime(), Date = TimeZoneInfo.ConvertTimeToUtc(e.Quote.Timestamp, TimeZoneInfo), Price = session == null ? (e.Quote.Ask + e.Quote.Bid) / 2 : session.Last, Volume = session == null ? 0 : session.LastSize, Bid = e.Quote.Bid, BidSize = e.Quote.BidSize, Ask = e.Quote.Ask, AskSize = e.Quote.AskSize }); } if (NewLevel2 != null && m_Level2SubscribedSymbol.Contains(aSymbolName)) { SymbolItem aSymbol = new SymbolItem() { DataFeed = Name, Exchange = MarketName, Symbol = aSymbolName, Type = aType }; Level2Data level2 = new Level2Data(); level2.Symbol = aSymbol; level2.Asks = new Level2Item[] { new Level2Item { MarketMaker = Level1MarketMaker, Price = e.Quote.Ask, Quantity = (int)e.Quote.AskSize } }; level2.Bids = new Level2Item[] { new Level2Item { MarketMaker = Level1MarketMaker, Price = e.Quote.Bid, Quantity = (int)e.Quote.BidSize } }; NewLevel2(Name, this.TimeZoneInfo, level2); } } catch (Exception ex) { WriteToLog("---OnDdfClient_NewQuote Exception", ex); } }
private static Item Deref(SymbolSpace space, SymbolItem symbol) { var reference = space.Lookup(symbol.Name); return(reference is EvaluateableItem ? (reference as EvaluateableItem).Quote() : reference); }
private void LoadLines2ListBox() { listBoxLines.Items.Clear(); foreach (SymbolLine item in this.SymbolLinesCache) { SymbolItem symbol = new SymbolItem(item); listBoxLines.Items.Add(symbol); } }
private void Validate(HistoryRequest aRequest) { SymbolItem aSymbol = aRequest.Selection.Symbol; if (aSymbol.Type == Instrument.Unknown) { throw new ApplicationException("Invalid instrument"); } }
private void Validate(UnsubscribeRequest aRequest) { SymbolItem aSymbol = aRequest.Symbol; if (aSymbol.Type == Instrument.Unknown) { throw new ApplicationException("Invalid instrument"); } }
public object Clone() { SymbolItem result = this.MemberwiseClone() as SymbolItem; foreach (PointD item in this.Points) { result.Points.Add(item.Clone() as PointD); } return(result); }
protected async Task NavigateToSymbolItemAsync( Document document, NavigationBarItem item, SymbolItem symbolItem, ITextVersion textVersion, CancellationToken cancellationToken) { var workspace = document.Project.Solution.Workspace; var(documentId, position, virtualSpace) = await GetNavigationLocationAsync( document, item, symbolItem, textVersion, cancellationToken).ConfigureAwait(false); await NavigateToPositionAsync(workspace, documentId, position, virtualSpace, cancellationToken).ConfigureAwait(false); }
public void SubscribeLevel2(SymbolItem aSymbol) { lock (m_Level2SubscribeSymbol) { if (!m_Level2SubscribeSymbol.Contains(aSymbol)) { m_Level2SubscribeSymbol.Add(aSymbol); } } }
public TradescriptAlert(string name, SymbolItem symbol, string script, IList <Bar> history) { _Alert = new Modulus.TradeScript.Alert(); _Alert.License = TradeScript.TradeScriptKey; _Alert.Symbol = symbol.Symbol; _Alert.AlertName = name; _Alert.AlertScript = script; TradeScript.AppendData(_Alert, history); _Alert.OnScriptError += alert_OnError; _Alert.OnAlert += alert_OnAlert; }
public static void UnSubscribeSymbolList(SymbolItem sysmbol) { try { dataServerClient.UnSubscribeSymbolList(new List <SymbolItem> { sysmbol }); } catch (Exception ex) { Logger.Error(ex); } }
protected async Task NavigateToSymbolItemAsync( Document document, NavigationBarItem item, SymbolItem symbolItem, ITextVersion textVersion, CancellationToken cancellationToken) { var workspace = document.Project.Solution.Workspace; var(documentId, position, virtualSpace) = await GetNavigationLocationAsync( document, item, symbolItem, textVersion, cancellationToken).ConfigureAwait(false); // Ensure we're back on the UI thread before either navigating or showing a failure message. await this.ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); NavigateToPosition(workspace, documentId, position, virtualSpace, cancellationToken); }
private double GetLastPrice(SymbolItem smbItem) { double lastPrice; lock (m_LastPrice) { if (!m_LastPrice.TryGetValue(smbItem, out lastPrice)) { lastPrice = (double)m_Random.Next(100000) / 100; m_LastPrice[smbItem] = lastPrice; m_StartPrice[smbItem] = lastPrice; } } return(lastPrice); }
static void ShowNodeValue(SymbolItem item) { if (Config.Instance.NaviBarOptions.MatchFlags(NaviBarOptions.FieldValue) == false) { return; } switch (item.SyntaxNode.Kind()) { case SyntaxKind.VariableDeclarator: item.Hint = (item.SyntaxNode as VariableDeclaratorSyntax).Initializer?.Value?.ToString(); break; case SyntaxKind.EnumMemberDeclaration: item.Hint = (item.SyntaxNode as EnumMemberDeclarationSyntax).EqualsValue?.Value?.ToString(); break; case SyntaxKind.PropertyDeclaration: var p = item.SyntaxNode as PropertyDeclarationSyntax; if (p.Initializer != null) { item.Hint = p.Initializer.Value.ToString(); } else if (p.ExpressionBody != null) { item.Hint = p.ExpressionBody.ToString(); } else if (Config.Instance.NaviBarOptions.MatchFlags(NaviBarOptions.AutoPropertyAnnotation)) { var a = p.AccessorList.Accessors; if (a.Count == 2) { if (a[0].Body == null && a[0].ExpressionBody == null && a[1].Body == null && a[1].ExpressionBody == null) { item.Hint = "{;;}"; } } else if (a.Count == 1) { if (a[0].Body == null && a[0].ExpressionBody == null) { item.Hint = "{;}"; } } } break; } }
public Item ParseValue(string instring) { // number if (char.IsDigit(instring[0])) { return(new ValueItem(ItemType.Number, double.Parse(instring))); } // string if (instring[0] == '"') { return(new ValueItem( ItemType.String, instring.Substring(1, instring.Length - 2))); } // Type if (instring[0] == ':') { var type = (ItemType)Enum.Parse(typeof(ItemType), instring.Substring(1), true); return(new TypeItem(type)); } // symbol var current = instring; var quote = false; if (instring[0] == '\'') { current = current.Substring(1); quote = true; } if (char.IsDigit(current.First())) { throw new FormatException(); } var symbol = new SymbolItem(current); if (quote) { symbol.Quote(); } return(symbol); }
/// <summary> /// see IDataFeeder interface /// </summary> public void Subscribe(SymbolItem aSymbol) { string aSymbolName = BuildSymbolName(aSymbol.Symbol, aSymbol.Type); int maxWhileCount = 20; int whileCount = 0; while (m_ConnectionStatus == Status.Connecting || m_ConnectionStatus == Status.Disconnecting) { Thread.Sleep(100); whileCount++; if (whileCount >= maxWhileCount) { break; } } bool isAdded = true; lock (m_SubscribedSymbol) { if (!m_SubscribedSymbol.Contains(aSymbol.Symbol)) { isAdded = false; m_SubscribedSymbol.Add(aSymbol.Symbol); } } if (!isAdded) { lock (m_DDFSymbols) { if (!m_DDFSymbols.Contains(aSymbolName)) { m_DDFSymbols.Add(aSymbolName); isAdded = false; } else { isAdded = true; } } } if (!isAdded) { UpdateSubscriberSymbols(); } }
public int Compare(TreeNodeViewModel x, TreeNodeViewModel y) { SymbolItem symbolX = (x as INodeWithSymbolItem)?.Symbol; SymbolItem symbolY = (y as INodeWithSymbolItem)?.Symbol; if (symbolX == null && symbolY == null) //Always place nodes without symbol first { return(0); } else if (symbolX == null) { return(1); } else if (symbolY == null) { return(-1); } return(symbolX.DeclarationOrder - symbolY.DeclarationOrder); }
internal virtual Task <(DocumentId documentId, int position, int virtualSpace)> GetNavigationLocationAsync( Document document, NavigationBarItem item, SymbolItem symbolItem, ITextVersion textVersion, CancellationToken cancellationToken) { if (symbolItem.Location.InDocumentInfo != null) { // If the item points to a location in this document, then just determine the where that span currently // is (in case recent edits have moved it) and navigate there. var navigationSpan = item.GetCurrentItemSpan(textVersion, symbolItem.Location.InDocumentInfo.Value.navigationSpan); return(Task.FromResult((document.Id, navigationSpan.Start, 0))); } else { // Otherwise, the item pointed to a location in another document. Just return the position we // computed and stored for it. Contract.ThrowIfNull(symbolItem.Location.OtherDocumentInfo); var(documentId, span) = symbolItem.Location.OtherDocumentInfo.Value; return(Task.FromResult((documentId, span.Start, 0))); } }
/// <summary> /// see IDataFeeder interface /// </summary> public void UnSubscribe(SymbolItem aSymbol) { string aSymbolName = BuildSymbolName(aSymbol.Symbol, aSymbol.Type); int maxWhileCount = 20; int whileCount = 0; while (m_ConnectionStatus == Status.Connecting || m_ConnectionStatus == Status.Disconnecting) { Thread.Sleep(100); whileCount++; if (whileCount >= maxWhileCount) { break; } } lock (m_SubscribedSymbol) { if (m_SubscribedSymbol.Contains(aSymbolName)) { m_SubscribedSymbol.Remove(aSymbolName); } } bool isLevel2Subscribed = false; lock (m_Level2SubscribedSymbol) { isLevel2Subscribed = m_Level2SubscribedSymbol.Contains(aSymbolName); } if (!isLevel2Subscribed) { lock (m_DDFSymbols) { m_DDFSymbols.Remove(aSymbolName); } UpdateSubscriberSymbols(); } }
internal virtual Task <(DocumentId documentId, int position, int virtualSpace)> GetNavigationLocationAsync( Document document, NavigationBarItem item, SymbolItem symbolItem, ITextVersion textVersion, CancellationToken cancellationToken) { // If the item points to a location in this document, then just determine the current location // of that item and go directly to it. var navigationSpan = item.TryGetNavigationSpan(textVersion); if (navigationSpan != null) { return(Task.FromResult((document.Id, navigationSpan.Value.Start, 0))); } else { // Otherwise, the item pointed to a location in another document. Just return the position we // computed and stored for it. Contract.ThrowIfNull(symbolItem.Location.OtherDocumentInfo); var(documentId, span) = symbolItem.Location.OtherDocumentInfo.Value; return(Task.FromResult((documentId, span.Start, 0))); } }
public static StockSymbol_FullDynamicData GetCurrentData(TradeCenter tradeCenter, string symbols, int full) { StockSymbol_FullDynamicData currentData = new StockSymbol_FullDynamicData(); try { bool isHOChange = false, isHAChange = false; int currentHOChangeId = full, currentHAChangeId = full; GetDatabaseState(ref currentHOChangeId, ref currentHAChangeId, ref isHOChange, ref isHAChange); if (tradeCenter == TradeCenter.HoSE) { #region Lay du lieu HoSE DataTable dtPriceData = new DataTable(); if (symbols != "" && (isHOChange || full == -1)) dtPriceData = GetHOSEDatatable_MemCache(symbols, (full == -1)); DataTable dtIndexData = new DataTable(); dtIndexData = GetHOSEIndexDatatable_MemCache(); currentData.ChangeId = currentHOChangeId; #region Index currentData.SessionId = 0; currentData.Indexs = new IndexItem[3]; if (dtIndexData.Rows.Count > 0) { #region Xác định phiên if (Lib.FormatDouble(dtIndexData.Rows[0]["Index3"]) != "0") // Phiên 3 { currentData.SessionId = 3; } else if (Lib.FormatDouble(dtIndexData.Rows[0]["Index2"]) != "0") // Phiên 2 { currentData.SessionId = 2; } else if (Lib.FormatDouble(dtIndexData.Rows[0]["Index1"]) != "0") // Phiên 1 { currentData.SessionId = 1; } #endregion currentData.PreviousIndex = Lib.FormatDouble(dtIndexData.Rows[0]["PrevIndex"]); currentData.Indexs[0].Index = Lib.FormatDouble(dtIndexData.Rows[0]["Index1"]); currentData.Indexs[0].Quantity = Lib.FormatDouble(dtIndexData.Rows[0]["Quantity1"]); currentData.Indexs[0].Volume = Lib.FormatDouble(dtIndexData.Rows[0]["Vol1"]); currentData.Indexs[0].Value = Lib.FormatDouble(dtIndexData.Rows[0]["Value1"]); currentData.Indexs[1].Index = Lib.FormatDouble(dtIndexData.Rows[0]["Index2"]); currentData.Indexs[1].Quantity = Lib.FormatDouble(dtIndexData.Rows[0]["Quantity2"]); currentData.Indexs[1].Volume = Lib.FormatDouble(dtIndexData.Rows[0]["Vol2"]); currentData.Indexs[1].Value = Lib.FormatDouble(dtIndexData.Rows[0]["Value2"]); currentData.Indexs[2].Index = Lib.FormatDouble(dtIndexData.Rows[0]["Index3"]); currentData.Indexs[2].Quantity = Lib.FormatDouble(dtIndexData.Rows[0]["Quantity3"]); currentData.Indexs[2].Volume = Lib.FormatDouble(dtIndexData.Rows[0]["Vol3"]); currentData.Indexs[2].Value = Lib.FormatDouble(dtIndexData.Rows[0]["Value3"]); } else { currentData.PreviousIndex = "0"; currentData.Indexs[0].Index = "0"; currentData.Indexs[0].Quantity = "0"; currentData.Indexs[0].Volume = "0"; currentData.Indexs[0].Value = "0"; currentData.Indexs[1].Index = "0"; currentData.Indexs[1].Quantity = "0"; currentData.Indexs[1].Volume = "0"; currentData.Indexs[1].Value = "0"; currentData.Indexs[2].Index = "0"; currentData.Indexs[2].Quantity = "0"; currentData.Indexs[2].Volume = "0"; currentData.Indexs[2].Value = "0"; } #endregion #region Thông tin giá hiện tại List<SymbolItem> items = new List<SymbolItem>(); foreach (DataRow drPriceData in dtPriceData.Rows) { SymbolItem symbol = new SymbolItem(); symbol.Symbol = drPriceData["Symbol"].ToString(); symbol.Datas = new string[22]; symbol.Datas[(int)HoSE_FieldName.Ref] = Lib.FormatDouble(drPriceData["Ref"]); symbol.Datas[(int)HoSE_FieldName.Cei] = Lib.FormatDouble(drPriceData["Ceiling"]); symbol.Datas[(int)HoSE_FieldName.Flo] = Lib.FormatDouble(drPriceData["Floor"]); symbol.Datas[(int)HoSE_FieldName.TraP] = FormatPrice(drPriceData["TradingPrice"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); symbol.Datas[(int)HoSE_FieldName.TraV] = FormatVolume(drPriceData["TradingVol"], drPriceData["TradingPrice"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); string BidPrice1 = (drPriceData["BidPrice1"] == null ? "" : drPriceData["BidPrice1"].ToString()); string BidVol1 = (drPriceData["BidVol1"] == null ? "" : drPriceData["BidVol1"].ToString()); if (BidPrice1 == "" || BidPrice1 == "0") { if (BidVol1 == "" || BidVol1 == "0") { BidPrice1 = ""; } else { if (currentData.SessionId == 1) { BidPrice1 = "ATO"; } else if (currentData.SessionId == 3) { BidPrice1 = "ATC"; } else { BidPrice1 = ""; } } } else { BidPrice1 = drPriceData["BidPrice1"].ToString(); } symbol.Datas[(int)HoSE_FieldName.BidP1] = FormatPrice(BidPrice1, drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); symbol.Datas[(int)HoSE_FieldName.BidV1] = FormatVolume(drPriceData["BidVol1"], BidPrice1, drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); symbol.Datas[(int)HoSE_FieldName.BidP2] = FormatPrice(drPriceData["BidPrice2"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); symbol.Datas[(int)HoSE_FieldName.BidV2] = FormatVolume(drPriceData["BidVol2"], drPriceData["BidPrice2"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); symbol.Datas[(int)HoSE_FieldName.BidP3] = FormatPrice(drPriceData["BidPrice3"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); symbol.Datas[(int)HoSE_FieldName.BidV3] = FormatVolume(drPriceData["BidVol3"], drPriceData["BidPrice3"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); string SellPrice1 = (drPriceData["SellPrice1"] == null ? "" : drPriceData["SellPrice1"].ToString()); string SellVol1 = (drPriceData["SellVol1"] == null ? "" : drPriceData["SellVol1"].ToString()); if (SellPrice1 == "" || SellPrice1 == "0") { if (SellVol1 == "" || SellVol1 == "0") { SellPrice1 = ""; } else { if (currentData.SessionId == 1) { SellPrice1 = "ATO"; } else if (currentData.SessionId == 3) { SellPrice1 = "ATC"; } else { SellPrice1 = ""; } } } else { SellPrice1 = drPriceData["SellPrice1"].ToString(); } symbol.Datas[(int)HoSE_FieldName.SelP1] = FormatPrice(SellPrice1, drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); symbol.Datas[(int)HoSE_FieldName.SelV1] = FormatVolume(drPriceData["SellVol1"], SellPrice1, drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); symbol.Datas[(int)HoSE_FieldName.SelP2] = FormatPrice(drPriceData["SellPrice2"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); symbol.Datas[(int)HoSE_FieldName.SelV2] = FormatVolume(drPriceData["SellVol2"], drPriceData["SellPrice2"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); symbol.Datas[(int)HoSE_FieldName.SelP3] = FormatPrice(drPriceData["SellPrice3"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); symbol.Datas[(int)HoSE_FieldName.SelV3] = FormatVolume(drPriceData["SellVol3"], drPriceData["SellPrice3"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); symbol.Datas[(int)HoSE_FieldName.Pri1] = FormatPrice(drPriceData["TradingPrice1"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); symbol.Datas[(int)HoSE_FieldName.Max] = FormatPrice(drPriceData["TradingPriceMax"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); symbol.Datas[(int)HoSE_FieldName.Min] = FormatPrice(drPriceData["TradingPriceMin"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); FormatChangeValue(out symbol.Datas[(int)HoSE_FieldName.Chg], out symbol.Datas[(int)HoSE_FieldName.Img], drPriceData["TradingPrice"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); items.Add(symbol); } currentData.Symbols = items.ToArray(); #endregion dtIndexData.Dispose(); dtPriceData.Dispose(); #endregion } else { #region Lay du lieu HaSTC DataTable dtPriceData = new DataTable(); if (symbols != "" && (isHAChange || full == -1)) dtPriceData = GetHASTCDatatable_MemCache(symbols, (full == -1)); DataTable dtIndexData = new DataTable(); dtIndexData = GetHASTCIndexDatatable_MemCache(); currentData.ChangeId = currentHAChangeId; #region Index currentData.SessionId = 0; currentData.Indexs = new IndexItem[1]; if (dtIndexData.Rows.Count > 0) { currentData.PreviousIndex = Lib.FormatDouble(dtIndexData.Rows[0]["PrevIndex"]); currentData.Indexs[0].Index = Lib.FormatDouble(dtIndexData.Rows[0]["Index"]); currentData.Indexs[0].Quantity = Lib.FormatDouble(dtIndexData.Rows[0]["Quantity"]); currentData.Indexs[0].Volume = Lib.FormatDouble(dtIndexData.Rows[0]["Vol"]); currentData.Indexs[0].Value = Lib.FormatDouble(dtIndexData.Rows[0]["Value"]); } else { currentData.PreviousIndex = "0"; currentData.Indexs[0].Index = "0"; currentData.Indexs[0].Quantity = "0"; currentData.Indexs[0].Volume = "0"; currentData.Indexs[0].Value = "0"; } #endregion #region Thông tin giá hiện tại List<SymbolItem> items = new List<SymbolItem>(); foreach (DataRow drPriceData in dtPriceData.Rows) { SymbolItem symbol = new SymbolItem(); symbol.Symbol = drPriceData["Symbol"].ToString(); symbol.Datas = new string[22]; symbol.Datas[(int)HaSTC_FieldName.Ref] = Lib.FormatDouble(drPriceData["Ref"]); symbol.Datas[(int)HaSTC_FieldName.Cei] = Lib.FormatDouble(drPriceData["Ceiling"]); symbol.Datas[(int)HaSTC_FieldName.Flo] = Lib.FormatDouble(drPriceData["Floor"]); symbol.Datas[(int)HaSTC_FieldName.TraP] = FormatPrice(drPriceData["TradingPrice"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); symbol.Datas[(int)HaSTC_FieldName.TraV] = FormatVolume(drPriceData["TradingVol"], drPriceData["TradingPrice"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); symbol.Datas[(int)HaSTC_FieldName.BidP1] = FormatPrice(drPriceData["BidPrice1"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); symbol.Datas[(int)HaSTC_FieldName.BidV1] = FormatVolume(drPriceData["BidVol1"], drPriceData["BidPrice1"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); symbol.Datas[(int)HaSTC_FieldName.BidP2] = FormatPrice(drPriceData["BidPrice2"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); symbol.Datas[(int)HaSTC_FieldName.BidV2] = FormatVolume(drPriceData["BidVol2"], drPriceData["BidPrice2"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); symbol.Datas[(int)HaSTC_FieldName.BidP3] = FormatPrice(drPriceData["BidPrice3"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); symbol.Datas[(int)HaSTC_FieldName.BidV3] = FormatVolume(drPriceData["BidVol3"], drPriceData["BidPrice3"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); symbol.Datas[(int)HaSTC_FieldName.SelP1] = FormatPrice(drPriceData["SellPrice1"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); symbol.Datas[(int)HaSTC_FieldName.SelV1] = FormatVolume(drPriceData["SellVol1"], drPriceData["SellPrice1"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); symbol.Datas[(int)HaSTC_FieldName.SelP2] = FormatPrice(drPriceData["SellPrice2"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); symbol.Datas[(int)HaSTC_FieldName.SelV2] = FormatVolume(drPriceData["SellVol2"], drPriceData["SellPrice2"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); symbol.Datas[(int)HaSTC_FieldName.SelP3] = FormatPrice(drPriceData["SellPrice3"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); symbol.Datas[(int)HaSTC_FieldName.SelV3] = FormatVolume(drPriceData["SellVol3"], drPriceData["SellPrice3"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); symbol.Datas[(int)HaSTC_FieldName.TTV] = Lib.FormatDouble(drPriceData["TotalTradingVolume"]); symbol.Datas[(int)HaSTC_FieldName.Max] = FormatPrice(drPriceData["TradingPriceMax"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); symbol.Datas[(int)HaSTC_FieldName.Min] = FormatPrice(drPriceData["TradingPriceMin"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); FormatChangeValue(out symbol.Datas[(int)HaSTC_FieldName.Chg], out symbol.Datas[(int)HaSTC_FieldName.Img], drPriceData["TradingPrice"], drPriceData["Ceiling"], drPriceData["Floor"], drPriceData["Ref"]); items.Add(symbol); } currentData.Symbols = items.ToArray(); #endregion dtIndexData.Dispose(); dtPriceData.Dispose(); #endregion } } catch (Exception ex) { Lib.WriteLog(ex); } return currentData; }
private void SubscribeAlert(AlertSubscribeRequest aRequest) { var errorString = TradeScript.Validate(aRequest.Script); if (aRequest.Script == string.Empty) { errorString = "Script can not be empty"; } if (errorString != string.Empty) { var response = new AlertSubscribeResponse { Id = aRequest.Id, Error = errorString, AlertName = aRequest.AlertName, Alert = new Alert { Name = aRequest.Name, Symbol = aRequest.Symbol }, User = aRequest.User }; PushResponses(aRequest.User.ID, new ResponseMessage[] { response }); return; } var selection = new HistoryParameters(aRequest.Id, aRequest.Symbol, aRequest.Periodicity, aRequest.Interval, aRequest.BarsCount); IDataFeed aDataFeed = GetDataFeedByName(aRequest.Symbol.DataFeed); if (aDataFeed != null) { GetHistoryCtx aCtx = GetHistoryCtx(selection, aDataFeed.TimeZoneInfo); aCtx.Request = new HistoryRequest(selection); aCtx.DataFeed = aDataFeed; ThreadPool.QueueUserWorkItem(o => { aDataFeed.GetHistory(aCtx, (ctx, bars) => { Level1Subscribers subscribers = null; var symbolItem = new SymbolItem() { DataFeed = aRequest.Symbol.DataFeed, Exchange = aRequest.Symbol.Exchange, Symbol = aRequest.Symbol.Symbol, Type = aRequest.Symbol.Type }; lock (m_Level1SubscribersBySymbols) { if (!m_Level1SubscribersBySymbols.TryGetValue(aRequest.Symbol, out subscribers)) { subscribers = new Level1Subscribers(); subscribers.Subscribers = new List <string>(); subscribers.AlertSubscribers = new List <AlertSubscription>(); m_Level1SubscribersBySymbols.Add(aRequest.Symbol, subscribers); } } AlertSubscription alert = new AlertSubscription() { Id = aRequest.Id, AlertName = aRequest.AlertName, Symbol = symbolItem, Name = aRequest.Name, Periodicity = aRequest.Periodicity, Interval = aRequest.Interval, Script = aRequest.Script, UserSessionId = aRequest.User.ID, Login = aRequest.User.Login, CalculationType = aRequest.CalculationType }; alert.InitAlert(bars); lock (subscribers.AlertSubscribers) { subscribers.AlertSubscribers.Add(alert); } aDataFeed.Subscribe(aRequest.Symbol); }); }); } }
static void ShowNodeValue(SymbolItem item) { if (Config.Instance.NaviBarOptions.MatchFlags(NaviBarOptions.FieldValue) == false) { return; } switch (item.SyntaxNode.Kind()) { case SyntaxKind.VariableDeclarator: item.Hint = ((VariableDeclaratorSyntax)item.SyntaxNode).Initializer?.Value?.ToString(); break; case SyntaxKind.EnumMemberDeclaration: ShowEnumMemberValue(item); break; case SyntaxKind.PropertyDeclaration: ShowPropertyValue(item); break; } void ShowEnumMemberValue(SymbolItem enumItem) { var v = ((EnumMemberDeclarationSyntax)enumItem.SyntaxNode).EqualsValue; if (v != null) { enumItem.Hint = v.Value?.ToString(); } else { enumItem.SetSymbolToSyntaxNode(); enumItem.Hint = ((IFieldSymbol)enumItem.Symbol).ConstantValue?.ToString(); } } void ShowPropertyValue(SymbolItem propertyItem) { var p = (PropertyDeclarationSyntax)propertyItem.SyntaxNode; if (p.Initializer != null) { propertyItem.Hint = p.Initializer.Value.ToString(); } else if (p.ExpressionBody != null) { propertyItem.Hint = p.ExpressionBody.ToString(); } else if (Config.Instance.NaviBarOptions.MatchFlags(NaviBarOptions.AutoPropertyAnnotation)) { var a = p.AccessorList.Accessors; if (a.Count == 2) { if (a[0].Body == null && a[0].ExpressionBody == null && a[1].Body == null && a[1].ExpressionBody == null) { propertyItem.Hint = "{;;}"; } } else if (a.Count == 1) { if (a[0].Body == null && a[0].ExpressionBody == null) { propertyItem.Hint = "{;}"; } } } } }
void AddMemberDeclarations(SyntaxNode node, bool isExternal) { const byte UNDEFINED = 0xFF, TRUE = 1, FALSE = 0; var directives = Config.Instance.NaviBarOptions.MatchFlags(NaviBarOptions.Region) ? node.GetDirectives(d => d.IsKind(SyntaxKind.RegionDirectiveTrivia) || d.IsKind(SyntaxKind.EndRegionDirectiveTrivia)) : null; byte regionJustStart = UNDEFINED; // undefined, prevent #endregion show up on top of menu items int pos = _Bar._View.GetCaretPosition(); foreach (var child in node.ChildNodes()) { if (child.IsMemberDeclaration() == false && child.IsTypeDeclaration() == false) { continue; } if (directives != null) { for (var i = 0; i < directives.Count; i++) { var d = directives[i]; if (d.SpanStart < child.SpanStart) { if (d.IsKind(SyntaxKind.RegionDirectiveTrivia)) { var item = _Menu.Add(d, _Bar._SemanticContext); item.Hint = "#region"; item.Content = SetHeader(d, false, false, false); if (isExternal) { item.Type = SymbolItemType.External; } regionJustStart = TRUE; } else if (d.IsKind(SyntaxKind.EndRegionDirectiveTrivia)) { // don't show #endregion if preceeding item is #region if (regionJustStart == FALSE) { var item = new SymbolItem(_Menu); _Menu.Symbols.Add(item); item.Content.Append("#endregion ").Append(d.GetDeclarationSignature()); item.Content.Foreground = ThemeHelper.SystemGrayTextBrush; } } directives.RemoveAt(i); --i; } } if (directives.Count == 0) { directives = null; } } if (child.IsKind(SyntaxKind.FieldDeclaration) || child.IsKind(SyntaxKind.EventFieldDeclaration)) { AddVariables((child as BaseFieldDeclarationSyntax).Declaration.Variables, isExternal, pos); } else { var i = _Menu.Add(child, _Bar._SemanticContext); if (isExternal) { i.Type = SymbolItemType.External; } i.SelectIfContainsPosition(pos); ShowNodeValue(i); if (Config.Instance.NaviBarOptions.MatchFlags(NaviBarOptions.ParameterList)) { AddParameterList(i.Content, child); } } // a member is added between #region and #endregion regionJustStart = FALSE; } if (directives != null) { foreach (var item in directives) { if (item.IsKind(SyntaxKind.RegionDirectiveTrivia)) { var i = _Menu.Add(item, _Bar._SemanticContext); i.Hint = "#region"; i.Content = SetHeader(item, false, false, false); if (isExternal) { i.Type = SymbolItemType.External; } } } } }
public AlertSubscription() { Id = string.Empty; Symbol = new SymbolItem(); FiredAlertsHistory = new List <Alert>(FiredAlertsHistoryMaxLenght); }