Bitcoin Forum
April 26, 2024, 04:00:00 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How do I store ticker data?  (Read 767 times)
rier (OP)
Newbie
*
Offline Offline

Activity: 2
Merit: 0


View Profile
August 08, 2011, 12:03:05 PM
Last edit: August 08, 2011, 12:14:57 PM by rier
 #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?
1714104000
Hero Member
*
Offline Offline

Posts: 1714104000

View Profile Personal Message (Offline)

Ignore
1714104000
Reply with quote  #2

1714104000
Report to moderator
1714104000
Hero Member
*
Offline Offline

Posts: 1714104000

View Profile Personal Message (Offline)

Ignore
1714104000
Reply with quote  #2

1714104000
Report to moderator
There are several different types of Bitcoin clients. The most secure are full nodes like Bitcoin Core, but full nodes are more resource-heavy, and they must do a lengthy initial syncing process. As a result, lightweight clients with somewhat less security are commonly used.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714104000
Hero Member
*
Offline Offline

Posts: 1714104000

View Profile Personal Message (Offline)

Ignore
1714104000
Reply with quote  #2

1714104000
Report to moderator
1714104000
Hero Member
*
Offline Offline

Posts: 1714104000

View Profile Personal Message (Offline)

Ignore
1714104000
Reply with quote  #2

1714104000
Report to moderator
1714104000
Hero Member
*
Offline Offline

Posts: 1714104000

View Profile Personal Message (Offline)

Ignore
1714104000
Reply with quote  #2

1714104000
Report to moderator
cubemonkey
Newbie
*
Offline Offline

Activity: 11
Merit: 0


View Profile
August 08, 2011, 05: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








kseistrup
Hero Member
*****
Offline Offline

Activity: 566
Merit: 500


Unselfish actions pay back better


View Profile WWW
August 08, 2011, 06: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,

Klaus Alexander Seistrup
Cellcote
Newbie
*
Offline Offline

Activity: 22
Merit: 0


View Profile
August 08, 2011, 09:42:42 PM
 #4

every 2 seconds

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

Activity: 11
Merit: 0


View Profile
August 09, 2011, 02:46:44 AM
 #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.
jboss
Newbie
*
Offline Offline

Activity: 27
Merit: 0


View Profile
August 09, 2011, 04:18:21 AM
 #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.
kseistrup
Hero Member
*****
Offline Offline

Activity: 566
Merit: 500


Unselfish actions pay back better


View Profile WWW
August 09, 2011, 05: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,

Klaus Alexander Seistrup
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!