In pursuit of an easy to use framework for using, exchanging, etc., BBR, I've taken a little detour and started adding Poloniex support to my Go exchange API package:
https://bitbucket.org/dave_andersen/exchangeThe only thing done at this point is retrieving the orderbook, but the rest should follow tomorrow. Putting these together, you can now script something that shows you the estimated value of your wallet in BTC, etc.
package main
import (
"bitbucket.org/dave_andersen/exchange/poloniex"
"fmt"
)
func main() {
err, ob := poloniex.GetOrderBook("BBR", "BTC")
if err != nil {
fmt.Println("Error: ", err)
} else {
fmt.Println("Top two bids for BBR/BTC on Poloniex:")
fmt.Printf("%.2f @ %.8f\n", ob.Bids[0].Quantity, ob.Bids[0].Price)
fmt.Printf("%.2f @ %.8f\n", ob.Bids[1].Quantity, ob.Bids[1].Price)
}
}
(This is BBR-relevant because of the dominance of Poloniex as an exchange for Boolberry).
Next step will complete support for automated management of BBR from wallet, to exchange, and back. Kinda neat.
Where I'm headed with all of this is trying to make it easy to receive payments in BBR and convert them to BTC in an automated fashion for people who wish to be able to accept anonymous payments, but don't necessarily want to hold on to it.
Tiny Go bindings update - some small performance improvements, and a new demo program that's a reasonable basis for simple blockchain analytics (blockinfo/blockinfo.go)
https://github.com/dave-andersen/gobbrAt this point, it could be used to write simple programs to calculate the block reward and difficulty and emit profitability, etc. I don't have exchange bindings for Poloniex or Mintpal, but if you had a favorite library to talk to them, it should be straightforward to build a mining profitability calculator.
For example, to calculate the trailing 24h block reward, you might write something like (without error checking):
d := gobbr.NewDaemon(DAEMON_ADDRESS)
height, _ := d.GetHeight()
reward := uint64(0)
nonOrphans := 0
for i := (height-720); i < height; i++ {
bh, _ := d.GetBlockHeaderByHeight(i)
if !bh.OrphanStatus {
nonOrphans++
reward += bh.Reward
}
}
fmt.Printf("Average 24 hour reward: %.2f\n", float64(reward)/(nonOrphans * gobbr.Multiplier))
There is a more complete example of that code in
https://github.com/dave-andersen/gobbr/blob/master/blockinfo/blockinfo.go(As a warning, it takes about 30 seconds to run - at least, while also mining on all cores).
Probably still only of interest to me as I try to get it up to speed for some other hacking, but if anyone would like to use it or thinks it would be perfect for them if only it did one thing, please let me know.
