def get_spot_price(self, symbol):
        """Returns a dictionary of data about the spot price,
        which includes bid, ask, bid size, ask size, as well as some api identification"""

        stock1 = Stock.fetch(self.client, symbol)
        stock = StockMarketdata.quote_by_instrument(self.client,
                                                    _id=stock1['id'])

        return stock
Exemplo n.º 2
0
symbol = "AAPL"
md = StockMarketdata.quote_by_symbol(client, symbol)
print_symbol_price(md)

#
# fetch by multiple stock symbols
#
symbols = ['AAPL', 'MU', 'FB']
mds = StockMarketdata.quote_by_symbols(client, symbols)
for md in mds:
    print_symbol_price(md)

#
# fetch by single 'instrument_id'
#
symbol = 'AAPL'
md = StockMarketdata.quote_by_symbol(client, symbol)
instrument_id = md['instrument'].split('/')[4]
md = StockMarketdata.quote_by_instrument(client, instrument_id)
print_symbol_price(md)

#
# fetch by multiple 'instrument_id's
#
symbols = ['AAPL', 'MU', 'FB']
mds = StockMarketdata.quote_by_symbols(client, symbols)
instrument_ids = [md['instrument'].split('/')[4] for md in mds]
mds = StockMarketdata.quote_by_instruments(client, instrument_ids)
for md in mds:
    print_symbol_price(md)