def buyStock(token, game, action, tickerSymbol, amt, times): print("Buying...") for x in xrange(0, times): print("moira.order(token, game, " + str(action) + ", " + str(tickerSymbol) + ", " + str(amt) + ")") orderStatus = moira.order(token, game, str(action), str(tickerSymbol), str(amt)) if orderStatus[0] == True: print("Order successful.") break else: # Volume restriction bypass print("\nOrder Failed. Fixing now...") # find the legal transaction limit newAmount = int( (str(orderStatus[1]).rsplit("volume restriction ", 1)[1]).rsplit(".", 1)[0]) times = amt / newAmount # the amount of legal transactions we can make remainder = amt - (newAmount * (amt / newAmount)) # excess amount # break up the large order into smaller, legal transactions for x in range(times): moira.order(token, game, action, tickerSymbol, newAmount) # order the excess amount moira.order(token, game, action, tickerSymbol, remainder) print("Transaction complete.")
def buyStock(token, game, action, tickerSymbol, amt, times): print("Buying...") for x in xrange(0,times): print("moira.order(token, game, " + str(action) + ", " + str(tickerSymbol) + ", " + str(amt) + ")") orderStatus = moira.order(token, game, str(action), str(tickerSymbol), str(amt)) if orderStatus[0] == True: print("Order successful.") break else: # Volume restriction bypass print("\nOrder Failed. Fixing now...") # find the legal transaction limit newAmount = int((str(orderStatus[1]).rsplit("volume restriction ", 1)[1]).rsplit(".", 1)[0]) times = amt/newAmount # the amount of legal transactions we can make remainder = amt - (newAmount * (amt/newAmount)) # excess amount # break up the large order into smaller, legal transactions for x in range(times): moira.order(token, game, action, tickerSymbol, newAmount) # order the excess amount moira.order(token, game, action, tickerSymbol, remainder) print("Transaction complete.")
def buyStock(token, game, action, tickerSymbol, amt, times): print("Buying...") for x in xrange(0, times): moira.order(token, game, action, tickerSymbol, amt) print("Transaction complete.")
from moira import moira import login as l # SET UP MOIRA token = l.login() game = 'meisenheimer' while True: #time.sleep(1) astring = moira.stock_search(token, game, 'TSLA') print astring['price'] if float(astring['price']) >= 205: print 'yes, selling 100 shares' moira.order(token, 'meisenheimer', 'Sell', 'STOCK-XNAS-TSLA', 100) else: print 'no'