def test_quote(self, mock_rtie): from tdameritrade import TDClient tdc = TDClient(clientId=123, refreshToken='reftoken', accountIds=[1, 2]) with patch('requests.get') as m: m.return_value.status_code = 200 m.return_value.json.return_value = {'aapl': {'test': 1, 'test2': 2}} tdc.quote('aapl') tdc.quoteDF('aapl')
def test_quote(self): from tdameritrade import TDClient tdc = TDClient('test', [1, 2]) with patch('requests.get') as m: m.return_value.status_code = 200 m.return_value.json.return_value = { 'aapl': { 'test': 1, 'test2': 2 } } tdc.quote('aapl') tdc.quoteDF('aapl')
async def get_and_save_quotes(client: tdameritrade.TDClient, quotes, start_time: float, time_sec: int) -> None: """ Get the quotes and then save them to DB. """ try: active_pulse.inc() quotes = client.quote(QUOTE_SYMBOLS) await write_quotes_to_db(quotes, start_time, time_sec) except Exception as error: logger.error("Unable to get quote data for symbols: {}".format(error)) tda_quotes_error.inc()
print(response) c = TDClient(response['access_token']) c.accounts() #access_Trade(html) again = True while again: #print("current Price") if timer.is_alive() == False: print("STOPPED") response = au.refresh_token(REFRESH_TOKEN, 'CHARLIEQ') c = TDClient(response['access_token']) c.accounts() timer = Timer(1500.0, timeout) timer.start() quote = c.quote('ugaz') current_price = quote['UGAZ']['lastPrice'] print("Current Price: " + str(current_price)) sleep(1.5) ###if current_price >= our price ###sell ###if current_price <= our price ###buy ### fill in with algorithm