109 lines
5.5 KiB
Plaintext
109 lines
5.5 KiB
Plaintext
/*
|
|
// The IncomeStatement sources from Yahoo Finance
|
|
private static List<IncomeStatement> GetIncomeStatementYahoo(String symbol,IncomeStatement.PeriodType periodType)
|
|
{
|
|
List<IncomeStatement> incomeStatements = new List<IncomeStatement>();
|
|
HttpNetResponse httpNetResponse=null;
|
|
try
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
String strRequest;
|
|
sb.Append("http://finance.yahoo.com/q/is?s=").Append(symbol.ToUpper()).Append("+Income+Statement");
|
|
sb.Append(periodType.Equals(IncomeStatement.PeriodType.Quarterly)?"&quarterly":"&annual");
|
|
strRequest = sb.ToString();
|
|
httpNetResponse=HttpNetRequest.GetRequestNoEncoding(strRequest);
|
|
if(!httpNetResponse.Success)return incomeStatements;
|
|
|
|
// No currency conversion ability so only pull USD
|
|
String currency=Utility.KeepAfterLast(httpNetResponse.ResponseString,"<!-- react-text: 27 -->Currency in");
|
|
if(null!=currency)
|
|
{
|
|
currency=Utility.BetweenString(currency,"",".");
|
|
if(null!=currency)currency=currency.ToUpper().Trim();
|
|
if(null!=currency &&!"USD".Equals(currency))
|
|
{
|
|
MDTrace.WriteLine(String.Format("No currency conversion from {0} to {1}",currency,"USD"));
|
|
return null;
|
|
}
|
|
}
|
|
|
|
List<String> strItems=null;
|
|
strItems=MarketDataHelper.LocateItems(httpNetResponse.ResponseString,">Revenue<",4,4);
|
|
if(null==strItems||0==strItems.Count)return incomeStatements;
|
|
for(int index=0;index<strItems.Count;index++)
|
|
{
|
|
IncomeStatement incomeStatement=new IncomeStatement();
|
|
incomeStatement.AsOf = DateTime.Parse(strItems[index]);
|
|
incomeStatement.Symbol = symbol.ToUpper();
|
|
incomeStatement.Period = periodType;
|
|
incomeStatements.Add(incomeStatement);
|
|
}
|
|
strItems=MarketDataHelper.LocateItems(httpNetResponse.ResponseString,">Total Revenue<");
|
|
if(null!=strItems)
|
|
{
|
|
for(int index=0;index<strItems.Count&&index<incomeStatements.Count;index++)incomeStatements[index].TotalRevenue=ParseValue(strItems[index])*1000.00;
|
|
}
|
|
strItems=MarketDataHelper.LocateItems(httpNetResponse.ResponseString,">Cost of Revenue<");
|
|
if(null!=strItems)
|
|
{
|
|
for(int index=0;index<strItems.Count&&index<incomeStatements.Count;index++)incomeStatements[index].CostOfRevenue=ParseValue(strItems[index])*1000.00;
|
|
}
|
|
strItems=MarketDataHelper.LocateItems(httpNetResponse.ResponseString,">Income Tax Expense<");
|
|
if(null!=strItems)
|
|
{
|
|
for(int index=0;index<strItems.Count&&index<incomeStatements.Count;index++)incomeStatements[index].IncomeTaxExpense=ParseValue(strItems[index])*1000.00;
|
|
}
|
|
strItems=MarketDataHelper.LocateItems(httpNetResponse.ResponseString,">Gross Profit<");
|
|
if(null!=strItems)
|
|
{
|
|
for(int index=0;index<strItems.Count&&index<incomeStatements.Count;index++)incomeStatements[index].GrossProfit=ParseValue(strItems[index])*1000.00;
|
|
}
|
|
strItems=MarketDataHelper.LocateItems(httpNetResponse.ResponseString,">Net Income<");
|
|
if(null!=strItems)
|
|
{
|
|
for(int index=0;index<strItems.Count&&index<incomeStatements.Count;index++)incomeStatements[index].NetIncome=ParseValue(strItems[index])*1000.00;
|
|
}
|
|
strItems=MarketDataHelper.LocateItems(httpNetResponse.ResponseString,">Selling General and Administrative<");
|
|
if(null!=strItems)
|
|
{
|
|
for(int index=0;index<strItems.Count&&index<incomeStatements.Count;index++)incomeStatements[index].SGA=ParseValue(strItems[index])*1000.00;
|
|
}
|
|
strItems=MarketDataHelper.LocateItems(httpNetResponse.ResponseString,">Net Income Applicable To Common Shares<");
|
|
if(null!=strItems)
|
|
{
|
|
for(int index=0;index<strItems.Count&&index<incomeStatements.Count;index++)incomeStatements[index].NetIncomeApplicableToCommonShares=ParseValue(strItems[index])*1000.00;
|
|
}
|
|
strItems=MarketDataHelper.LocateItems(httpNetResponse.ResponseString,">Earnings Before Interest and Taxes<");
|
|
if(null!=strItems)
|
|
{
|
|
for(int index=0;index<strItems.Count&&index<incomeStatements.Count;index++)incomeStatements[index].EBIT=ParseValue(strItems[index])*1000.00;
|
|
}
|
|
strItems=MarketDataHelper.LocateItems(httpNetResponse.ResponseString,">Operating Expenses<");
|
|
if(null!=strItems)
|
|
{
|
|
for(int index=0;index<strItems.Count&&index<incomeStatements.Count;index++)incomeStatements[index].OperatingExpenses=ParseValue(strItems[index])*1000.00;
|
|
}
|
|
strItems=MarketDataHelper.LocateItems(httpNetResponse.ResponseString,">Research Development<");
|
|
if(null!=strItems)
|
|
{
|
|
for(int index=0;index<strItems.Count&&index<incomeStatements.Count;index++)incomeStatements[index].ResearchAndDevelopment=ParseValue(strItems[index])*1000.00;
|
|
}
|
|
strItems=MarketDataHelper.LocateItems(httpNetResponse.ResponseString,">Interest Expense<");
|
|
if(null!=strItems)
|
|
{
|
|
for(int index=0;index<strItems.Count&&index<incomeStatements.Count;index++)incomeStatements[index].InterestExpense=ParseValue(strItems[index])*1000.00;
|
|
}
|
|
return incomeStatements;
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
MDTrace.WriteLine(LogLevel.DEBUG,exception.ToString());
|
|
return null;
|
|
}
|
|
finally
|
|
{
|
|
if(null!=httpNetResponse)httpNetResponse.Dispose();
|
|
}
|
|
}
|
|
*/
|