public async Task <int> SaveAsync(List <EquityApi.BalanceSheet.Response> responses) { foreach (var response in responses) { List <BalanceSheetEntity> entities = response.BalanceSheetEntityList; if (ValidateEntities(entities) != 0) { GeneralInfo generalInfo = response.GeneralInfo; _logger.LogInformation("IngestionTask ==> Symbol: {0}", generalInfo.Symbol); IngestionTask ingestionTask = IngestionTask.Create(string.Format("Balance Sheet {0}", generalInfo.ExchangeId), string.Format("Symbol: {0}", generalInfo.Symbol)); _ingestionContext.IngestionTasks.Add(ingestionTask); TGeneralInfo tGeneralInfo = _mapper.Map <TGeneralInfo>(generalInfo); tGeneralInfo.Id = Guid.NewGuid(); tGeneralInfo.IngestionTaskId = ingestionTask.IngestionTaskId; _ingestionContext.TGeneralInfo.Add(tGeneralInfo); foreach (var entity in entities) { TBalanceSheet item = _mapper.Map <TBalanceSheet>(entity); item.Id = Guid.NewGuid(); item.IngestionTaskId = ingestionTask.IngestionTaskId; _ingestionContext.TBalanceSheets.Add(item); } } } return(await _ingestionContext.SaveChangesAsync()); }
public CFATManager(ERUN_MODE nMode = ERUN_MODE.BACKTEST, string sMode = "") { m_configGeneral = new TGeneralInfo(); CConfigMng.load_config_general(ref m_configGeneral); CMQClient.connectToMQ(m_configGeneral.sHost, m_configGeneral.sUser, m_configGeneral.sPwd); CFATLogger.output_proc(string.Format("###### Start Mode = {0} #######", sMode)); CFATManager.m_nRunMode = nMode; m_lstLogics = new List <CLogic>(); m_configLogics = new List <Dictionary <string, string> >(); m_configSites = new List <Dictionary <string, string> >(); m_configWorkTimes = new List <TWorkTimeInterval>(); }
public async Task <int> SaveAsync(List <EquityApi.ProfitabilityRatios.Response> responses, bool isTTM = false) { foreach (var response in responses) { List <ProfitabilityEntity> entities = response.ProfitabilityEntityList; if (ValidateEntities(entities) != 0) { GeneralInfo generalInfo = response.GeneralInfo; _logger.LogInformation("IngestionTask ==> Symbol: {0}", generalInfo.Symbol); IngestionTask ingestionTask = IngestionTask.Create(string.Format("ProfitabilityRatios {0}", generalInfo.ExchangeId), string.Format("Symbol: {0}", generalInfo.Symbol)); _ingestionContext.IngestionTasks.Add(ingestionTask); TGeneralInfo tGeneralInfo = _mapper.Map <TGeneralInfo>(generalInfo); tGeneralInfo.Id = Guid.NewGuid(); tGeneralInfo.IngestionTaskId = ingestionTask.IngestionTaskId; _ingestionContext.TGeneralInfo.Add(tGeneralInfo); foreach (var entity in entities) { if (isTTM) { TProfitabilityRatioTTM item = _mapper.Map <TProfitabilityRatioTTM>(entity); item.Id = Guid.NewGuid(); item.IngestionTaskId = ingestionTask.IngestionTaskId; _ingestionContext.TProfitabilityRatioTTMs.Add(item); } else { TProfitabilityRatio item = _mapper.Map <TProfitabilityRatio>(entity); item.Id = Guid.NewGuid(); item.IngestionTaskId = ingestionTask.IngestionTaskId; _ingestionContext.TProfitabilityRatios.Add(item); } } } } return(await _ingestionContext.SaveChangesAsync()); }