In [1]:
#this is Just a demo to create content from pynb notebooks
import requests
import json
import toolz
In [2]:
cexio_ticker_url = "https://cex.io/api/tickers/USD/btc"
coinome_ticker_url = "https://www.coinome.com/api/v1/ticker.json"
In [3]:
cex_ticker_data = requests.get(cexio_ticker_url)
coinome_ticker_data = requests.get(coinome_ticker_url)
In [28]:
coinome_ticker_data.content
Out[28]:
b'{"btc-inr":{"last":"680001.02","lowest_ask":"695000.0","highest_bid":"680001.01","24hr_volume":null},"bch-inr":{"last":"83512.00","lowest_ask":"87499.0","highest_bid":"83511.0","24hr_volume":null},"ltc-inr":{"last":"13700.00","lowest_ask":"13849.0","highest_bid":"13700.0","24hr_volume":null},"dash-inr":{"last":"42003.00","lowest_ask":"43999.0","highest_bid":"41101.0","24hr_volume":null},"dgb-inr":{"last":"2.43","lowest_ask":"2.43","highest_bid":"2.4","24hr_volume":null},"zec-inr":{"last":"27300.00","lowest_ask":"27800.0","highest_bid":"27260.0","24hr_volume":null}}'
In [66]:
cex_parsed
Out[66]:
{'data': [{'ask': 10127.8,
   'bid': 10109.3,
   'high': '11124.5',
   'last': '10137.5',
   'low': '9901',
   'pair': 'BTC:USD',
   'timestamp': '1519313248',
   'volume': '2504.17187113',
   'volume30d': '72962.46039408'},
  {'ask': 819,
   'bid': 818.05,
   'high': '890',
   'last': '819',
   'low': '801.52',
   'pair': 'ETH:USD',
   'timestamp': '1519313248',
   'volume': '3833.35548000',
   'volume30d': '213129.53190600'},
  {'ask': 1225.53,
   'bid': 1212.44,
   'high': '1369.74',
   'last': '1225.53',
   'low': '1200',
   'pair': 'BCH:USD',
   'timestamp': '1519313248',
   'volume': '418.47464531',
   'volume30d': '16579.74607431'},
  {'ask': 110.97,
   'bid': 110,
   'high': '126.49',
   'last': '110.01',
   'low': '108',
   'pair': 'BTG:USD',
   'timestamp': '1519313248',
   'volume': '1227.81558748',
   'volume30d': '46625.61778342'},
  {'ask': 619.73,
   'bid': 607.01,
   'high': '696.67',
   'last': '606.46',
   'low': '606.4',
   'pair': 'DASH:USD',
   'timestamp': '1519313248',
   'volume': '73.55899353',
   'volume30d': '5829.68044298'},
  {'ask': 0.905,
   'bid': 0.9039,
   'high': '1.0298',
   'last': '0.905',
   'low': '0.88',
   'pair': 'XRP:USD',
   'timestamp': '1519313248',
   'volume': '3716680.987245',
   'volume30d': '175576027.187890'},
  {'ask': 0.3616,
   'bid': 0.3571,
   'high': '0.4068',
   'last': '0.3608',
   'low': '0.3451',
   'pair': 'XLM:USD',
   'timestamp': '1519313248',
   'volume': '2013025.0214051',
   'volume30d': '56213922.7989869'},
  {'ask': 402,
   'bid': 397.98,
   'high': '449.36',
   'last': '401.9',
   'low': '395.18',
   'pair': 'ZEC:USD',
   'timestamp': '1519313248',
   'volume': '300.06466229',
   'volume30d': '16931.48374972'}],
 'e': 'tickers',
 'ok': 'ok'}
In [5]:
cex_parsed = json.loads(cex_ticker_data.content)
In [6]:
cex_parsed.keys()
Out[6]:
dict_keys(['e', 'ok', 'data'])
In [7]:
coinome_parsed = json.loads(coinome_ticker_data.content)
In [68]:
coinome_parsed.keys()
Out[68]:
dict_keys(['btc-inr', 'bch-inr', 'ltc-inr', 'dash-inr', 'dgb-inr', 'zec-inr'])
In [74]:
coinome_parsed
Out[74]:
{'bch-inr': {'24hr_volume': None,
  'highest_bid': '83511.0',
  'last': '83512.00',
  'lowest_ask': '87499.0'},
 'btc-inr': {'24hr_volume': None,
  'highest_bid': '680001.01',
  'last': '680001.02',
  'lowest_ask': '695000.0'},
 'dash-inr': {'24hr_volume': None,
  'highest_bid': '41101.0',
  'last': '42003.00',
  'lowest_ask': '43999.0'},
 'dgb-inr': {'24hr_volume': None,
  'highest_bid': '2.4',
  'last': '2.43',
  'lowest_ask': '2.43'},
 'ltc-inr': {'24hr_volume': None,
  'highest_bid': '13700.0',
  'last': '13700.00',
  'lowest_ask': '13849.0'},
 'zec-inr': {'24hr_volume': None,
  'highest_bid': '27260.0',
  'last': '27300.00',
  'lowest_ask': '27800.0'}}
In [73]:
list(keys)
Out[73]:
['btc-inr', 'bch-inr', 'ltc-inr', 'dash-inr', 'dgb-inr', 'zec-inr']
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [23]:
a = map( lambda x:  (x['pair'], x['last']),cex_parsed['data'])
In [10]:
b = [map(lambda x: x['pair'], cex_parsed['data'])]
In [64]:
c = list(a)
In [65]:
c
Out[65]:
[]
In [32]:
d=[]
for x in coinome_parsed.keys():
    d.append((x, coinome_parsed[x]['last']))
In [33]:
d
Out[33]:
[('btc-inr', '680001.02'),
 ('bch-inr', '83512.00'),
 ('ltc-inr', '13700.00'),
 ('dash-inr', '42003.00'),
 ('dgb-inr', '2.43'),
 ('zec-inr', '27300.00')]
In [34]:
c
Out[34]:
[('BTC:USD', '10137.5'),
 ('ETH:USD', '819'),
 ('BCH:USD', '1225.53'),
 ('BTG:USD', '110.01'),
 ('DASH:USD', '606.46'),
 ('XRP:USD', '0.905'),
 ('XLM:USD', '0.3608'),
 ('ZEC:USD', '401.9')]
In [46]:
p = set(map(lambda x : x[0].split("-")[0].upper(), d))
In [47]:
q = set(map(lambda x : x[0].split(":")[0], c))
In [48]:
p
Out[48]:
{'BCH', 'BTC', 'DASH', 'DGB', 'LTC', 'ZEC'}
In [49]:
q
Out[49]:
{'BCH', 'BTC', 'BTG', 'DASH', 'ETH', 'XLM', 'XRP', 'ZEC'}
In [59]:
r = list(p.intersection(q))
In [75]:
r
Out[75]:
['ZEC', 'BTC', 'BCH', 'DASH']
In [62]:
import pandas as pd
In [57]:
 
--------------------------------------------------------------------------
ValueError                               Traceback (most recent call last)
<ipython-input-57-e4373cacf837> in <module>()
----> 1 z.update(("a","b"))

ValueError: dictionary update sequence element #0 has length 1; 2 is required
In [ ]: