with open(filename) as f: tickers = [r.rstrip('\n') for r in f] else: print_usage() if len(tickers) == 0: raise Exception('No tickers were found') #else: # print 'Fetching: %s' % ','.join(tickers) ''' Get browser, and log in to Ameritrade. Replace userid and password below with correct values. TODO: o Encrypt so they are not stored in plain text. ''' (br,__) = mech.get_browser() br.open('https://mobile.tdameritrade.com/wireless/loginAction_input.action') html = br.response().read() assert 'Password' in html, 'Not on logon page' assert 'Ameritrade' in html # print html br.select_form(nr=0) br['userid'] = '*****' br['password'] = '******' br.submit() assert 'Balances' in br.response().read(), 'not on login landing page: %s'%br.response().read() ''' Gather list of possible responses / errors you may see when you try to submit a Sell Short order. ''' bad_sym_cond = []
import mech import json import requests import pandas as pd br,_ = mech.get_browser() example_options = {'id':256304, 'q1':59, 'type_filter':'1,2,3,4', 'symbol':'', 'change_filter':'1,2,3,4,5', 'minimum_ranking':'', 'minimum_shares':'', '_search':'false', 'rows':'25', 'page':1} quarter_mapping = {'59':'09/30/2015', '58':'06/30/2015', '57':'03/31/2015', '56':'12/31/2014', '55':'09/30/2014'} def search_filers(search_phrase): # Search Box: http://whalewisdom.com/session/new url = 'http://whalewisdom.com/search/filer_stock_search2?search_phrase=%s&filer_restrictions=undefined'%search_phrase.replace(' ','+') r = requests.get(url) if r.text == 'Invalid search parameters': print r.text df = pd.DataFrame([])
filename = sys.argv[2] with open(filename) as f: tickers = [r.rstrip('\n') for r in f] else: print_usage() if len(tickers) == 0: raise Exception('No tickers were found') #else: # print 'Fetching: %s' % ','.join(tickers) ''' Get browser, and log in to Ameritrade. Replace userid and password below with correct values. TODO: o Encrypt so they are not stored in plain text. ''' (br, __) = mech.get_browser() br.open('https://mobile.tdameritrade.com/wireless/loginAction_input.action') html = br.response().read() assert 'Password' in html, 'Not on logon page' assert 'Ameritrade' in html # print html br.select_form(nr=0) br['userid'] = '*****' br['password'] = '******' br.submit() assert 'Balances' in br.response().read( ), 'not on login landing page: %s' % br.response().read() ''' Gather list of possible responses / errors you may see when you try to submit a Sell Short order. ''' bad_sym_cond = []