bitcoin-client
bitcoin client library for price ticker and wallet
git clone https://9o.is/git/bitcoin-client.git
BitStamp.scala
(1140B)
1 package inc.pyc.bitcoin
2 package provider
3
4 import dispatch._
5 import akka.actor._
6 import net.liftweb.json._
7 import inc.pyc.bitcoin.HttpExchange
8
9 /**
10 * BitStamp REST services
11 */
12 class BitStamp
13 extends Actor
14 with ActorLogging
15 with HttpExchange {
16
17 import BitStamp._
18
19 implicit val formats = DefaultFormats
20
21 def receive = priceTicker
22
23 protected val api = :/ ("www.bitstamp.net").secure / "api"
24
25 protected val ticker_api = api / "ticker" / ""
26
27 protected def buyPrice: String = {
28 (request(ticker_api).extract[BitStampPrices]).last
29 }
30 }
31
32 object BitStamp {
33 /**
34 * Different prices returned by BitStamp's API.
35 *
36 * Note: Currently not configurable. 'last' is default.
37 *
38 * last - last BTC price (BitStamp's Current Price)
39 * high - last 24 hours price high
40 * low - last 24 hours price low
41 * vwap - last 24 hours volume weighted average price
42 * volume - last 24 hours volume
43 * bid - highest buy order
44 * ask - lowest sell order
45 */
46 case class BitStampPrices(
47 last: String, high: String, low: String, vwap: String, volume: String,
48 bid: String, ask: String, timestamp: String)
49 }