Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 36 lines (29 sloc) 0.939 kB
8a0cef6 @nelhage Add bitcoin zephyr notifier
authored
1 import urllib2
2 import simplejson
3 import yaml
4 import zephyr
5 import traceback
6
7 # URL = 'https://mtgox.com/code/data/ticker.php'
8
9 tickers = [('tradehill', 'https://api.tradehill.com/APIv1/USD/Ticker'),
10 ('mtgox', 'https://mtgox.com/code/data/ticker.php')]
11
12 zephyr.init()
13 for (instance, URL) in tickers:
14 try:
15 data = simplejson.loads(urllib2.urlopen(URL).read())
16 ticker = dict((k,float(v)) for (k,v) in data['ticker'].items()
17 if k != 'last_when')
18
19 display = """\
20 last: %(last).2f / buy: %(buy).2f / sell: %(sell).2f
21 low: %(low).2f / high: %(high).2f
22 volume: %(vol)s""" % ticker
23
24 z = zephyr.ZNotice()
25
26 z.cls = 'bitcoin'
27 z.instance = instance
28 z.opcode = 'auto'
29 z.fields = ['Bitcoin Market Zephyr gateway',
30 display]
31 z.auth = False
32 z.sender = 'bitcoin'
33 z.send()
34 except:
35 traceback.print_exc()
Something went wrong with that request. Please try again.