Example #1
0
def analyzeM(stockTicker):
    """
    Feed the ticker string to moira's stock_search function--
    allowing us to retrieve the [hopefully] lagging time.

    :param stockTicker: String of the stock ticker you wish to analyze
    """
    price = moira.stock_search(token,game,stockTicker)
    print price
Example #2
0
	clr.disable()

if username:
	if not password:
		password = getpass.getpass()
	token = moira.get_token(username, password)
	with open('/tmp/.moira-token-cache', 'w') as f:
		pickle.dump(token, f)
	print('Token stored to /tmp/.moira-token-cache; on future runs, omit the username and password and use the -t flag for faster startup.')

if args.cached_token:
	with open('/tmp/.moira-token-cache', 'r') as f:
		token = pickle.load(f)

if args.no_continuous:
	r = moira.stock_search(token, game, ticker)
	if not args.use_local_time:
		r['time'] = timefmt.format(r['time'])
	else:
		r['time'] = time.ctime()
	print(outputfmt % r)
else:
	try:
		while 1:
			r = moira.stock_search(token, game, ticker)
			tick = time.mktime(r['time'].timetuple())
			if tick % 2:
				sym = u'\u25cf'
			else:
				sym = u'\u25cb'
			r['time'] = clr.dullgreen + sym + clr.end + ' ' + clr.pink + timefmt.format(r['time'])
Example #3
0
def get_mw():
    r = moira.stock_search(token, game, ticker)
    return float('%(price)f' % r)
Example #4
0
if username:
    if not password:
        password = getpass.getpass()
    token = moira.get_token(username, password)
    with open('/tmp/.moira-token-cache', 'w') as f:
        pickle.dump(token, f)
    print(
        'Token stored to /tmp/.moira-token-cache; on future runs, omit the username and password and use the -t flag for faster startup.'
    )

if args.cached_token:
    with open('/tmp/.moira-token-cache', 'r') as f:
        token = pickle.load(f)

if args.no_continuous:
    r = moira.stock_search(token, game, ticker)
    if not args.use_local_time:
        r['time'] = timefmt.format(r['time'])
    else:
        r['time'] = time.ctime()
    print(outputfmt % r)
else:
    try:
        while 1:
            r = moira.stock_search(token, game, ticker)
            tick = time.mktime(r['time'].timetuple())
            if tick % 2:
                sym = u'\u25cf'
            else:
                sym = u'\u25cb'
            r['time'] = clr.dullgreen + sym + clr.end + ' ' + clr.pink + timefmt.format(
Example #5
0
try:
	while 1:
		print("Single-key trading interface.\n"
	      	+ clr.dullgreen + "[d - sell] "
	      	"[f - buy] " + clr.end +
	      	clr.blue + "[j - short] "
	      	"[k - cover]\n" + clr.end +
		clr.peach + "[s - shares] "
		"[q - quit]" + clr.end)
		key = getch()
		try:
			action = {'f': 'Buy',
	 		'd': 'Sell',
	 		'j': 'Short',
	 		'k': 'Cover',
			's': '',
			'q': ''}[key]
			if key == 'q':
				raise KeyboardInterrupt
			if key == 's':
				_get_shares()

			if action:
				print(clr.fuchsia + action + clr.end + ' ' + clr.green + shares + clr.peach + ' @ ' + clr.yellow + '$' + str(moira.stock_search(token, game, ticker.split('-')[2])['price']) + clr.end)
				moira.order(token, game, action, ticker, shares)
		except KeyError:
			print("Invalid key.")
			pass
except KeyboardInterrupt:
	sys.exit(1)
Example #6
0
              "[f - buy] " + clr.end + clr.blue + "[j - short] "
              "[k - cover]\n" + clr.end + clr.peach + "[s - shares] "
              "[q - quit]" + clr.end)
        key = getch()
        try:
            action = {
                'f': 'Buy',
                'd': 'Sell',
                'j': 'Short',
                'k': 'Cover',
                's': '',
                'q': ''
            }[key]
            if key == 'q':
                raise KeyboardInterrupt
            if key == 's':
                _get_shares()

            if action:
                print(clr.fuchsia + action + clr.end + ' ' + clr.green +
                      shares + clr.peach + ' @ ' + clr.yellow + '$' + str(
                          moira.stock_search(token, game,
                                             ticker.split('-')[2])['price']) +
                      clr.end)
                moira.order(token, game, action, ticker, shares)
        except KeyError:
            print("Invalid key.")
            pass
except KeyboardInterrupt:
    sys.exit(1)