Author

Topic: Storing price history on a site. MTgox alternitives to cron job (Read 1369 times)

member
Activity: 116
Merit: 11
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?


newbie
Activity: 46
Merit: 0
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.
newbie
Activity: 28
Merit: 0
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.
legendary
Activity: 1498
Merit: 1000
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.
member
Activity: 102
Merit: 10
 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?
Jump to: