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


Python Share.get_open方法代码示例

本文整理汇总了Python中yahoo_finance.Share.get_open方法的典型用法代码示例。如果您正苦于以下问题:Python Share.get_open方法的具体用法?Python Share.get_open怎么用?Python Share.get_open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yahoo_finance.Share的用法示例。


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

示例1: get_quote

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_open [as 别名]
def get_quote(symbol):
    share = Share(symbol)

    if not share.get_price():
        return {}

    change_f = float(share.get_change())
    change_str = '+%.02f' % change_f if change_f >= 0 else '%.02f' % change_f

    change_percent_f = change_f / float(share.get_open()) * 100
    change_percent = '+%.02f' % change_percent_f if change_percent_f >= 0 else '%.02f' % change_percent_f

    return {
        'price': share.get_price(),
        'change': change_str,
        'change_percent': change_percent,
        'open_price': share.get_open(),
        'market_cap': share.get_market_cap(),
        'year_low': share.get_year_low(),
        'year_high': share.get_year_high(),
        'day_low': share.get_days_low(),
        'day_high': share.get_days_high(),
        'volume': share.get_volume(),
        'pe_ratio': share.get_price_earnings_ratio() or '-'
    }
开发者ID:karan,项目名称:slashStock,代码行数:27,代码来源:share.py

示例2: SelectStock

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_open [as 别名]
 def SelectStock(self):
     wb = Workbook()
     ws = wb.active
     with open('export.csv',newline='') as f:
         reader = csv.reader(f)
         index = 2
         title = ["代號","名稱","股價","本益比","EPS"]
         for x in range(0,5,1):
             ws.cell(row=1,column=x+1,value=title[x])
         for row in reader:
             if row!=[]:
                 try:
                     if int(row[0]) < 10000:
                     #    print(row[2])
                         if "-" not in (row[2]) and float(row[2]) < 20:
                          #   print(row)
                             Query = Share(row[0]+'.TW')
                             #print(float(Query.get_earnings_share()))     
                             #print(float(Query.get_open()))
                             #print("******************")
                             if float(Query.get_open()) >= 20 and float(Query.get_open()) <= 90 and float(Query.get_earnings_share())>1.2:
                                 print(row)
                                 ws.cell(row=index , column=1 , value = row[0])
                                 ws.cell(row=index , column=2 , value = row[1])
                                 ws.cell(row=index , column=3 , value = Query.get_open())
                                 ws.cell(row=index , column=4 , value = row[2])
                                 ws.cell(row=index , column=5 , value = Query.get_earnings_share())
                                 index = index + 1
             
                                 
                 except:
                     pass    
         wb.save("Final.xlsx")        
开发者ID:sheettrait,项目名称:Stock_Python,代码行数:35,代码来源:Main.py

示例3: recentdata

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_open [as 别名]
def recentdata(companyname):
    try:
        companydata = Share(companyname)
        print "This morning, it opened for $" + companydata.get_open() + ", and right now is at $" + companydata.get_price() + "."
        if companydata.get_open() > companydata.get_price():
            difference = float(companydata.get_open()) - float(companydata.get_price())
            if len(str(difference)) < 3:
                print "Since this morning, the price has fallen by $" + str(difference) + "0"
            else:
                print "Since this morning, the price has fallen by $" + str(difference)
        elif companydata.get_open() < companydata.get_price():
            difference = float(companydata.get_price()) - float(companydata.get_open())
            if len(str(difference)) < 3:
                print "Since this morning, the price has risen by $" + str(difference) + "0"
            else:
                print "Since this morning, the price has risen by $" + str(difference)
        print ""
        selection = raw_input(
            "Would you like some info about what the stock has been like in the past few days? Yes/No: ")
        if str.lower(selection) == "no":
            end()
        elif str.lower(selection) == "yes":
            print "Okay, please wait a moment"
    except (RuntimeError, TypeError, NameError):
        print "Whoops, something went wrong there. Are you sure you entered a valid company abbreviation?"

    finally:
        longterm(companyname)
开发者ID:robbiebarrat,项目名称:Stock_advisor,代码行数:30,代码来源:Stocks.py

