Created
August 25, 2017 20:50
-
-
Save rubcuadra/31d2c9d0ca5862d1755a355c6047f7c6 to your computer and use it in GitHub Desktop.
Simple getTicker for an specific book from bitso
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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