コード例 #1
0
import moira
from moira import moira
from googlefinance import getQuotes
import json

# SET UP MOIRA
token = moira.get_token('*****@*****.**', 'password')
game = 'hack-the-system'

stocks = moira.get_current_holdings(token, game)
prices = [stocks[x].current_price for x in stocks]
#print prices

def analyze(stockTicker):
    """
    Feed the ticker string to googlefinance's "getQuotes" function--
    allowing us to retrieve the real time price. At least I hope
    it is in real time.

    :param stockTicker: String of the stock ticker you wish to analyze
    """

    quotes = getQuotes(stockTicker)
    print json.dumps(quotes, indent=2)

    # I'll let it print out the full data for now... I want to know the time
    # and stuff, but eventually I will have it filter for just the price :)
    # then I can have that price be saved in a .CSV so that I can graph and
    # analyze later or something.

def analyzeM(stockTicker):
コード例 #2
0
ファイル: mirrorbuy.py プロジェクト: inculi/follow-the-leader
filename = "transactions.csv"
#Instantiate mynet
mynet = 0
symbols = []
orderdate = []
transdate = []
ordertype = []
orderamount = []
orderprice = []
allitems = []

#t.getHistory("http://www.marketwatch.com/game/summit-high-school-economics-club-2015-2016/portfolio/transactionhistory?name=Andrew%20Hollenbaugh&p=1215199")
url = "http://www.marketwatch.com/game/moiratestone/portfolio/transactionhistory?name=James%20McGregor&p=1491149"

#Log in to marketwatch
token = moira.get_token(username, password)
#Try to get user portfolio, if not, assume it is 1000000
try:
    portfolio = moira.get_portfolio_data(token, game)
    #Get net worth from portfolio
    mynet = portfolio["net_worth"]
except:
    mynet = 1000000.00


dic = pd.read_csv(filename).to_dict()


def checkNew(variable):
    if len(dic[variable]) > 10:
        for x in range(0, len(dic[variable] - 10)):
コード例 #3
0
		self.yellow = ''
		self.blue = ''
		self.fucshia = ''
		self.goldenrod = ''
		self.white = ''
		self.end = ''

username = '******'
password = '******'
game = 'intro-to-business-spring-2015'
ticker = 'UWTI'
stock = 'EXCHANGETRADEDNOTE-XASQ-UWTI'
amount = 300000
outputfmt = clr.pink + '%(time)s' + clr.peach + ' $%(price)s' + clr.end
timefmt = '{:%Y-%m-%d %H:%M:' + clr.dullyellow + '%S}'
token = moira.get_token(username, password)

def get_google():
    r2 = requests.get('http://finance.google.com/finance/info', params={'q': ticker})
    
    #r['time'] = clr.pink + timefmt.format(r['time'])
    j = json.loads(r2.text.replace('\n','').replace('/','').replace('[','').replace(']',''))
    #print r2.headers['date'], float(j['l_cur']), outputfmt % r
    #time.sleep(.05)
    
    return float(j['l_cur'])

def get_mw():
    r = moira.stock_search(token, game, ticker)
    return float('%(price)f' % r)