Ejemplo n.º 1
0
        public async Task <KeyValuePair <FactLabel, FinancialFactTrendDataPoint[]>[]> GetFactsForChartRequestAsync(ChartingRequest request)
        {
            AletheiaService AlServ = new AletheiaService(apikey);
            List <KeyValuePair <FactLabel, FinancialFactTrendDataPoint[]> > ToReturn = new List <KeyValuePair <FactLabel, FinancialFactTrendDataPoint[]> >();

            foreach (FactLabel label in request.FactLabels)
            {
                FinancialFactTrendRequest trreq = new FinancialFactTrendRequest();
                trreq.Id         = request.CompanyId;
                trreq.Label      = label;
                trreq.PeriodType = request.PeriodType;
                trreq.After      = request.After;
                trreq.Before     = request.Before;
                FinancialFactTrendDataPoint[] points = await AlServ.FinancialFactTrendAsync(trreq);

                ToReturn.Add(new KeyValuePair <FactLabel, FinancialFactTrendDataPoint[]>(label, points));
            }
            return(ToReturn.ToArray());
        }
        public async Task <SecurityTransactionHolding[]> GetAllSecurityTransactionHoldingsAsync(string company_cik_or_symbol)
        {
            AletheiaService service = new AletheiaService(AletheiaApiKey);

            UpdateStatus("Getting starter transactions...");
            SecurityTransactionHolding[] sths = await service.LatestTransactionsAsync(company_cik_or_symbol, null, 100, null, SecurityType.NonDerivative, TransactionType.OpenMarketOrPrivatePurchase);

            //Collect
            List <SecurityTransactionHolding> ToReturn = new List <SecurityTransactionHolding>();

            while (sths.Length > 0)
            {
                UpdateStatus("Adding " + sths.Length.ToString() + " transactions...");

                foreach (SecurityTransactionHolding sth in sths)
                {
                    ToReturn.Add(sth);
                }

                //Find the oldest transaction in the group
                UpdateStatus("Finding oldest transaction...");
                DateTime oldest = DateTime.Now;
                foreach (SecurityTransactionHolding sth in sths)
                {
                    if (sth.TransactionDate.HasValue)
                    {
                        if (sth.TransactionDate < oldest)
                        {
                            oldest = sth.TransactionDate.Value;
                        }
                    }
                }
                UpdateStatus("Oldest transaction in this group: " + oldest.ToShortDateString());

                //Search again
                UpdateStatus("Querying again...");
                sths = await service.LatestTransactionsAsync(company_cik_or_symbol, null, 100, oldest, SecurityType.NonDerivative, TransactionType.OpenMarketOrPrivatePurchase);
            }

            UpdateStatus("Collection complete! " + ToReturn.Count.ToString("#,##0") + " found.");
            return(ToReturn.ToArray());
        }