def test_match_order_type(self): real_order = test_utils.real_order() order = EquityOrderBuilder('CVS', 1) \ .set_order_type(EquityOrderBuilder.OrderType.MARKET) self.assertTrue(order.matches(real_order)) order.set_order_type(EquityOrderBuilder.OrderType.LIMIT) self.assertFalse(order.matches(real_order))
currentdir = os.path.dirname(os.path.realpath(__file__)) parentdir = os.path.dirname(currentdir) sys.path.append(parentdir) import config # stored in parent directory for security token_path = 'token' redirect_uri = "https://localhost" DRIVER_PATH = "/home/hopper/chromedriver" driver = webdriver.Chrome(DRIVER_PATH) try: c = auth.client_from_token_file(token_path, config.api_key) except FileNotFoundError: c = auth.client_from_login_flow( driver, config.api_key, redirect_uri, token_path ) time.sleep(2) # print(c.place_order(config.tda_acct_num, equity_buy_market('SNDL', 1).set_duration(Duration.GOOD_TILL_CANCEL).set_session(Session.SEAMLESS).build())) builder = EquityOrderBuilder() builder.set_instruction(EquityOrderBuilder.instruction.SELL) builder.set_order_type(EquityOrderBuilder.OrderType.MARKET) builder.set_duration(duration.DAY) time.sleep(2) driver.quit()
from selenium import webdriver import json currentdir = os.path.dirname(os.path.realpath(__file__)) parentdir = os.path.dirname(currentdir) sys.path.append(parentdir) import config # stored in parent directory for security token_path = 'token' redirect_uri = "https://localhost" DRIVER_PATH = "/home/hopper/chromedriver" driver = webdriver.Chrome(DRIVER_PATH) try: c = auth.client_from_token_file(token_path, config.api_key) except FileNotFoundError: c = auth.client_from_login_flow( driver, config.api_key, redirect_uri, token_path ) time.sleep(2) # print(c.place_order(config.tda_acct_num, equity_buy_market('SNDL', 1).set_duration(Duration.GOOD_TILL_CANCEL).set_session(Session.SEAMLESS).build())) builder = EquityOrderBuilder() builder.set_instruction(EquityOrderBuilder.instruction.SELL) builder.set_order_type(EquityOrderBuilder.OrderType.MATRK) time.sleep(2) driver.quit()
from tda import auth, client from tda.orders import EquityOrderBuilder, Duration, Session import json import config import datetime # limit order of 5 shares of netflix stock at 18 dollars a share builder = EquityOrderBuilder('NFLX', 5) builder.set_instruction(EquityOrderBuilder.Instruction.BUY) builder.set_order_type(EquityOrderBuilder.OrderType.LIMIT) builder.set_price(18) builder.set_duration(Duration.GOOD_TILL_CANCEL) builder.set_session(Session.NORMAL) response = c.place_order(config.account_id, builder.build())