当前位置: 首页>>代码示例>>Python>>正文


Python ystockquote.get_price函数代码示例

本文整理汇总了Python中ystockquote.get_price函数的典型用法代码示例。如果您正苦于以下问题:Python get_price函数的具体用法?Python get_price怎么用?Python get_price使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_price函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: printStocks

def printStocks(sL) : # Prints the stocks
	for x in sL: # A for each loop
		lcd.clear() # Clears the LCD
		print x + " " + ystockquote.get_price(x) # Gets the price of x and prints it to console
		lcd.message(x + " " + ystockquote.get_price(x)) # Gets the price and shows it on the lcd
		print ystockquote.get_change(x) # Gets the price change and prints it to the console
		lcd.message(ystockquote.get_change(x)) # Gets the price change and shows it on the lcd
		sleep(10) # Sleeps so it user can read the info
开发者ID:nicholas-russell,项目名称:RPi-LCD-Stock-Displayer,代码行数:8,代码来源:stock_watcher.py

示例2: oil

def oil():
  # crude oil
  crude = ystockquote.get_price('CLJ14.NYM')
  print crude
  # heating oil
  heat = ystockquote.get_price('HOH14.NYM')
  print heat
  if float(crude) < 98:
    body = "Low price alert! Crude: " + crude + " Heat: " + heat
    messager(body)
    print body
  return
开发者ID:fayeishere,项目名称:oilAlert,代码行数:12,代码来源:app.py

示例3: buy_stock_conditionals

def buy_stock_conditionals(data, portfolio, monthly, request):
    price = ystockquote.get_price(str(data))
    number_shares = math.trunc(float(monthly) / float(price))
    if portfolio:
        for items in portfolio:
            empty_stock_add_shares(data, items, number_shares)
    else:
        price = ystockquote.get_price(str(data))
        cost = float(price) * float(number_shares)
        real_cost = decimal.Decimal(cost)
        PersonalStockPortfolio.objects.create(name="primary", owner=request.user, stock_one_name=str(data),
                                              stock_one_shares=number_shares, cost=real_cost)
    data = {data: number_shares}
    return data
开发者ID:travis6888,项目名称:wealthy,代码行数:14,代码来源:utils.py

示例4: update_price

def update_price(dict):
	'''
	Updates portfolio with new prices
	'''
	print 'Updating portfolio...'
	for key in dict:
		dict[key][4] = ystockquote.get_price(dict[key][1])
开发者ID:blazinghand,项目名称:Portfolio_Tracker,代码行数:7,代码来源:portfolio_tracker.py

示例5: __init__

 def __init__(self, ticker):
     self.ticker = ticker
     params = getParams(ticker)
     self.mean = params[0][0]
     self.var = params[0][1]
     self.vol = params[1]
     self.price = get_price(self.ticker)
开发者ID:r0fls,项目名称:monteio,代码行数:7,代码来源:futurePrice.py

示例6: get_stock_cost

def get_stock_cost(data, number_shares, items):
    price = ystockquote.get_price(str(data))
    cost = float(price) * float(number_shares)
    real_cost = decimal.Decimal(cost)
    items.cost += real_cost
    items.save()
    return real_cost
开发者ID:travis6888,项目名称:wealthy,代码行数:7,代码来源:utils.py

示例7: run

 def run(self):
     """
     Main loop
     """
     properties = {"app_id": self.app_id}
     while True:
         # Loop over the tickers and lookup the stock price and volume
         for ticker in self.tickers:
             measurements = []
             price = ystockquote.get_price(ticker)
             volume = ystockquote.get_volume(ticker)
             timestamp = int(time.time())
             if volume == 'N/A' or price == 'N/A':
                 sys.stderr.write('Could not find ticker \"{0}\", skipping'.format(ticker))
             else:
                 print("ticker: {0}, price: {1}, volume: {2}".format(ticker, price, volume))
                 measurements.append(Measurement(metric='STOCK_PRICE',
                                                 value=price,
                                                 source=ticker,
                                                 properties=properties))
                 measurements.append(Measurement(metric='STOCK_VOLUME',
                                                 value=volume,
                                                 source=ticker,
                                                 properties=properties))
                 self.send_measurements(measurements)
         time.sleep(self.interval)
开发者ID:boundary,项目名称:tsi-lab,代码行数:26,代码来源:ex6-1.stocks.py

示例8: buyStockIfPossible

	def buyStockIfPossible(self):
		for k,v in self.stocks.items():
			cost = float(ystockquote.get_price(k));
			if(cost < self.capital):
				count = int(self.capital / cost);
				self.stocks[k] = v + count;
				self.capital -= cost * count;
开发者ID:TuckerBMorgan,项目名称:Stock,代码行数:7,代码来源:stockCheck.py

