Bitcoin Forum
May 04, 2024, 10:45:15 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Determining exchange rates for a merchant site  (Read 1391 times)
Cryptoman (OP)
Hero Member
*****
Offline Offline

Activity: 726
Merit: 500



View Profile
January 04, 2011, 05:03:14 PM
 #1

I was wondering if the community had thoughts on what is the best way to come up with BTC/USD, BTC/EUR, etc. exchange rates for pricing goods and services on a merchant site.  I wrote a little script to grab the LAST trade from MtGox:

Code:
#!/usr/bin/env ruby
require 'open-uri'
btc_per_usd = 0.0
quote_str = open('http://mtgox.com/code/data/ticker.php').read
quote_str = quote_str.gsub(/["{}]/,'')
quote_str = quote_str.gsub(/ticker:/, '')
quotes = quote_str.split(',')
#puts quotes
quotes.each {|q| btc_per_usd = q.delete('a-z:').to_f if q[/last:/] }
#puts btc_per_usd

There are several problems with doing it this way.  The last trade could have been unusually large or small in volume and not indicative of the true current exchange rate.  Also, it doesn't make sense to continually update the exchange rate in real time because the price in BTC of items could fluctuate during the order completion process.  I'm thinking that the rate should be set once per day from a cron job by taking some sort of average of the previous day's MtGox transactions.  Any ideas or scripts you'd like to share?


"A small body of determined spirits fired by an unquenchable faith in their mission can alter the course of history." --Gandhi
1714819515
Hero Member
*
Offline Offline

Posts: 1714819515

View Profile Personal Message (Offline)

Ignore
1714819515
Reply with quote  #2

1714819515
Report to moderator
1714819515
Hero Member
*
Offline Offline

Posts: 1714819515

View Profile Personal Message (Offline)

Ignore
1714819515
Reply with quote  #2

1714819515
Report to moderator
1714819515
Hero Member
*
Offline Offline

Posts: 1714819515

View Profile Personal Message (Offline)

Ignore
1714819515
Reply with quote  #2

1714819515
Report to moderator
According to NIST and ECRYPT II, the cryptographic algorithms used in Bitcoin are expected to be strong until at least 2030. (After that, it will not be too difficult to transition to different algorithms.)
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714819515
Hero Member
*
Offline Offline

Posts: 1714819515

View Profile Personal Message (Offline)

Ignore
1714819515
Reply with quote  #2

1714819515
Report to moderator
davout
Legendary
*
Offline Offline

Activity: 1372
Merit: 1007


1davout


View Profile WWW
January 04, 2011, 05:08:03 PM
 #2

And maybe other bitcoin exchanges for the matter  Angry
For example the ones that allow you to trade LRUSD/LREUR/EUR/BTC for free  Kiss

mndrix
Michael Hendricks
VIP
Sr. Member
*
Offline Offline

Activity: 447
Merit: 258


View Profile
January 04, 2011, 08:27:25 PM
 #3

I was wondering if the community had thoughts on what is the best way to come up with BTC/USD, BTC/EUR, etc. exchange rates for pricing goods and services on a merchant site.

My favorite is the 24 hour, volume-weighted price listed in the right column of http://www.taters.net/cgi-bin/btc/matrix.pl?axisinc=0.01
Anonymous
Guest

January 04, 2011, 08:51:14 PM
 #4

bitcoinwatch  Huh


http://bitcoinwatch.com/
Cryptoman (OP)
Hero Member
*****
Offline Offline

Activity: 726
Merit: 500



View Profile
January 04, 2011, 09:44:40 PM
 #5

My favorite is the 24 hour, volume-weighted price listed in the right column of http://www.taters.net/cgi-bin/btc/matrix.pl?axisinc=0.01

Great idea!  I've updated my script to calculate a 48-hour (MtGox recent trades) volume-weighted price.  I would do a 24-hour volume-weighted price if I weren't too lazy to deal with the date arithmetic.  Cheesy

Code:
#!/usr/bin/env ruby
require 'open-uri'
require 'json'
total_vol = 0.0
price_vol_product = 0.0
quote_str = open('http://mtgox.com/code/data/getTrades.php').read
quotes = JSON.parse(quote_str)
#puts quotes
quotes.each do |q|
   price_vol_product += q["price"] * q["amount"]
   total_vol += q["amount"]
end
usd_per_btc = price_vol_product/total_vol
#puts usd_per_btc


And maybe other bitcoin exchanges for the matter  Angry
For example the ones that allow you to trade LRUSD/LREUR/EUR/BTC for free  Kiss

...and the trade data APIs for these other sites can be found...where?  Tongue

"A small body of determined spirits fired by an unquenchable faith in their mission can alter the course of history." --Gandhi
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!