示例4: updateInfos

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_open [as 别名]
def updateInfos():
    print("Updating Infos!")
    with open('static/sp100.json', 'rb') as f:
        ls = json.load(f)
        for i in ls:
            timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
            print (i['name'])
            symbol = Share(i['name'])
            item = {
                'name': i['name'],
                'price': symbol.get_price(),
                'time': timestamp,
                'prev_close': symbol.get_prev_close(),
                'open': symbol.get_open(),
                'volume': symbol.get_volume(),
                'pe': symbol.get_price_earnings_ratio(),
                'eps': symbol.get_earnings_share(),
                'price_sales': symbol.get_price_sales(),
                'ebitda': symbol.get_ebitda(),
                'hotness': ms.hotness_function(i['name']),
                'BS': ms.bs_function(i['name'])}
            db.infos.update(
                {"name": i['name']},
                {
                    "$push": {"data": item}
                }
            )
    print('Collection Infos Updated.')
    return Response('Collection Infos Updated.')
开发者ID:jckhang,项目名称:stockTwits_server,代码行数:31,代码来源:app.py

示例5: get_stock_info

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_open [as 别名]
def get_stock_info(symbols, moreInfo=False):
	""" 
	Scrape stock info from Yahoo finance
	@Param 'moreInfo': False for getting price, True for getting more information
	@Return 'message': "symbol: Price-number, Open Price-number, Pre Close Price-number, High Price-number, 
						Low price-number"
	"""
	message = ''
	for symbol in symbols:
		try:
			stock = Share(symbol)
			price = stock.get_price()
		except AttributeError:
			price = None
		
		if price == None: # Stock symbol not exists, replace with an alert message
			message += '#' + symbol + ': ' + 'The stock symbol does not exit' + '\n'
		elif moreInfo: 
			message += '#%s: Price-%s, Open Price-%s, Pre Close Price-%s, High Price-%s, Low price-%s\n' \
						% (symbol, price, stock.get_open(), stock.get_prev_close(), stock.get_days_high(), stock.get_days_low())
		else:
			message += '#' + symbol + ': ' + price + '\n'

	alert_message = 'Please type #1 followed by stock symbols to get more information' if moreInfo == True else \
					'Please type #0 followed by stock symbols to get stock price'
	return message if message != '' else alert_message
开发者ID:HugoZhang33,项目名称:StockTicker,代码行数:28,代码来源:views.py

示例6: get_data

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_open [as 别名]
def get_data():

    filename = 'data/symbols.csv'

    data = []

    with open(filename, 'r') as csvfile:

        reader = csv.reader(csvfile, delimiter=',')

        for row in reader:


            symbol  = row[0]
            print ("Getting share for %s" % symbol)

            name    = row[1]
            sector  = row[2]

            share = Share(symbol)
            _open = share.get_open()

            if _open:
                data.append({
                    'id'        : symbol,
                    'symbol'    : symbol,
                    'name'      : name,
                    'sector'    : sector,
                    'open'      : _open
                })


    return data
开发者ID:ZackBotkin,项目名称:stock-project,代码行数:35,代码来源:indexer.py

示例7: fundamentalStats

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_open [as 别名]
def fundamentalStats(stock):

	try:

		stokOutput = Share(stock)

		openPrice = stokOutput.get_open()
		closePrice = stokOutput.get_prev_close()	
		dailyDelta = stokOutput.get_change()
		earningsShare = stokOutput.get_earnings_share()	
		fiddyDay = stokOutput.get_50day_moving_avg()
		priceBook = stokOutput.get_price_book()
		peeEee = stokOutput.get_price_earnings_ratio()
		pegRatio = stokOutput.get_price_earnings_growth_ratio()


		if (float(priceBook) < 1.5 and float(peeEee) < 50 and float(pegRatio) < 2 and float(peeEee) > 0):
			csvList = [stock, "open price:", openPrice, "previous close:", closePrice, "daily deltas:", dailyDelta, "earnings per share:", earningsShare, "50 day moving avg:", fiddyDay, "price/book:", priceBook, "price/earnings:", peeEee, "peg:", pegRatio, "\n"]
			print (stock, "will be imported to Excel.") 

			stockPicks = open("picks.csv", "a", newline='')

			writeCSV = csv.writer(stockPicks, dialect='excel')
			for stock in csvList:
				writeCSV.writerow([stock])

		else:
			print (stock, "does not meet criteria.")


	except:
		print(stock, "is missing a defined key statistic.")
开发者ID:alanleung88,项目名称:stockpicker,代码行数:34,代码来源:stockPicker.py

