Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Apr 2012
    Posts
    34
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Get stock symbol price

    Hello

    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...g-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.

    Thanks
    Chris

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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.

  • #3
    New Coder
    Join Date
    Apr 2012
    Posts
    34
    Thanks
    11
    Thanked 0 Times in 0 Posts
    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.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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).

  • #5
    New Coder
    Join Date
    Apr 2012
    Posts
    34
    Thanks
    11
    Thanked 0 Times in 0 Posts
    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.
    Last edited by ChrisTrader; 04-20-2012 at 04:17 AM. Reason: Clarification


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •