public List <SecurityInformationViewModel> GetSecuritiesInformationViewModels( [ModelBinder(typeof(TypeSafeEnumModelBinder))] StockBoard tradeSector = null, string securityCode = null) { List <SecurityInformation> entities = _marketDataProvider.GetSecuritiesInformation(tradeSector, securityCode); return(AutoMapper.Mapper.Map <List <SecurityInformation>, List <SecurityInformationViewModel> >(entities)); }
public EntityResponse <List <SecurityInformation> > GetSecuritiesInformation(StockBoard stockBoard = null, string securityCode = null) { try { List <SZKingdomArgument> arguments = new List <SZKingdomArgument> { SZKingdomArgument.StockBoard(stockBoard), SZKingdomArgument.SecurityCode(securityCode) }; var retFromKingdom = _marketDataLibrary.ExecuteCommandList <SecurityInformation>(SZKingdomRequest.SecuritiesInformation, arguments); EntityResponse <List <SecurityInformation> > result = CheckForEmptyResult(retFromKingdom); //EntityResponse<List<SecurityInformation>> result = // CheckForEmptyResult(_marketDataLibrary.ExecuteCommandList<SecurityInformation>(SZKingdomRequest.SecuritiesInformation, arguments)); if (securityCode != null && result.IsSuccess && result.Entity.Count != 1) { Logging.Logger.Debug("thread ID:" + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString() + ", GetSecuritiesInformation return SZKingdomLibraryNoRecords," + ", class is MarketDataProvider"); return(ErrorCode.SZKingdomLibraryNoRecords); } return(result); } catch (Exception ex) { Logging.Logger.Debug("thread ID:" + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString() + "Exception is" + ex.StackTrace.ToString() + ", class is MarketDataProvider"); return(null); } }
public IGroupRuntimeMetric GetMetricForBoard(StockBoard board) { int index = _boardMetricIndices[(int)board]; if (index < 0) { return(null); } else { return(_context.GroupMetricManager.GetMetric(index)); } }
public StandardEvaluationContext( ITradingDataProvider provider, EquityManager equityManager, ILogger logger, TradingSettings settings = null, StreamWriter dumpDataWriter = null, StockBlockRelationshipManager relationshipManager = null) { if (equityManager == null || provider == null || logger == null) { throw new ArgumentNullException(); } _provider = provider; _equityManager = equityManager; _logger = logger; _settings = settings; _relationshipManager = relationshipManager; var metricManager = new StandardRuntimeMetricManager(_provider.GetAllTradingObjects().Length); var groupMetricManager = new StandardGroupRuntimeMetricManager(metricManager); // register the group metric manager as observer of metric manager. metricManager.RegisterAfterUpdatedMetricsObserver(groupMetricManager); _metricManager = metricManager; _groupMetricManager = groupMetricManager; _boardIndexTradingObjects = new Dictionary <string, ITradingObject>(); var boards = new StockBoard[] { StockBoard.GrowingBoard, StockBoard.MainBoard, StockBoard.SmallMiddleBoard }; foreach (var board in boards) { string boardIndex = StockName.GetBoardIndex(board); ITradingObject tradingObject = GetTradingObject(boardIndex); _boardIndexTradingObjects.Add(boardIndex, tradingObject); } _dumper = dumpDataWriter == null ? null : new StreamDataDumper(dumpDataWriter, 8, 3, _settings.DumpMetrics, this, _provider); }
public static string GetBoardIndex(StockBoard board) { switch (board) { case StockBoard.GrowingBoard: return(GrowingBoardIndex); case StockBoard.SmallMiddleBoard: return(SmallMiddleBoardIndex); case StockBoard.MainBoard: return(MainBoardIndex); default: return(MainBoardIndex); } }
/// <summary> /// NOTE: Cached. /// </summary> public EntityResponse <List <SecurityInformation> > GetSecuritiesInformation(StockBoard stockBoard = null, string securityCode = null) { //lock (MemoryCache.SecurityInformationCache) //{ if (!MemoryCache.IsSecurityInformationCacheExpired(securityCode)) { // memory cache working. return(MemoryCache.SecurityInformationCache[securityCode].SecurityInformations); } DBCacheStatus status; IQueryable <SecurityInformationCache> databaseCache = _databaseCacheService.Get <SecurityInformationCache>(out status); if (status != DBCacheStatus.Ok) { EntityResponse <List <SecurityInformation> > info = GetAllSecuritiesInformationFromLibrary(); if (info.IsSuccess) { List <SecurityInformationCache> mapped = Mapper.Map <List <SecurityInformation>, List <SecurityInformationCache> >(info); _databaseCacheService.UpdateCache(mapped); List <SecurityInformation> result = info.Entity.Where(si => (stockBoard == null || si.TradeSector == stockBoard) && (securityCode == null || si.SecurityCode == securityCode)).ToList(); MemoryCache.AddOrUpdateSecurityInformationCache(securityCode, result); return(result); } return(info); } if (stockBoard != null) { string tradeSectorCode = stockBoard.ToString(); databaseCache = databaseCache.Where(si => si.TradeSector == tradeSectorCode); } if (securityCode != null) { databaseCache = databaseCache.Where(si => si.SecurityCode == securityCode); } List <SecurityInformation> mappedResult = Mapper.Map <List <SecurityInformationCache>, List <SecurityInformation> >(databaseCache.ToList()); MemoryCache.AddOrUpdateSecurityInformationCache(securityCode, mappedResult); return(mappedResult); //} }
public EntityResponse <List <LockableUnderlyingInformation> > GetLockableUnderlyings(StockBoard stockBoard, string tradeAccount, string customerCode = null, string accountCode = null) { List <SZKingdomArgument> arguments = new List <SZKingdomArgument>(); if (customerCode == null && accountCode == null) { EntityResponse <List <LockableUnderlyingInformation> > entityReponse = EntityResponse <List <LockableUnderlyingInformation> > .Error(ErrorCode.SZKingdomLibraryError, SameCodesErrorMessage); return(entityReponse); } arguments.Add(SZKingdomArgument.CustomerCode(customerCode)); arguments.Add(SZKingdomArgument.CustomerAccountCode(accountCode)); arguments.Add(SZKingdomArgument.StockBoard(stockBoard)); arguments.Add(SZKingdomArgument.TradeAccount(tradeAccount)); EntityResponse <List <LockableUnderlyingInformation> > result = _marketDataLibrary .ExecuteCommandList <LockableUnderlyingInformation>(SZKingdomRequest.LockableUnderlyings, arguments); return(result); }
public ITradingObject GetBoardIndexTradingObject(StockBoard board) { return(_boardIndexTradingObjects[StockName.GetBoardIndex(board)]); }
public static string GetBoardIndex(StockBoard board) { return(StockName.NormalizeCode(StockBoardIndex.GetBoardIndex(board))); }