Bitcoin Forum
May 09, 2024, 03:17:21 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Storing price history on a site. MTgox alternitives to cron job  (Read 1343 times)
WorldOfBitcoin (OP)
Member
**
Offline Offline

Activity: 102
Merit: 10



View Profile
October 11, 2012, 05:30:39 AM
 #1

 I am building a site where I need to store bitcoin USD trade prices in a set time intervals into a SQL database. So I have a database I can throw transactions against and get trading price at the time of Transaction.  I think I could do this with a php script to returns MTgox last price but the finest time intervals a Cron Job is hourly.

I read in some other forms you could just have a php script run on an infinite loop with a sleep 5 second.  But I don’t like the sound of that would it really be 24/7? Dont really want to doxx MTgox. If it ever stopped would I need to start it back up? I need something extremely dependable and as close to real time pricing is preferred. What kind of options are out there?

This sounds to me like something a web socket would be for. Is it possible to connect to MTgox’s websocket 24/7 and store data in this in this fashion?
1715224641
Hero Member
*
Offline Offline

Posts: 1715224641

View Profile Personal Message (Offline)

Ignore
1715224641
Reply with quote  #2

1715224641
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715224641
Hero Member
*
Offline Offline

Posts: 1715224641

View Profile Personal Message (Offline)

Ignore
1715224641
Reply with quote  #2

1715224641
Report to moderator
gweedo
Legendary
*
Offline Offline

Activity: 1498
Merit: 1000


View Profile
October 11, 2012, 06:06:51 AM
 #2

Yes it is possible, I would write a python script or a java application that just takes the web socket stream and add it to your database.
exotime
Newbie
*
Offline Offline

Activity: 28
Merit: 0


View Profile
October 19, 2012, 12:18:45 PM
 #3

You may wish to ask MtGox nicely if they have an API feed somewhere. If you started hitting their website every five seconds for a scripting purpose, and they find out, I doubt they'll be terribly happy. Bandwidth isn't cheap, if their sysadmin is decent he'll just block your IP.
Girhes
Newbie
*
Offline Offline

Activity: 46
Merit: 0


View Profile
October 19, 2012, 06:38:02 PM
 #4

Cron jobs could be run every minute actually. I you want a better resolution you can make a client in any language that polls the API every 10-15 seconds, and use a simple cron script to make sure it is running.
BitcoinRate.com
Member
**
Offline Offline

Activity: 116
Merit: 11



View Profile WWW
October 19, 2012, 11:03:58 PM
 #5

You want to get the price of the latest trade, or the most recent best bid and best ask?

If the former, check out this script written in Python that uses the HTTP Rest API and a sqlite database (you could replace that of course). Also note the 10 second delay that is built in between requests.

http://cahier2.ww7.be/bitcoinmirror/phantomcircuit/mtgox.py

It should give you an idea on how to implement this (if you want the most recent best bid ans ask you could change some things like the url to be called and the handling of the json).

You could start this script of with a cronjob, and to be sure it keeps running do a restart hourly through a cronjob.

Does this help you?



★ Get +16GB extra on your Dropbox: https://bitcointalk.org/index.php?topic=142163.0
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!