Post
Topic
Board Trading Discussion
Re: Help me brainstorm for Spend Bitcoins
by
kjj
on 09/08/2011, 00:06:18 UTC
It will be back up just as soon as I can code a proper exchange rate. 0.5% would not be enough to keep the 24-hour average as the exchange rate, but someone has PM'd me an excellent idea for the exchange rate--the lower of last price and the 24-hour average. That should stop the losses (on average anyway) as long as I automate trading. Does everyone reading this think that is a fair exchange rate (still with no added fees!)?

On a side note, I'm not a programmer. I'm having trouble grabbing the 'last' price from Mt Gox. Here is the current php that grabs the '24 hour weighted average' from bitcoincharts.com:

Quote
$string = file_get_contents("http://bitcoincharts.com/t/weighted_prices.json");
$json_a=json_decode($string,true);
echo $json_a['USD']['24h'];
?>

My site then just calls what this code echos whenever it needs the current BTC rate.

2 BTC bounty to whoever can rewrite this code (not give me hints on rewriting it myself, actually rewriting it, remember, I'm not a programmer Wink to echo the lower of the Mt Gox 24 hour weighted average and the Mt Gox last price.

Thanks for the help everyone (don't stop now, though, happy to hear any more ideas on making this profitable!).

If I were doing it, I would pull the market depth data directly from mtgox (and cache it for a few minutes so you don't have to read it again on every page load), and read the bids (in order from high to low) to find out how many bitcoins it was really going to cost you to cover the transaction.  If you don't know the amount in advance, like if you want to provide a quote up front, pick a number a bit higher than your typical order and use that, probably with a disclaimer that unusually large orders will need to be recalculated.

The reason I'd do it this way is because you don't really care about the last price, or the average price, you care about the price that you are going to get in a few minutes when you sell.  You still have some risk, which is unavoidable, but you can seek to minimize it.