def searchStock(tickerSymbol,option): searchData = str(moira.stock_search(token, game, tickerSymbol)) if option == 'name': re1='.*?' # Non-greedy match on filler re2='\\\'.*?\\\'' # Uninteresting: strng re3='.*?' # Non-greedy match on filler re4='\\\'.*?\\\'' # Uninteresting: strng re5='.*?' # Non-greedy match on filler re6='(\\\'.*?\\\')' # Single Quote String 1 rg = re.compile(re1+re2+re3+re4+re5+re6,re.IGNORECASE|re.DOTALL) m = rg.search(searchData) if m: strng1=m.group(1) return (strng1).replace("'","") if option == 'price': re1='.*?' # Non-greedy match on filler re2='([+-]?\\d*\\.\\d+)(?![-+0-9\\.])' # Float 1 rg = re.compile(re1+re2,re.IGNORECASE|re.DOTALL) m = rg.search(searchData) if m: float1=m.group(1) return float(float1)
def searchStock(tickerSymbol, option): searchData = str(moira.stock_search(token, game, tickerSymbol)) if option == 'name': re1 = '.*?' # Non-greedy match on filler re2 = '\\\'.*?\\\'' # Uninteresting: strng re3 = '.*?' # Non-greedy match on filler re4 = '\\\'.*?\\\'' # Uninteresting: strng re5 = '.*?' # Non-greedy match on filler re6 = '(\\\'.*?\\\')' # Single Quote String 1 rg = re.compile(re1 + re2 + re3 + re4 + re5 + re6, re.IGNORECASE | re.DOTALL) m = rg.search(searchData) if m: strng1 = m.group(1) return (strng1).replace("'", "") if option == 'price': re1 = '.*?' # Non-greedy match on filler re2 = '([+-]?\\d*\\.\\d+)(?![-+0-9\\.])' # Float 1 rg = re.compile(re1 + re2, re.IGNORECASE | re.DOTALL) m = rg.search(searchData) if m: float1 = m.group(1) return float(float1)
def searchStock(tickerSymbol): searchData = str(moira.stock_search(token, game, tickerSymbol)) re1 = ".*?" # Non-greedy match on filler re2 = "\\'.*?\\'" # Uninteresting: strng re3 = ".*?" # Non-greedy match on filler re4 = "\\'.*?\\'" # Uninteresting: strng re5 = ".*?" # Non-greedy match on filler re6 = "(\\'.*?\\')" # Single Quote String 1 rg = re.compile(re1 + re2 + re3 + re4 + re5 + re6, re.IGNORECASE | re.DOTALL) m = rg.search(searchData) if m: strng1 = m.group(1) return (strng1).replace("'", "")
from moira import moira import time import login as l # SET UP MOIRA token = l.login() game = 'meisenheimer' for x in xrange(0,20): time.sleep(5) astring = moira.stock_search(token, game, 'FLDM') print astring
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'
from moira import moira import time import login as l # SET UP MOIRA token = l.login() game = 'meisenheimer' for x in xrange(0, 20): time.sleep(5) astring = moira.stock_search(token, game, 'FLDM') print astring