Get stock prices for a project

LoloWilou69 Posted messages 15 Status Membre -  
 Malti Z F -
Hello,

I am looking for a web service, API, etc. to retrieve stock market quotes (from Paris) almost instantly (I know that to get quotes for free, there is a 20-minute delay).

I will use them for a JAVA or C# application. I need the stock market quote and individual stock quotes.

I saw that it might be possible to do this via a Yahoo Finance API, but I did not fully understand how it works. If you at least know of a tutorial, I would appreciate it.

One solution could be to load an HTML page from Boursorama or Euronext... and retrieve the information I am interested in from it, but I find this solution a bit "dirty" because if one of those sites changes its page format, I would no longer be able to retrieve the data. Also, I am not sure if I am allowed to extract this information without the site’s permission.

If you have any ideas, I am all ears.

Thank you in advance
Configuration: Windows XP Firefox 3.0.5

9 réponses

castorix
 
It is enough to read the streams (ajax generally now)
I created a real-time software (in C), covering all of Euronext and the US (> 10,000 stocks analyzed)
which allows me to detect a stock that starts to rise ... and to position myself on it to exit in ID (Swing trading)

This is the software of my life (~ 1 year of development), I live off this now :-)
(and my income is significantly > than my previous job, which was as an IT consultant in banking...)
30
Zarma
 
Hello Castorix.

Can you explain how you did it?
I would like to do the same thing.

Thank you
0
Castorix
 
I read the feeds in text mode from Google Finance for the US and L'echo.be for Euronext

For example, for the feed of stocks in Compartment A on Paris:
http://1.ajax.lecho.be/rtq/?reqtype=simple"es=360015511&lightquotes=&group=g2101_q_p

All that's left is to parse and match ID :<=>Title (e.g., 360115890 = Faurecia)
which I will do only once during installation by parsing the HTML of
https://www.lecho.be/les-marches/bourses/euronext-paris/frencha.html
for Comp. A, for example.
0
heyquem Posted messages 808 Status Membre 131
 
No, really?!

Are the courses on Google Finance and L'echo.be instant courses? Because if this condition is not met, I don't see how a computer program could produce usable results, knowing that now a very large part of stock trading is carried out automatically by robots, computer programs like yours but much more sophisticated that react at very high speeds.

Are the feeds you are talking about RSS feeds?
0
Castorix
 
Yes, it’s real-time on Google Finance for NYSE/NASDAQ
and on Echo.be for Euronext, except for Alternext (Same as Zonebourse.com)
or through my broker Binck Bank)

I’m obviously aware of HFT (High Frequency Trading), which doesn't concern me since I don't need to place x orders per second!
The purpose of my software is to detect any sudden increase on over 10,000 titles, impossible for a human, to position myself on it before others and to exit after +n%
So far, it works almost perfectly (the key is not to be too greedy with the gain percentage and to exit on time, as the price can drop during the day, of course)
(+1% on 30-40 K€ is enough for me, for example, but I need +7 to 8% in ID if I only put in 5, which is rare on Euronext but common on Nasdaq)

I manage to make several passes per second on each title using multi-threading, which is more than sufficient.
0
Machina92
 
Good evening castorix
How often do you parse the streams?

Do you also have access to derivatives like warrants, trackers, etc. live?
Thank you
0
Edouard
 
Hi,
I don't know which OS you're using, but you can find a bash script (for Linux and Mac) that fetches stock prices in real-time from Boursorama.
http://www.ensta.fr/~garnier/bourse.html

Even if you’re not on Linux, you can look through the code to see.

Let me know if you have any questions or if there's anything you don't understand,
talk to you later.
6
Castorix
 
I don't know PHP, but a quick search on Google shows that there are parsing functions or JSON, like
http://php.net/manual/en/function.json-decode.php
and many sites provide examples,
http://webhole.net/2009/08/31/how-to-read-json-data-with-php/
etc...
4
Empact
 
Indeed, I didn't know about 'json' at all, which will allow me to easily retrieve the data once I've managed to get the line.
Because curl is currently only returning an empty variable for a reason I don't know.
But if you don't know PHP, I won't take advantage of your patience.

Thank you for your responses and good luck.
0
jocqfd
 
Thank you for this information. I'm looking for a feed to retrieve the CAC40 (and maybe the values that compose it... I believe that in your request, it's the quotes= parameter that gives the value we want to track. Where can we find the other values?
0
Castorix
 
But this example query returns the CAC40 precisely...
360097430 = CAP, 360017056 = ML (Michelin), etc...
0
didier
 
Hi Castorix

How do you know what these codes correspond to:
es=360015511

Can we do it individually for an action?


Have a good day
0
Castorix
 
I use tools like Httpwatch to trace all HTTP requests.
0
alaclef Posted messages 19 Status Membre 1
 
Okay, thanks
I didn't understand because I thought it was the CAC!
Does anyone have a table of stock and index codes??

Thanks in advance
1
stick-man
 
