本文整理汇总了Python中yahoo_finance.Share.get_earnings_share方法的典型用法代码示例。如果您正苦于以下问题:Python Share.get_earnings_share方法的具体用法?Python Share.get_earnings_share怎么用?Python Share.get_earnings_share使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yahoo_finance.Share
的用法示例。
在下文中一共展示了Share.get_earnings_share方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SearchPERatio
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_earnings_share [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())
示例2: report_current_from_yahoo
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_earnings_share [as 别名]
def report_current_from_yahoo(symbol):
yahoo = Share(symbol)
price_cur = yahoo.get_price()
eps = yahoo.get_earnings_share()
pe = yahoo.get_price_earnings_ratio()
print 'yahoo: price=%s eps=%s, pe=%s'%(price_cur, eps, pe)
示例3: fundamentalStats
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_earnings_share [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.")
示例4: createInfos
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_earnings_share [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.')
示例5: SelectStock
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_earnings_share [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")
示例6: tesfile
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_earnings_share [as 别名]
def tesfile(self,event):
count =0
f = open("export.csv","r")
for row in csv.reader(f):
# print(row)
count+=1
if count >=4 and (row[2]!='-' and float(row[2])<=self.TargetPERatio):
QueryPrice=Share(row[0]+'.TW')
# volumetemp = self.InTimeObject.GetInTimeStockInfo(row[0])
# print(volumetemp)
if QueryPrice.get_earnings_share()!=None and float(QueryPrice.get_earnings_share())>=self.TargetEPS and float: #float(QueryPrice.get_earnings_share())>=self.TargetEPS:
if float(QueryPrice.get_volume())>=self.TargetVolume and float(QueryPrice.get_price())<=self.TargetPrice:
information = row[0] + row[1]+"\t" + QueryPrice.get_earnings_share() +" "+ QueryPrice.get_volume()+" " + QueryPrice.get_price()
self.ThreemenBox.insert(END,information)
if count==50:
break
示例7: updateInfos
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_earnings_share [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.')
示例8: stock_summary
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_earnings_share [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})
示例9: get_company_info
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_earnings_share [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 {}
示例10: rec
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_earnings_share [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()
示例11:
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_earnings_share [as 别名]
print getopen
if myargs.getbook is True:
getbook = stock.get_book_value()
print getbook
if myargs.dividendshare is True:
getdiv = stock.get_dividend_share()
print getdiv
if myargs.dividendyield is True:
dividendyield = stock.get_dividend_yield()
print dividendyield
if myargs.eps is True:
eps = stock.get_earnings_share()
print eps
if myargs.dayh is True:
dayhigh = stock.get_days_high()
print dayhigh
if myargs.dayl is True:
daylow = stock.get_days_low()
print daylow
if myargs.yearhigh is True:
yearhigh = stock.get_year_high()
print yearhigh
if myargs.yearlow is True:
示例12:
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_earnings_share [as 别名]
except:
pass
try:
russell3000.set_value(s,'Ebitda',shy.get_ebitda())
except:
pass
try:
russell3000.set_value(s,'Dividend share',shy.get_dividend_share())
except:
pass
#try:
# russell3000.set_value(s,'Divident yield',shy.get_dividend_yield())
#except:
# pass
try:
russell3000.set_value(s,'Earnings share',shy.get_earnings_share())
except:
pass
try:
russell3000.set_value(s,'Year high',shy.get_year_high())
except:
pass
try:
russell3000.set_value(s,'Year low',shy.get_year_low())
except:
pass
try:
russell3000.set_value(s,'50 days MA',shy.get_50day_moving_avg())
except:
pass
try:
示例13: Share
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_earnings_share [as 别名]
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 21 15:17:46 2016
@author: SMALLON
"""
from yahoo_finance import Share
yahoo = Share('YHOO')
goog = Share('GOOG')
print(yahoo.get_ebitda())
print(yahoo.get_earnings_share())
print(yahoo.get_price_book())
print(goog.get_ebitda())
print(goog.get_earnings_share())
print(goog.get_price_book())
from yahoo_finance import Share
IBB = Share('IBB')
print(IBB.get_ebitda())
from yahoo_finance import Share
li = ['YHOO','GOOG']
yahoo = Share('YHOO')
goog = Share('GOOG')
print(yahoo.get_book_value())
for i in li:
t = Share(i)
print(i)
print(t.get_book_value())
示例14: Symbol
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_earnings_share [as 别名]
class Symbol(object):
def __init__(self, symbol, s_date=None, e_date=None):
self.log=Logging()
self.name=symbol
self.created=datetime.datetime.utcnow()
self.log.info("created {}".format(self.name))
try:
self.share=Share(symbol)
except:
self.log.error("platform is offline or not connecting")
if s_date and e_date:
self.begin=s_date
self.end=e_date
try:
self.share=Share(symbol)
self.data=self.share.get_historical(self.begin, self.end)
self.log.refresh("{} data collected".format(self.name))
except:
self.log.error("platform is offline or not connecting")
def refresh_data(self, s_date=None, e_date=None):
if s_date and e_date:
try:
share=Share(self.name)
self.begin=s_date
self.end=e_date
share.get_historical(s_date, e_date)
self.log.refresh("{} data collected".format(self.name))
except:
self.log.error("platform is offline or not connecting")
def market_cap(self):
try:
self.market_cap = self.share.get_market_cap()
self.log.info("{} market cap refreshed".format(self.name))
except:
self.log.error("platform is offline or not connecting")
def earnings_per_share(self):
try:
self.eps = self.share.get_earnings_share()
self.log.info("{} eps refreshed".format(self.name))
except:
self.log.error("platform is offline or not connecting")
def moving_average_50(self):
try:
self.moving_average_50 = self.share.get_50day_moving_average()
self.log.info("{} 50 day moving ave refreshed".format(self.name))
except:
self.log.error("platform is offline or not connecting")
#implement TODO
def nday_moving_average(self, n):
try:
self.moving_average_n = None
self.log.info("{} {} day moving ave refreshed".format(self.name, n))
except:
self.log.error("platform is offline or not connecting")
def price_earnings_ratio(self):
try:
self.price_to_earnings = self.share.get_price_earnings_ratio()
self.log.info("{} price to earnings refreshed".format(self.name))
except:
self.log.error("platform is offline or not connecting")
def book_value(self):
try:
self.book = self.share.get_price_book()
self.log.info("{} book value refreshed".format(self.name))
except:
self.log.error("platform is offline or not connecting")
def year_high(self):
try:
self.year_high = self.share.get_change_from_year_high()
self.log.info("{} year high change refreshed".format(self.name))
except:
self.log.error("platform is offline or not connecting")
def year_low(self):
try:
self.year_low = self.share.get_change_from_year_low()
self.log.info("{} year low change refreshed".format(self.name))
except:
self.log.error("platform is offline or not connecting")
def target_price(self):
try:
self.year_target = self.share.get_change_from_year_high()
self.log.info("{} year target change refreshed".format(self.name))
except:
self.log.error("platform is offline or not connecting")
def year_range(self):
try:
#.........这里部分代码省略.........
示例15: Share
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_earnings_share [as 别名]
import glob, pandas as pd
from yahoo_finance import Share
res = []
for f in glob.glob('data/*.csv'):
market = f.replace("data/","").replace(".csv","")
df = pd.read_csv(f)
for line in df.iterrows():
res.append((market, line[1].Symbol, line[1].Name))
for (market,symbol,name) in res:
if market=='nyse':
x = Share(symbol)
print x.get_book_value()
print x.get_ebitda()
print x.get_earnings_share()
print x.get_price_sales()