def display_options(sym): tk = TradeKingAPI() fids = 'ask,bid,vol,strikeprice' # def market_options_search(self, symbol, query=None, fids=None): options_data = tk.market_options_search(symbol=sym, fids=fids) print('options url: ', options_data.url) return render_template('DisplayBTCData.html', btcdata=options_data.json())
def display_options_expirations(sym): tk = TradeKingAPI() # def market_options_expirations(self, symbol): options_expire = tk.market_options_expirations(sym) print('options_expire url: ', options_expire.url) return render_template('DisplayBTCData.html', btcdata=options_expire.json())
def display_quote(symb): print('symb: ', symb, flush=True) print('symb: ', escape(symb), flush=True) fids = 'last,bid,ask' tk = TradeKingAPI() ext_quotes_data = tk.market_ext_quotes(escape(symb), fids) quote_last = ext_quotes_data.json() print('response last: ', quote_last['response']['quotes']['quote']['last']) for keys, values in quote_last['response']['quotes']['quote'].items(): print('keys: ', keys) print('values: ', values) return render_template('DisplayBTCData.html', btcdata=ext_quotes_data.json())
def display_options_strikes(sym): tk = TradeKingAPI() # def market_options_strikes(self, symbol): options_strikes = tk.market_options_strikes(symbol=sym) strikes = options_strikes.json() print('strikes:', strikes) strikelist = strikes['response'] strikelist = strikelist['prices'] print('strikelist:', strikelist) print('options_strikes url: ', options_strikes.url, flush=True) print('options_strikes json: ', strikelist, flush=True) print('data type:', type(strikelist), flush=True) list_values = [v for v in strikelist.values()] list_values = [x for x in list_values] print('data type-list:', type(list_values), flush=True) print('list values: ', list_values, flush=True) for x in list_values: for y in x: print('y:', y) return render_template('DisplayBTCData.html', btcdata=strikelist)
def display_clock(): tk = TradeKingAPI() clock_data = tk.market_clock() return render_template('DisplayBTCData.html', btcdata=clock_data)
def display_data(): tk = TradeKingAPI() btc_data = tk.accounts() return render_template('DisplayBTCData.html', btcdata=btc_data)
def display_testdata(): tk = TradeKingAPI() btcdata = tk.accounts() return btcdata.json()