I’m following up to see if you have found the solution.
0
tri_tri Posted messages 1 Status Membre
 
Salut castorix, could you send me your info privately about programming automatic stock orders on Binck Bank? I can't find the documentation and I’m with another broker, thanks.
0
Joker
 
Hello,

Where do you find the average volumes to be loaded over 15 days?

Even if you have to "parse" them, I'm interested!

Thank you!
0
Castorix
 
Among others on Google Finance
For example for BNP:
http://www.google.com/finance/getprices?q=BNP&x=EPA&p=15d&i=86400
0
cyka Posted messages 4 Status Membre
 
Hello Castorix,

Thank you for your code. Do you know if we can retrieve only the basic information, in one line? I used to get this code from Yahoo Finance but it no longer works.
The most important thing is that I want to retrieve the quotes for commodities: Gold, Silver, etc.
My site kestellikian.fr, now all the values are at zero, I had to set the values to 1 to avoid a division by zero.

Thank you for your help, my email: c.kestellikian@live.fr
0
Castorix
 
For raw materials, I get them from:
www.forexpros.fr/commodities/futures
(I parse the HTML, not great, but it’s enough for this part)
0
cyka Posted messages 4 Status Membre
 
Can you give me the example for the OR, I'll manage the rest.

Thank you very much.
0
Empact
 
Hello castorix,

I just read the post and I'm very interested in your URL.

http://1.ajax.lecho.be/rtq/?reqtype=simple&quotes=360015511&lightquotes=&group=g30_q_p

I tested it in my browser and the values I'm looking for are there.
The problem is that I completely don't know how to handle this information.
Ajax is not my strong suit.

I'm working on an HTML PHP page that needs to display the information. Can you give me a code compatible with both languages that would allow me to handle this request?

Thanks in advance
0
Castorix
 
No need to know Ajax, since it's just a text output
I just parsed it in C, cutting each line by searching for "}" for example as a title separator.
0
Empact
 
Thank you for your response, I will try that.
0
Empact
 
Well, I'm still struggling.
I tried to retrieve the line of text returned to me using
 <?php file_get_contents('URL'); ?> 

but this line causes my browser to spin endlessly.

So I tried with curl.
I tested with different sites like Google and it works, but when testing with the URL http://1.ajax.lecho.... nothing happens.
If you have any ideas

 <?php function get_contenu($url) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_FRESH_CONNECT, true); curl_setopt($ch, CURLOPT_TIMEOUT, 3); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $contenu = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($httpCode < 400 && $httpCode >= 300) { return FALSE; } else { return $contenu; } } $site = get_contenu('http://1.ajax.lecho.be/rtq/?reqtype=simple&%20quotes=360015511&lightquotes=&group=g30_q_p'); echo $site; ?> 
0
alaclef Posted messages 19 Status Membre 1
 
Hello everyone

interesting post ....
has anyone managed to analyze the ajax flow on lecho.be?
it seems to be the CAC 40 but the data does not match.
0
Castorix
 
Well, if that corresponds:
If we take the first one for example,
"360097430":{"open":"31.4450","time":"23/11","pct":"0.1434","last":"31.4250","volume":503068,"high":"31.4600","ask":"0.0000","low":"31.0200","bid":"0.0000","prev":"31.3800"
These are indeed the data for CAP:
http://www.lecho.be/bourses/Cap_Gemini.360097430
0
alaclef Posted messages 19 Status Membre 1
 
Ok, it's all the actions of the CAC
but how to recover a stock (e.g. Google) or an index (e.g. CAC or NYSE)
thank you for your help
0
Castorix
 
The CAC itself is inside, code 360015511
Otherwise, just the CAC, http://1.ajax.lecho.be/rtq/?reqtype=simple"es=360015511
(remove the space before quotes)
But we don't have the volume, which we easily get with the first request by adding up all the volumes.


Google, it's http://1.ajax.lecho.be/rtq/?reqtype=simple"es=350186927
But for NYSE/NASDAQ, I prefer to use Google feeds, more real-time
http://www.google.com/finance/info?infotype=infoquoteall&q=NASDAQ:GOOG
0
alaclef Posted messages 19 Status Membre 1
 
Great!!
Thank you very much

Do you know the syntax for currency pairs, e.g. EUR/USD
In Google visual it’s EURUSD but I can't seem to retrieve this feed
Same question for commodities

Thanks for your help
0
scaface38
 
Good evening
I’ve got the CAC 40 in a table
now I just need to update it. Is 5 seconds a good compromise?

Otherwise, are the prices in real-time?

Have a nice evening
0
Castorix
 
For Euro/USD, the latest value is usually on the last line of:
http://www.google.com/finance/getprices?q=EURUSD&x=CURRENCY&i=60&p=1d
0
alaclef Posted messages 19 Status Membre 1
 
grandiose!!
do you have a Google link on raw materials not miracle?
that would be so cool
I don't know this forum very well: can we send a PM?
thank you again for your help
0