示例8: createInfos

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_open [as 别名]
def createInfos():
    if db.infos.count() == 0:
        print("Creating Infos!!")
        with open('static/sp100.json', 'rb') as f:
            ls = json.load(f)
            for i in ls:
                timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
                symbol = Share(i['name'])
                item = {
                    'name': i['name'],
                    'price': symbol.get_price(),
                    'time': timestamp,
                    'prev_close': symbol.get_prev_close(),
                    'open': symbol.get_open(),
                    'volume': symbol.get_volume(),
                    'pe': symbol.get_price_earnings_ratio(),
                    'eps': symbol.get_earnings_share(),
                    'price_sales': symbol.get_price_sales(),
                    'ebitda': symbol.get_ebitda(),
                    'hotness': ms.hotness_function(i['name']),
                    'BS': ms.bs_function(i['name'])}
                db.infos.insert_one({
                    "name": i['name'],
                    "sector": i['sector'],
                    "data": [item]
                })
        print('Collection Infos Created.')
        return Response('Collection Infos Created.')
开发者ID:jckhang,项目名称:stockTwits_server,代码行数:30,代码来源:app.py

示例9: displayFinance

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_open [as 别名]
	def displayFinance(self, yearStart, yearEnd):
		yahoo = Share(self.companyCode)

		#declare
		textReturn = ""

		textReturn += "Opening price: " + str(yahoo.get_open()) + '\n'

		textReturn += "Current price: " + str(yahoo.get_price()) + '\n'

		textReturn += "Dividend Share: " + str(yahoo.get_dividend_share()) + '\n'
		
		textReturn += "Year High: " + str(yahoo.get_year_high()) + '\n'
		
		textReturn += "Year Low: " + str(yahoo.get_year_low()) + '\n'

		self.jsonObj.append({ "openPrice" : str(yahoo.get_open()) , "currPrice" : str(yahoo.get_price()), "dividendPrice" : str(yahoo.get_dividend_share()), "yearHigh" : str(yahoo.get_year_high()), "yearLow" : str(yahoo.get_year_low()) })


		#historical data returns a jSON object
		jsonHistorical = yahoo.get_historical(str(yearStart) + '-04-25', str(yearEnd) + '-04-29')

		textReturn += "Historical Data: " + '\n'

		#To limit the number of historical datapoints sent
		numHist = 0
		maxHist = 10

		for dict in jsonHistorical:
			numHist += 1

			if numHist < maxHist:
				textReturn += "For year " + dict['Date'] + " High was: " + dict['High'] + " Low was: " + dict['Low'] + '\n'
				#self.jsonObj[0][dict['Date'] + "High"] = dict['High']
				#self.jsonObj[0][dict['Date'] + "Low"] = dict['Low']

				self.jsonObj.append({ "Highd" : dict['Date'] , "Lowd" : dict['Date'], "Highp" : dict['High'], "Lowp" : dict['Low'] })


		if textReturn == "":
			self.jsonObj.append({ "success" : "false" })

		else:
			self.jsonObj.append({ "success" : "true" })

		return textReturn
开发者ID:SDharan93,项目名称:bridge2grid-backend,代码行数:48,代码来源:finance.py

示例10: get_quote

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_open [as 别名]
def get_quote(symbol):
    share = Share(symbol)

    return {
        'open': share.get_open(),
        'price': share.get_price(),
        'change': share.get_change(),
        'market_cap': share.get_market_cap(),
        'pe': share.get_price_earnings_ratio() or '-'
    }
开发者ID:jonahkirangi,项目名称:slashStock,代码行数:12,代码来源:bot.py

示例11: print_stats

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_open [as 别名]
def print_stats(ticker,is_trading_hours):
  stock = Share(ticker)
  stock.refresh()
  
  if(is_trading_hours == True):
    print("Current Price:  $" + stock.get_price() + "\n--------------------------------------")
  else:
    print("Previous Close: $" + stock.get_prev_close())
    print("Opening Price:  $" + stock.get_open())
    print("Current Price:  $" + stock.get_price() + "\n--------------------------------------")
开发者ID:ppourmand,项目名称:stockchecker,代码行数:12,代码来源:stocks.py

