Skip to content

Instantly share code, notes, and snippets.

@rubcuadra
Created August 25, 2017 20:50
Show Gist options
  • Save rubcuadra/31d2c9d0ca5862d1755a355c6047f7c6 to your computer and use it in GitHub Desktop.
Save rubcuadra/31d2c9d0ca5862d1755a355c6047f7c6 to your computer and use it in GitHub Desktop.
Simple getTicker for an specific book from bitso
from requests import get
class Bitso(object):
"""Bitso"""
def __init__(self, version='v3'):
super(Bitso, self).__init__()
self.api = 'https://api.bitso.com/%s'%version
'''
Valid books: btc_mxn, eth_mxn, xrp_btc, xrp_mxn, eth_btc, bch_btc
'''
def getTicker(self, book=None):
r = get('%s/ticker/'%self.api).json()
if book:
for b in r['payload']:
if book == b['book']:
return b
raise Exception("Wrong book %s"%book)
return r
#Costo de un book
def getLast(self,book):
return self.getTicker(book)['last']
bitso = Bitso()
print bitso.getLast('eth_mxn')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment