Latest example of how to use Google Finance API in C#

5,235 views
Skip to first unread message

adam

unread,
Aug 10, 2009, 4:00:32 AM8/10/09
to Google Finance APIs and Tools
Hello,

I'm putting out a simple example of using Google's Finance API in C#.
You can download the zip which contains the source code for building
the example project SP500. SP500 console application lets you
manipulate your finance.google.com portfolios. There is also a command
to load S&P500 into a portfolio named SP500 (not all of the symbols
load cause of problems resolving the exchanges they are on.) Many bugs
in this application, this was meant to be an example, please let me
know what you find and/or email me a patch file. The
GoogleFinanceManager.cs should give you a good example of how to use
the wrappers to gdata's finance api in C#. All improvements and
criticism welcome.

http://googlefinance.googlecode.com/files/GoogleFinanceDemo.0.0.2.zip

Kind Regards,
Adam (http://googlefinance.googlecode.com)

Anil Dhiman

unread,
Aug 10, 2009, 5:53:51 AM8/10/09
to google-fi...@googlegroups.com
Thanks Adam,
                      SP500 gave a clear picture of how to use wrapper developed by you. I noticed one thing it doesn't return intraday values like price, low, high, volumes, 52 weeks low, 52 weeks high etc.
 
I found it very difficult to grasp your wrapper as it is very difficult for someone like me(beginner) to build an application on the top of it.
 
Still I am going through this wrapper implimentation in detail.
Regards,
Anil
--
Anil Dhiman

Anil Dhiman

unread,
Aug 10, 2009, 2:25:24 PM8/10/09
to google-fi...@googlegroups.com
I want to create a ASP.NET webpage which will load data from CSV file,, and display all the symbols with all its details like
Price,LOW,HIGH, 52Weeks high, 52 Weeks Low , Volumes etc in a grid view like:
 
for e.g.
 
Price                 LOW             HIGH                 Volumes
--------------------------------------------------------------------------------
GOOG             2000               2500                  34384923492
MSFT              5000               5500                   23423423424
 
 
I think this process may slow the things,, but stil I am looking at your API. I may come up with a solution with that.
Also, I am planning to create one spreadsheet and read data from it. I think it will be much faster.
but there is a limitation we can only implement 200 =Googlefinance functions per sheet,, We need to write some logic out there.
 
Let/s hope will come out with a good solution soon
 
 
~Anil
--
Anil Dhiman

Adam

unread,
Aug 10, 2009, 2:25:58 PM8/10/09
to google-fi...@googlegroups.com
Please prepare a list of problems you are having and not understanding , even example sequences of what you are trying to acomplish , reference google docs on finance API , somethings you might want may bot be supported, that project is lacking documentation which I will do next weekend

Kind regards 
Adam

Sent from my iPhone

Anil Dhiman

unread,
Aug 11, 2009, 2:43:40 PM8/11/09
to google-fi...@googlegroups.com
Adam,
            Can you please tell me how to retrieve position entries for my stock
I mean all the current positions like
 
Last price Change Mkt cap Volume Open High Low Day's ga
 
I could retrieve all portfolio, list all the stocks in a particular folio but could not understand how to retrieve stock positions.
Can u please help me on this/...
I could implement ur API on WEB using VB.NET..
 
 
Thanks for your support
 
 
Anil

 


--
Anil Dhiman

adam coding

unread,
Aug 12, 2009, 2:56:49 AM8/12/09
to google-fi...@googlegroups.com
Anil,

Some of those are not available yet (Google Finance API Team, Hint, Hint, Please Extend This API)... The best reference to the Finance API is http://code.google.com/apis/finance/reference.html
The schema does not provide much so far.. But in the SP500 console application if you check out the 'P' case statement, it should give you an idea of values that you could extract such as:

Choose a portfolio to print details of there stocks: [0]
6
Portfolio Name: test123

/portfolios/59/positions/NYSE:C/transactions
Symbol.FullName: Citigroup Inc.
Symbol.Exchange: NYSE
Symbol.StockSymbol: C
DaysGain:
        Amount=($750.00)
        Amount=USD

CostBasis:
        Amount=$3,020.00
        Amount=USD

Gain:
        Amount=$8,050.00
        Amount=USD

MarketValue:
        Amount=$11,070.00
        Amount=USD

GainPercentage: 2.665562914
Return1Week: 0.1353846154
Return4Week: 0.2636986301
Return3Month: -0.08208955224
ReturnYTD: -0.4500745156
Return1Year: -0.8096957194
Return3Year: -0.9230769231
Return5Year: -0.9164780444
ReturnOverall: 2.665562914
Shares: 3000

Check the schema out to see which types are what when handling the returns of transactions. I was a bit disappointed my self that Google did not provide a much more extensive API... But I think with time things will change, or you might be able to do some kind of screen scape on tags by navigating to the main page with the data your interested in. This weekend I might be working on something that can do something similar to that and integrate it into the base library. I'm not sure what you mean "implement API on WEB using VB.NET", this is C#  .NET so it all gets compiled down to the same code as VB.NET

Kind Regards,
Adam 

Anil Dhiman

unread,
Aug 12, 2009, 6:25:37 AM8/12/09
to google-fi...@googlegroups.com
Adam,
           It's very sad from Google that a company from such an extensive outlook could not come out with what we want. Nevertheless, I'll have to implement this by my own. I mean I am developing appilcation using ASP.NET but I am using VB as the development language.
 
Thanks for your support,
 
~Anil



--
Anil Dhiman

magnet

unread,
Sep 11, 2009, 10:14:32 AM9/11/09
to Google Finance APIs and Tools
From second run of SP500 project i get following error:

Unhandled Exception: Google.GData.Client.CaptchaRequiredException:
Captcha required

Dion Loy (Google)

unread,
Sep 11, 2009, 11:20:06 AM9/11/09
to Google Finance APIs and Tools
There is a quota limit per minute and per day on requests (to protect
our servers), you've probably tripped over one of those numbers by
issuing too many requests or too quickly. Try spacing out the
individual requests instead.

magnet

unread,
Sep 11, 2009, 11:50:34 AM9/11/09
to Google Finance APIs and Tools
Thanks

On Sep 11, 6:20 pm, "Dion Loy (Google)" <dloy+gro...@google.com>
wrote:
Reply all
Reply to author
Forward
0 new messages