View Full Version : Get stock symbol price

04-19-2012, 11:13 PM

I'm looking to make my site a bit more dynamic with respect to its display. I have a section for which I share my trades. I'd like to have the real time price of the stock as well as the current p/l on each position display and calculate. Is this possible? the page that I'm looking to make more dynamic is http://stocksandstocks.com/index.php/emini-futures-trading-results/stock-trading-results.html As I said before I would like to have the p/l change automatically instead of me having to place open as the entry. Right now this is just a simple table, but I'd like to tackle this. Can anyone point me in the right direction or have an example for which I may preview to ge me started. I really only know html well and I'd have to learn so please keep that in mind.


04-19-2012, 11:48 PM
Real-time cannot actually be done in PHP at all (in the web world). Once its done with its request and delivered its response, there is no way to reuse the data. APC and sessions can be used to "remember" things though.
Semi-real time is certainly doable. I wouldn't even recommend pulling near real time data out either, although you could pull every say 5 - 30 seconds. Chances are you are using a service for this data, and if its soap the amount of data between the requests is actually pretty low.
To refresh, PHP can push a header for a Refresh meta. That is the only way PHP can do this in a web environment reliably; used to be you could flush buffered data, but since browsers tend to buffer nowadays, that doesn't really work like it used to.
AJAX, Flash or Java are what you want to use. All of these can be timed, can communicate with PHP (or straight to originating site), and can make updates appear seamless.

04-20-2012, 12:16 AM
Thanks for the quick reply! Yeah I wasn't real sure on which code I needed to approach it with. You understand what I mean though. I thought maybe data could be grabbed from yahoo which would probably be the easiest way to do this. I just have no idea how to do it. Is there a way for me to move this to the appropriate category in the forum that you know of? I don't want to re post a duplicate.

04-20-2012, 12:42 AM
I can move it to the JS forums.
More information would be better, how is this getting the data currently? That would likely be done from a server side language, although could be done from a client one (server side would let you log information as well, or compare, trend etc).

04-20-2012, 12:55 AM
I simply enter the data manually. I like the control of that. These picks are specific to the site thus I am okay with entering the data manually.

Edit: I'm not looking to make anything anymore complicated I simply want to have the ability for up to date p/l to show.