示例9: export

 def export(self, xlsx_file, s_flag):
   wb = Workbook()
   ws = wb.create_sheet(0)
   ws.title = "Guru 13Fs"
   print "Writing {0}...".format(xlsx_file) 
   headers = ["Gurus", "Date", "Symbol", "Action", "Average", "Minimum", "Volume", "Portfolio Impact"]
   if s_flag:
     headers.append("Current Share Price")
   
   col = 0
   for header in headers:
     header_cell = ws.cell(row = 0, column = col)
     header_cell.value = header
     if header == "Gurus":
       ws.merge_cells(start_row = 0, start_column = 0, end_row = 0, end_column = 2)
       col += 2
     col += 1
     
   db = self.client.gurudb
   gurus = db.gurus
   cursor = gurus.find()
   
   share_prices = dict()
   guruRow = 1
   for guru in cursor:
     tickers = guru['tickers']
     for ticker in tickers:
       history = ticker['transactionHistory']
       transactions = history['transactions']
       symbol = ticker['ticker']
       if share_prices.get(symbol) == None and s_flag:
         share_prices[symbol] = ystockquote.get_price(symbol)
         print "Retrieved {0} at ${1} for {2}".format(symbol, share_prices[symbol], guru['name'])
       for transaction in transactions:
         guru_cell = ws.cell(row = guruRow, column = 0)
         guru_cell.value = guru['name']
         ws.merge_cells(start_row = guruRow, start_column = 0, end_row = guruRow, end_column = 2)
         symbol_cell = ws.cell(row = guruRow, column = self.SYMBOL_CELL)
         symbol_cell.value = symbol
         impact_cell = ws.cell(row = guruRow, column = self.IMPACT_START_CELL)
         impact_cell.value = "{0}%".format(ticker['percent'])
         transaction_cell = ws.cell(row = guruRow, column = self.DATE_CELL)
         transaction_cell.value = transaction['date']
         action_cell = ws.cell(row = guruRow, column = self.ACTION_CELL)
         action_cell.value = transaction['entryType']
         average_cell = ws.cell(row = guruRow, column = self.AVERAGE_CELL)
         # convert from int to decimal. stored in mongo this way for percision reasons
         average_cell.value = float(transaction['avg']) * 0.01
         minimum_cell = ws.cell(row = guruRow, column = self.MINIMUM_CELL)
         minimum_cell.value = float(transaction['min']) * 0.01
         volume_cell = ws.cell(row = guruRow, column = self.VOLUME_CELL)
         volume_cell.value = transaction['numberOfShares']
         if s_flag:
           current_share_price_cell = ws.cell(row = guruRow, column = self.CURRENT_SHARE_PRICE_START_CELL)
           current_share_price_cell.value = share_prices.get(symbol)
         guruRow += 1
   
   wb.save(xlsx_file)
   print "Wrote {0}".format(xlsx_file) 
   return
开发者ID:cpitzak,项目名称:excel13Fs,代码行数:60,代码来源:export13Fs.py

示例10: check

def check(symbol, position=False):
  days = 20
  quotes = prices(symbol, days) 
  _raising = raising(symbol) 
  _price = float(ystockquote.get_price(symbol))
  _over_mavg = over_mavg(_price, quotes)
  _min = min(quotes)
  #print "%s min %s, now %s" % (symbol, _min, _price)

  if(position):
    color = "red"
  else:  
    color = "orange"

  if(_raising and
     _over_mavg):
    print "<div style=color:green>Raising and over mavg: BUY %s</div>" % symbol
    return

  if(not _over_mavg):
    print "<div style=color:%s>Not over mavg: SELL %s</div>" % (color, symbol)
    return
  
  if(_price <= _min):
    print "<div style=color:orange>Under 20 day min: SELL %s</div>" % (color, symbol)
    return
  
  print "<div>No matching signal for %s</div>" % symbol
开发者ID:codelurker,项目名称:stockholm,代码行数:28,代码来源:system.py

示例11: post_stock_price

def post_stock_price(symbol, apikey, devicename):
    '''
    Retrieve the stock price for the given ticker symbol ("T" for AT&T) and
    post it in the correct M2X data stream.
    '''
    client = M2XClient(key=apikey)

    # Find the correct device if it exists, if not create it.
    try:
        device = [d for d in client.devices(q=devicename) if d.name == devicename][0]
    except IndexError:
        device = client.create_device(name=devicename,
                                      description="Stockreport Example Device",
                                      visibility="private")

    # Get the stream if it exists, if not create the stream.
    try:
        stream = device.stream(symbol)
    except HTTPError:
        stream = device.create_stream(symbol)
        device.update_stream(symbol, unit={'label': 'Dollars', 'symbol': '$'})

    postime = datetime.now()
    stock_price = ystockquote.get_price(symbol).encode('utf-8')
    stream.add_value(stock_price, postime)
开发者ID:attm2x,项目名称:m2x-demo-heroku-python,代码行数:25,代码来源:stockreport.py

示例12: buy

 def buy(self, ticker, amount):
     buy_price = y.get_price(ticker)
     buy_date = datetime.today()
     pos = Position(ticker, buy_date, buy_price, amount)
     self.open_positions.append(pos)
     buy = Decimal(buy_price.strip(' "')) * Decimal(amount)
     self.cash = int(self.cash - buy)
开发者ID:ohansrud,项目名称:StockUtils,代码行数:7,代码来源:Portfolio.py

示例13: priceMe

def priceMe(tick):
	price = 0
	try:
		price = float(ystockquote.get_price(tick))
	except:
		return price
	return price
开发者ID:ShayanArman,项目名称:knotPortfolio,代码行数:7,代码来源:helper.py

示例14: get_current_price

def get_current_price(symbol):
    """
    Get the latest price!
    :param symbol:
    :return:
    """
    return float(ystockquote.get_price(symbol))
开发者ID:Stock-Portfolio-Risk-Analyzer,项目名称:spr,代码行数:7,代码来源:yahoo_finance.py

示例15: __init__

 def __init__(self, ticker):
     self.ticker = ticker
     self.price = round(float(ystock.get_price(ticker)), 2)
     self.ma_5 = None
     self.ma_10 = None
     self.ma_20 = None
     self.ma_50 = None
     self._calculate_moving_averages()
开发者ID:gollum2411,项目名称:antec,代码行数:8,代码来源:mavgs.py


注:本文中的ystockquote.get_price函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。