示例12: stock_summary

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_open [as 别名]
def stock_summary(request, symbol=None):
    if symbol == None:
        symbol = request.POST['symbol']

    current_stock = Stock()
    stock = Share(symbol)
    current_stock.symbol = symbol.upper()
    current_stock.price = stock.get_price()
    current_stock.change = stock.get_change()
    current_stock.volume = stock.get_volume()
    current_stock.prev_close = stock.get_prev_close()
    current_stock.stock_open = stock.get_open()
    current_stock.avg_daily_volume = stock.get_avg_daily_volume()
    current_stock.stock_exchange = stock.get_stock_exchange()
    current_stock.market_cap = stock.get_market_cap()
    current_stock.book_value = stock.get_book_value()
    current_stock.ebitda = stock.get_ebitda()
    current_stock.dividend_share = stock.get_dividend_share()
    current_stock.dividend_yield = stock.get_dividend_yield()
    current_stock.earnings_share = stock.get_earnings_share()
    current_stock.days_high = stock.get_days_high()
    current_stock.days_low = stock.get_days_low()
    current_stock.year_high = stock.get_year_high()
    current_stock.year_low = stock.get_year_low()
    current_stock.fifty_day_moving_avg = stock.get_50day_moving_avg()
    current_stock.two_hundred_day_moving_avg = stock.get_200day_moving_avg()
    current_stock.price_earnings_ratio = stock.get_price_earnings_ratio()
    current_stock.price_earnings_growth_ratio = stock.get_price_earnings_growth_ratio()
    current_stock.price_sales = stock.get_price_sales()
    current_stock.price_book = stock.get_price_book()
    current_stock.short_ratio = stock.get_short_ratio()

    date_metrics = []
    url = 'http://chartapi.finance.yahoo.com/instrument/1.0/'+symbol+'/chartdata;type=quote;range=1y/csv'
    page = urllib2.urlopen(url).read()
    pagebreaks = page.split('\n')
    for line in pagebreaks:
        items = line.split(',')
        if 'Company-Name:' in line:
            current_stock.company_name = line[13:len(line)]
            current_stock.save()
        if 'values' not in items:
            if len(items)==6:
                hd = HistoricalData(
                    stock_id = Stock.objects.get(id=int(current_stock.id)).id,
                    date = items[0][4:6]+'/'+items[0][6:9]+'/'+items[0][0:4],
                    close = items[1][0:(len(items[1])-2)],
                    high = items[2][0:(len(items[2])-2)],
                    price_open = items[3][0:(len(items[3])-2)],
                    low = items[4][0:(len(items[4])-2)],
                    volume = items[5][0:-6]+","+items[5][-6:-3]+","+items[5][-3:len(items[5])])
                hd.save()
                date_metrics.append(hd)
    del date_metrics[0]
    return render(request, "stock_summary.html", {'current_stock': current_stock, 'date_metrics': date_metrics})
开发者ID:dannyshafer,项目名称:Chrysalis-Mutual-Funds-Python-Django-,代码行数:57,代码来源:views.py

示例13: SearchPERatio

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_open [as 别名]
 def SearchPERatio(self):
     for x in range(8,1503,5):
    # for x in range(8,self.soup.select('.basic2').__len__(),5):
         if self.soup.select('.basic2')[x].text != '-':
             if float(self.soup.select('.basic2')[x].text) <=float(self.TargetPERatio) :
                 QueryPrice = Share(self.soup.select('.basic2')[x-2].text+'.TW') #Query the API  
                 if QueryPrice.get_earnings_share()!=None and float(QueryPrice.get_earnings_share())>=self.TargetEPS:                     # Get EPS
                     self.AllData.append(self.soup.select('.basic2')[x-2].text)  # StockNumber
                     self.AllData.append(QueryPrice.get_open())                  # Get FinalPrice
                     self.AllData.append(self.soup.select('.basic2')[x].text)    # Get PERatio
                     self.AllData.append(QueryPrice.get_earnings_share())
开发者ID:sheettrait,项目名称:Stock_Python,代码行数:13,代码来源:Main.py

示例14: get_open_ticker

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_open [as 别名]
	def get_open_ticker(self):
		date = datetime.datetime.now()
		weekday = date.weekday()
		if (datetime.time(07,30,30) < date.time() < datetime.time(07,31,30)) and (weekday != 5 or weekday != 6) and (self.posted_open == None or self.posted_open < date.date()):
			stock_prices = []
			all_stocks = self.get_all_stocks()
			if all_stocks:
				for stock in all_stocks:
					stock_info = Share(stock)
					stock_prices.append('%s: $%s [%s]' % (stock_info.symbol.upper(), stock_info.get_open(), stock_info.get_change()))
				self.posted_open = date.date()
				return ' - '.join(stock_prices)
开发者ID:DW3B,项目名称:TWP,代码行数:14,代码来源:TWPStocks.py

示例15: get_stock_info

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_open [as 别名]
def get_stock_info(tickers):
    for ticker in tickers:
        try:
            stock = Share(ticker)
            print ticker + '\'s opening price today: ' + stock.get_open()
            print ticker + '\'s current price today: ' + stock.get_price()
            print '\n'
            
        except Exception as e:
            print 'Could not retrieve data for ' + ticker + '\n'

    return   
开发者ID:rutgersqfc,项目名称:Quantopian-Algorithms,代码行数:14,代码来源:stock_scraper_finished_template.py


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