2

我需要从返回的 json 数据中提取价格。我已经搜索和搜索。我只想要从 pprint 打印的价格。底部的 pprint 无论如何我都无法过滤它。不确定是否需要将其放入字典中。

{'ask': 16749.45,
 'average': None,
 'baseVolume': 16313.93360969,
 'bid': 16749.44,
 'change': None,
 'close': None,
 'datetime': '2017-12-14T23:53:43.476Z',
 'first': None,
 'high': None,
 'info': {'ask': '16749.45',
          'bid': '16749.44',
          '**price': '16749.44000000',**
          'size': '0.10000000',
          'time': '2017-12-14T23:53:43.476000Z',
          'trade_id': 28280124,
          'volume': '16313.93360969'},
 'last': None,
 'low': None,
 'open': None,
 'percentage': None,
 'quoteVolume': None,
 'symbol': 'BTC/USD',
 'timestamp': 1513295623476,
 'vwap': None}


import ccxt
import os
import datetime
from pprint import pprint
import json


#TOP LEVEL EXCHANGE 
gdax = ccxt.gdax()
bittrex = ccxt.bittrex()
bitfinex = ccxt.bitfinex()
kraken = ccxt.kraken()

#LOAD MARKETS - MUST BE LOADED BEFORE CALLING ANY DATA.
gdax.load_markets()
bittrex.load_markets()
bitfinex.load_markets()
kraken.load_markets()

#BTC/USD MARKET CALLS
BU_GDAX = gdax.markets['BTC/USD']
BU_BITF = bitfinex.markets['BTC/USD']
BU_KR = kraken.markets['BTC/USD']

#BTC/XRP MARKET CALLS



#BTC/LTC MARKET CALLS
BL_GDAX = gdax.markets['LTC/BTC']
BL_BITF = bitfinex.markets['LTC/BTC']
BL_KR = kraken.markets['LTC/BTC']



#FETCH TICKERS
pprint((gdax.fetch_ticker('BTC/USD'))
4

1 回答 1

1
  1. 更新到最新版本的 ccxt
  2. 像这样更改 pprint 行:pprint(gdax.fetch_ticker('BTC/USD')['last'])
于 2017-12-18T00:25:53.580 回答