Yahoo Finance C++ API design code

closed account (zqMDizwU)
Hey guys,
I get a bunch of broken links and nearly nothing when I search for how to hook up Yahoo Finance with C++ api.

Is there code for Yahoo Api or a search feature?

I need to look up stock tickers, volume, and closing price.
I have not found any C++ Yahoo Finance interface either so I started doing one myself past weekend. It is very early in development but it might be helpful.

The code is on:
closed account (zqMDizwU)
How far did you get it to work?
The library retrieves historical and current data (provided Yahoo! Finance delay) in CSV format as a string and provides basic error handling. There are essentially 2 functions (plus some convenience overloads).

All symbols described in were implemented.

I intend to add an option to name current data CSV columns.

I do not plan to elaborate much more than that, since there should be some good CSV parsers floating around the net.
Last edited on
closed account (zqMDizwU)
Hey man, your quote file is great but when I am trying to make file in the unbuntu 14.04 is giving me this error and telling me to recomplie with -fPIC so I added that to the complier flags.

Here is my error can you please help. Thanks!

mathewfok@mathewfok-Satellite-C855:~/Documents/quote/quote-master$ make
cd src && make all
make[1]: Entering directory `/home/mathewfok/Documents/quote/quote-master/src'
g++ -shared -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu/ -L/usr/lib -lcurl conversion.o core.o curl_util.o quote.o string_util.o -o
/usr/bin/ld: conversion.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
conversion.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make[1]: *** [] Error 1
make[1]: Leaving directory `/home/mathewfok/Documents/quote/quote-master/src'
make: *** [all] Error 2
-fPIC flag was in fact missing. I thought I had tested building on linux, but it seems I didn't. The correct rules are in the repository.

Thanks for pointing out the error!
closed account (zqMDizwU)
I am having compiling errors in my code. I have added this to get rid of the enum error and add c++11

Can you please help me run this code?
The library requires C++11 features to build. You must specify that to your compiler in order to use it in your project (flags: -std=c++11 or -std=c++0x - depending on your compiler version).

Did you get the sample to compile? You can build it with:

make samples

on quote root directory.
closed account (zqMDizwU)
mathewfok@mathewfok-Satellite-C855:~/Documents/quote/quote-master$ make samples
cd src && make static
make[1]: Entering directory `/home/mathewfok/Documents/quote/quote-master/src'
make[1]: Nothing to be done for `static'.
make[1]: Leaving directory `/home/mathewfok/Documents/quote/quote-master/src'
cd samples && make all
make[1]: Entering directory `/home/mathewfok/Documents/quote/quote-master/samples'
cd csv_string && make all
make[2]: Entering directory `/home/mathewfok/Documents/quote/quote-master/samples/csv_string'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/mathewfok/Documents/quote/quote-master/samples/csv_string'
make[1]: Leaving directory `/home/mathewfok/Documents/quote/quote-master/samples'

Here is the screen shot:
Last edited on
closed account (zqMDizwU)
Hey man if you see where my problems lie please help me. I gotta move on. This is for a group project, but they are just downloading the csv and I wanted to download the csvs through c++ through a yahoo finance api. Afterwards I will make our groups trading algorithm. I just need this to work. Tell me if you can't see that screenshot. We are supposed to use a Yahoo api, but as long as I get this to work everything should be fine.
Last edited on
I see. Dealing with the GNU toolchain can be quite cumbersome, especially for a beginner. I work primarily with IDEs, which makes my life a lot easier most of the times. However, the knowledge acquired dealing with it can be quite rewarding, in particular when dealing with open source projects.

That said, I'll give you another approach to make things work (at least try to).

First uninstall and clean the library (quote directory):
make clean
sudo make uninstall

Using eclipse CDT (there is some time I do not use it, but these instructions should work):
1. create a new managed project;
2. copy all source files from "quote/src" *except* "Makefile" into the project you had just created;
3. also copy "samples/csv_string/csv_string.cpp" to the project;
4. open you project settings;
5. add "-std=c++11" in miscellaneous compiler options (or something like that);
6. add the library "curl" in linker/libraries options;
7. add "/usr/local/lib", "/usr/lib/x86_64-linux-gnu", "/usr/lib" to the libraries path;
8. add "/usr/local/include" to the include path in general properties;
9. try to build the project.

I am not sure about the names of the menus, but that should give a good indication.

If things work (I hope so), modify the "csv_string.cpp" to do your own stuff.
Last edited on
As another suggestion, I would recommend using R (check out RStudio -

You can manipulate the csv files with ease and even get Yahoo! Finance data programmatically (see More importantly, it has tons of statistics and finance features (packages) that can make your life a lot easier, especially when doing a school/uni/academic projects.

As a last resort, we always have Excel. But IMHO I do not think that will widen your horizons too much.
closed account (zqMDizwU)
Ok thanks, I like r studio. I will read this over. For now I am trying it through windows, downloading libcurl through this method:
There is a long time I do not work with VS, so you are probably better on your own in that way.

To use quote. Just dump all the source files of "quote/src" in your VS project.
Last edited on
closed account (zqMDizwU)
It might not work because I opened an empty project, but I'll see. There is the option to open a Makefile project, but I will go through this and probably hit a bunch of errors, because the project you built is a Makefile project and I don't know how to do that on windows. There are probably a bunch of dos commands I will learn. So I will go through your steps, because the repository requires an external build.
You can ignore the makefile and just put quote source files in your project. Just make sure you set the IDE to link to libcurl.
closed account (zqMDizwU)
I got it to work holy ****

Thank you so much for having this thread and keeping me updated. Wow I am so happy. I will adjust it and try to run it on ubuntu when I really have nothing to do. But it worked on windows. I had to do a few things that arent mentioned, but through it all I am so happy I got it done.

Now I can change up the variables, see its capabilities and really have a roll with it. God I am happy that I have an API that works and maybe live too like you said. Thank you so much for posting this repository. I really needed this for my group project and I can do what I need to do with it.

I am thankful you commented on my post because you are the only one with the best answer.

Thank You!
You are welcome. I am glad it worked!
Topic archived. No new replies allowed.