Author

Topic: How do I store ticker data? (Read 786 times)

hero member
Activity: 566
Merit: 500
Unselfish actions pay back better
August 09, 2011, 12:41:58 AM
#7

bitcoincharts streams it..  you save the stream to your local machine, then access that every 2 seconds.

The data from bitcoincharts are up to a couple of minutes delayed, whereas those from the Mt Gox websocket stream are generally only a couple of seconds old.  There is no point in using the telnet stream from bitcoincharts unless one wants data from other exchanges than from Mt Gox, and even in that case it'll make more sense to use the websocket stream to obtain data from Mt Gox.

By saying that he wants to poll Mt Gox every 2 seconds, the OP has implicitly said that he wants the data as soon as possible.  The websocket API, by pushing data as soon as they're available, obsoletes expensive polling.

Cheers,
newbie
Activity: 27
Merit: 0
August 08, 2011, 11:18:21 PM
#6
The volume on mt gox is small compared to say nyse, you probalby don't even need to query every 2 minutes...

I wrote a small perl backend to show these charts. (I couldn't find a chart site that let me view by date).

http://bitcoin.coprimeinc.com/

I'm still experimenting with it. The perl backend took me about 10 minutes to write - which grabs the trade data off mt gox and dumps it into mysql.

PM me if you want more details.
newbie
Activity: 11
Merit: 0
August 08, 2011, 09:46:44 PM
#5
every 2 seconds

As I recall correctly, MT Gox only allow you to acces their API once per 15 minutes.

bitcoincharts streams it..  you save the stream to your local machine, then access that every 2 seconds.
newbie
Activity: 22
Merit: 0
August 08, 2011, 04:42:42 PM
#4
every 2 seconds

As I recall correctly, MT Gox only allow you to acces their API once per 15 minutes.
hero member
Activity: 566
Merit: 500
Unselfish actions pay back better
August 08, 2011, 01:41:43 PM
#3

Or should I use the websocket feed?

You would save both your own and mtgox' resources by using the websocket feed.

Cheers,
newbie
Activity: 11
Merit: 0
August 08, 2011, 12:29:41 PM
#2
You could try:

Code:
nohup  nc bitcoincharts.com 27007 |awk '/mtgoxUSD/ {gsub(/,/,"");p = $4+0;v = $6+0;print $2" "p" "v}' >>/tmp/stream.out &

Output in stream.out will look like:

Code:
1312824328 7.67 0.64291525
1312824328 7.667 3.5
1312824328 7.66051 7
1312824328 7.66 41.65206919
1312824328 7.65766 10.03
1312824329 7.65755 0.08
1312824329 7.65 20
1312824329 7.65 5
1312824329 7.65 2
1312824329 7.65 16.3761626

(trade time in epoch, value in USD, and volume)

Then something like (pardon my rusty mysql, but just showing the general idea... )

Code:
while true
do
   # take a snapshot
   tail -1 stream.out > /tmp/stream.out.tmp
   TIME=$(cat /tmp/stream.out.tmp |awk '{print $1}')
   TRADE=$(cat /tmp/stream.out.tmp |awk '{print $2}')
   QTY=$(cat /tmp/stream.out.tmp |awk '{print $3}'  
   mysqlupdate=`(mysql -u user -p password -e "INSERT INTO blah.blah VALUES ($TIME,$TRADE,$QTY)") 2>&1`
   sleep 2
done








newbie
Activity: 2
Merit: 0
August 08, 2011, 07:03:05 AM
#1
I'm writing a bot, I was thinking about querying Mt. Gox's api every 2 seconds and store the ticker data in a MySQL database.

Is this the best way to do this? I need to run some algorithms to determine enter an exit signals for the automated bot.

Or should I use the websocket feed?
Jump to: