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


Python Share.get_price_earnings_growth_ratio方法代码示例

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


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

示例1: fundamentalStats

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_price_earnings_growth_ratio [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

示例2: __init__

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_price_earnings_growth_ratio [as 别名]
class Stock:
    """

    """

    def __init__(self, n):
        self.name = n
        self.confidence_list = []
        self.fifty_day_moving_average = None
        self.two_hundred_day_moving_average = None
        self.price_earnings_growth_ratio = None
        self.confidence_string = None
        self.current_price = None
        self.stock = Share(self.name)

    def calculate_confidence_percentage(self):
        self.confidence_list = []
        self.confidence_list.append(sc.formula_00_is_stock_above_50_day_moving_average(self.get_current_price(), self.get_fifty_day_moving_average()))
        self.confidence_list.append(sc.formula_01_is_stock_above_200_day_moving_average(self.get_current_price(), self.get_two_hundred_day_moving_average()))
        self.confidence_list.append(sc.formula_02_pattern_guesser_confidence_for_tomorrow(self.name))

        confidence_string = ''
        for c in self.confidence_list:
            confidence_string += str(c) + ", "

        self.confidence_string = 'Confidence List: ' + confidence_string + '\tAverage Confidence: ' + str(sum(self.confidence_list) / len(self.confidence_list))

    def get_name(self):
        """TODO:...
        :return:
        """
        return self.name

    def get_current_price(self):
        if self.current_price is None:
            self.current_price = self.stock.get_price()

    def get_confidence_string(self):
        if self.confidence_string is None:
            self.calculate_confidence_percentage()
        return self.confidence_string

    def get_fifty_day_moving_average(self):
        if self.fifty_day_moving_average is None:
            self.fifty_day_moving_average = self.stock.get_50day_moving_avg()
        return self.fifty_day_moving_average

    def get_two_hundred_day_moving_average(self):
        if self.two_hundred_day_moving_average is None:
            self.two_hundred_day_moving_average = self.stock.get_200day_moving_avg()
        return self.two_hundred_day_moving_average

    def get_price_earnings_growth_ratio(self):
        if self.price_earnings_growth_ratio is None:
            self.price_earnings_growth_ratio = self.stock.get_price_earnings_growth_ratio()
        return self.price_earnings_growth_ratio
开发者ID:utarsuno,项目名称:Aggregate_Predictor,代码行数:58,代码来源:stock.py

示例3: stock_summary

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_price_earnings_growth_ratio [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

示例4: get_company_info

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_price_earnings_growth_ratio [as 别名]
 def get_company_info(ticker):
     try:
         s = Share(ticker)
         data = {
             'Market_cap': s.get_market_cap(),
             'Average_volume': s.get_avg_daily_volume(),
             'EPS': s.get_earnings_share(),
             'Short_ratio': s.get_short_ratio(),
             'PE': s.get_price_earnings_ratio(),
             'PEG': s.get_price_earnings_growth_ratio(),
         }
         return DataFetcher._extract_company_info(data)
     except YQLQueryError:
         logger.error("Company info not found for {}".format(ticker))
     except Exception as e:
         logger.error("Unexpected error occured: {}".format(e))
     return {}
开发者ID:kacperadach,项目名称:stock_market_analysis,代码行数:19,代码来源:Data_Fetcher.py

示例5: rec

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_price_earnings_growth_ratio [as 别名]
def rec(p):
	yahoo = Share(p)
	a=yahoo.get_prev_close()
	b=yahoo.get_year_high()
	c=yahoo.get_year_low()
	d=yahoo.get_open()
	e=yahoo.get_ebitda()
	f=yahoo.get_market_cap()
	g=yahoo.get_avg_daily_volume()
	h=yahoo.get_dividend_yield()
	i=yahoo.get_earnings_share()
	j=yahoo.get_days_low()
	k=yahoo.get_days_high()
	l=yahoo.get_50day_moving_avg()
	m=yahoo.get_200day_moving_avg()
	n=yahoo.get_price_earnings_ratio()
	o=yahoo.get_price_earnings_growth_ratio()
	print p
	print "Previous Close: ",a
	print "Year High",b
	print "Year Low",c
	print "Open:",d
	print "EBIDTA",e 
	print "Market Cap",f
	print "Average Daily Volume",g 
	print "Dividend Yield",h
	print "Earnings per share",i 
	print "Days Range:", j ,"-",k
	print "50 Days Moving Average",l 
	print "200 Days Moving Average",m
	print"Price Earnings Ratio", n
	print"Price Earnings Growth Ratio",o

	import MySQLdb
	db = MySQLdb.connect(host="127.0.0.1", user="root",passwd="1111", db="stocks",local_infile = 1)  
	cur=db.cursor()
	cur.execute ("""
	            INSERT INTO stockapp_info (symbol, prev_close, year_high, year_low, open_price , ebidta, market_cap, avg_daily_vol , dividend_yield, eps , days_low ,days_high, moving_avg_50, moving_avg_200, price_earnings_ratio, price_earnings_growth_ratio)
	            VALUES
	                (%s, %s, %s, %s, %s, %s, %s,%s,%s,%s,%s,%s,%s,%s,%s,%s)

	        """, (p,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o))
	db.commit() 
	cur.close()
开发者ID:rpandya1990,项目名称:Stock-Prediction-Web-Application,代码行数:46,代码来源:stockinfo.py

示例6: write_technical_files

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_price_earnings_growth_ratio [as 别名]
def write_technical_files(stock_code, start_time, end_time):
  # """ Experiment on quandl """
  # print('quandl data')
  # mydata = quandl.get("FRED/GDP")
  # print(mydata)
  # print('hello')

  # data = quandl.get("WIKI/FB.11", start_date="2014-01-01", end_date="2014-12-31", collapse="monthly", transform="diff")
  # print(data)

  stock = Share(stock_code)

  print('stock.get_info()')
  print(stock.get_info())

  print('get_price()')
  print(stock.get_price())

  print('get_change()')
  print(stock.get_change())

  print('get_stock_exchange()')
  print(stock.get_stock_exchange())

  print('get_market_cap()')
  print(stock.get_market_cap())

  print('get_book_value()')
  print(stock.get_book_value())

  print('get_ebitda()')
  print(stock.get_ebitda())

  print('get_dividend_share()')  
  print(stock.get_dividend_share())

  print('get_dividend_yield()')
  print(stock.get_dividend_yield())

  print('get_earnings_share()')
  print(stock.get_earnings_share())

  print('get_50day_moving_avg()')
  print(stock.get_50day_moving_avg())

  print('get_200day_moving_avg()')
  print(stock.get_200day_moving_avg())

  print('get_price_earnings_ratio()')
  print(stock.get_price_earnings_ratio())

  print('get_price_earnings_growth_ratio()')
  print(stock.get_price_earnings_growth_ratio())

  print('get_price_sales()')
  print(stock.get_price_sales())

  print('get_price_book()')
  print(stock.get_price_book())

  print('get_short_ratio()')
  print(stock.get_short_ratio())

  print('historical_data')
  print(stock.get_historical(start_time, end_time))

  historical_data = stock.get_historical(start_time, end_time)

  info_text = "Symbol\t" + "Stock Exchange\t" + "Price\t" + "Market Cap\t" + "Book Value\t" + "EBITDA\t" + "50d Moving Avg\t" + "100d Moving Avg\n"
  info_text += str(stock.get_info()['symbol']) + "\t" + str(stock.get_stock_exchange()) + "\t" + str(stock.get_price()) + "\t" + str(stock.get_market_cap()) + "\t" + str(stock.get_book_value()) + "\t";
  info_text += str(stock.get_ebitda()) + "\t" + str(stock.get_50day_moving_avg()) + "\t" + str(stock.get_200day_moving_avg()) + "\n";

  info_directory = '/data/info.tsv'

  write_to_file(info_directory, info_text)

  high_low_text = "date\t" + "High\t" + "Low\n"
  open_close_text = "date\t" + "Open\t" + "Close\n"
  volume_text = "date\t" + "Volume\n"

  for index, value in enumerate(historical_data):
    date = str(historical_data[len(historical_data) - 1 - index]['Date'])
    date = date.replace('-','')

    stock_high = str(historical_data[len(historical_data) - 1 - index]['High'])
    stock_low = str(historical_data[len(historical_data) - 1 - index]['Low'])

    stock_open = str(historical_data[len(historical_data) - 1 - index]['Open'])
    stock_close = str(historical_data[len(historical_data) - 1 - index]['Close'])

    stock_volume = str(int(historical_data[len(historical_data) - 1 - index]['Volume']) / 1000)

    high_low_text += date + "\t" + stock_high + "\t" + stock_low + "\n"
    open_close_text += date + "\t" + stock_open + "\t" + stock_close + "\n"
    volume_text += date + "\t" + stock_volume + "\n"

  high_low_directory = '/data/highlow.tsv'
  open_close_directory = '/data/openclose.tsv'
  volume_directory = '/data/volume.tsv'

#.........这里部分代码省略.........
开发者ID:seokhoonlee,项目名称:stock-analysis-tool,代码行数:103,代码来源:file_manager.py

示例7: str

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_price_earnings_growth_ratio [as 别名]
		print yearhigh

	if myargs.yearlow is True:
		yearlow = stock.get_year_low()
		print yearlow

	if myargs.ebitda is True:
		ebitda = stock.get_ebitda()
		print ebitda

	if myargs.ps is True:
		ps = stock.get_price_sales()
		print ps

	if myargs.peg is True:
		peg = stock.get_price_earnings_growth_ratio()
		print peg

	if myargs.percentchange is True:
		change = stock.get_change()
		getopen = stock.get_open()
		percentchange = yahoofinancecalc.getPercentChange(stock, change, getopen)
		print str(percentchange) + "%"

	if myargs.percentoffhigh is True:
		realtimequote = realtime.scraper(myargs.ticker)
		poh = yahoofinancecalc.offHigh(stock, realtimequote)
		print poh

	if myargs.percentofflow is True:
		realtimequote = realtime.scraper(myargs.ticker)
开发者ID:nhsb1,项目名称:config,代码行数:33,代码来源:yfcmd.py

示例8:

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_price_earnings_growth_ratio [as 别名]
	except:
		pass
	try:
		russell3000.set_value(s,'50 days MA',shy.get_50day_moving_avg())
	except:
		pass
	try:
		russell3000.set_value(s,'200 days MA',shy.get_200day_moving_avg())
	except:
		pass
	try:
		russell3000.set_value(s,'Price earnings ratio',shy.get_price_earnings_ratio())
	except:
		pass
	try:
		russell3000.set_value(s,'Price earnings growth ratio',shy.get_price_earnings_growth_ratio())
	except:
		pass
	try:
		russell3000.set_value(s,'Price sales',shy.get_price_sales())
	except:
		pass
	try:
		russell3000.set_value(s,'Price book',shy.get_price_book())
	except:
		pass
	try:
		russell3000.set_value(s,'Short ratio',shy.get_short_ratio())
	except:
		pass
u=datetime.now()
开发者ID:isloux,项目名称:multiscaletools,代码行数:33,代码来源:realtimeyahoo.py

示例9: view_stock

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_price_earnings_growth_ratio [as 别名]
def view_stock(request, ticker):
    if request.user.__class__.__name__ is "CustomUser":
        c_user = get_object_or_404(CustomUser, pk=request.user.pk)
        account = Account.objects.get(user=c_user)
    else:
        account = False
    stock = get_object_or_404(Stock, ticker=ticker)

    companyName = stock.ticker
    companyName = companyName.upper()
    stock = Stock.objects.get(ticker=companyName)
    namer = "'" + companyName + "'"
    ystock = Share(companyName)
    the_price = ystock.get_price()

    regex = 'Business Summary</span></th><th align="right">&nbsp;</th></tr></table><p>(.+?)</p>'
    pattern = re.compile(regex)

    root_url = urllib.urlopen("http://finance.yahoo.com/q/pr?s=" + companyName + "+Profile")
    htmltext = root_url.read()

    decoded_str = str(re.findall(pattern, htmltext)).decode("utf8")
    encoded_str = decoded_str.encode("ascii", "ignore")
    stock.description = encoded_str
    stock.description = stock.description[:-2]
    stock.description = stock.description[2:]
    stock.book_value = ystockquote.get_book_value(companyName)
    stock.change = ystockquote.get_change(companyName)
    # stock.dividend_per_share = ystockquote.get_dividend_per_share(companyName)
    # stock.dividend_yield = ystockquote.get_dividend_yield(companyName)
    stock.ebitda = ystockquote.get_ebitda(companyName)
    stock.fifty_two_week_high = ystockquote.get_52_week_high(companyName)
    stock.fifty_two_week_low = ystockquote.get_52_week_low(companyName)
    stock.market_cap = ystockquote.get_market_cap(companyName)
    stock.short_ratio = ystockquote.get_short_ratio(companyName)
    stock.stock_exchange = ystockquote.get_stock_exchange(companyName)
    stock.volume = ystockquote.get_volume(companyName)
    stock.price = ystock.get_price()
    # yahoo_finance
    stock.average_daily_volume = ystock.get_avg_daily_volume()
    stock.earnings_per_share = ystock.get_price_earnings_ratio()
    stock.fifty_day_moving_avg = ystock.get_50day_moving_avg()
    stock.two_hundred_day_moving_avg = ystock.get_200day_moving_avg()
    stock.price_book_ratio = ystock.get_price_book()
    stock.last_sale = ystock.get_price()
    stock.price_earnings_growth_ratio = ystock.get_price_earnings_growth_ratio()
    stock.price_earnings_ratio = ystock.get_price_earnings_ratio()
    stock.price_sales_ratio = ystock.get_price_sales()
    stock.save()

    vl = []
    acl = []
    hl = []
    ll = []
    cl = []
    ol = []
    days_list = []
    d = 0
    seven_days_ago = datetime.datetime.now() + datetime.timedelta(-30)
    today = datetime.datetime.now()
    days = ystockquote.get_historical_prices("GOOGL", seven_days_ago.strftime("%Y-%m-%d"), today.strftime("%Y-%m-%d"))
    for day in days.keys():
        d += 1
        date_label = datetime.datetime.now() + datetime.timedelta(-d)
        days_list.append(date_label.strftime("%b-%d"))
        day_info = days.get(day)
        vol = int(day_info.get("Volume"))
        vl.append(vol)
        adjcl = float(day_info.get("Adj Close"))
        acl.append(adjcl)
        highs = float(day_info.get("High"))
        hl.append(highs)
        lows = float(day_info.get("Low"))
        ll.append(lows)
        closes = float(day_info.get("Close"))
        cl.append(closes)
        opens = float(day_info.get("Open"))
        ol.append(opens)

    volume = vl
    lows = ll
    opens = ol
    highs = hl
    averages = acl
    closes = cl
    days_l = days_list[::-1]
    context = RequestContext(
        request,
        dict(
            account=account,
            request=request,
            stock=stock,
            volume=volume,
            lows=lows,
            highs=highs,
            opens=opens,
            closes=closes,
            averages=averages,
            days_l=days_l,
        ),
#.........这里部分代码省略.........
开发者ID:iosifvilcea,项目名称:Scrap,代码行数:103,代码来源:views.py


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