本文整理汇总了Python中yahoo_finance.Share.get_market_cap方法的典型用法代码示例。如果您正苦于以下问题:Python Share.get_market_cap方法的具体用法?Python Share.get_market_cap怎么用?Python Share.get_market_cap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yahoo_finance.Share
的用法示例。
在下文中一共展示了Share.get_market_cap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_quote
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_market_cap [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 '-'
}
示例2: find_quote
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_market_cap [as 别名]
def find_quote(word):
"""Given an individual symbol,
find and return the corresponding financial data
word -- the symbol for which you're finding the data (ex. "GOOG")
"""
cleanword=re.sub('[@<>]', '', word)
share = Share(cleanword)
price = share.get_price()
if price != None:
# Extract data
day_high = share.get_days_high()
day_low = share.get_days_low()
market_cap = share.get_market_cap()
year_high = share.get_year_high()
year_low = share.get_year_low()
yoy = calculate_YoY(share)
output_string = ('*Stock*: \'{}\' \n*Current Price*: ${} \n*Day Range*: '
'${} - ${} \n*52 Wk Range*: ${} - ${} \n*YoY Change*: {}\n*Market Cap*: '
'${}').format(word.upper(), str(price), str(day_low), str(day_high),
str(year_low), str(year_high), str(yoy), str(market_cap))
else:
output_string = "Can't find a stock with the symbol \'" + cleanword.upper() + "\'"
return output_string
示例3: get_quote
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_market_cap [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 '-'
}
示例4: stock_summary
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_market_cap [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})
示例5: render_comment
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_market_cap [as 别名]
def render_comment(tickers):
for ticker in sorted(tickers):
stk = Share(ticker)
now = datetime.now()
print '''### %s\n
=======\n
* Price: %s
* Market Cap: %s\n
######*as of %s via [Openfolio](http://www.openfolio.com)*
''' % (ticker.upper(), stk.get_price(), stk.get_market_cap(), now.strftime('%Y/%m/%d %H:%M:%S'))
示例6: get_one_stock
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_market_cap [as 别名]
def get_one_stock(thread_id, tickers, good):
for ticker in tickers:
try:
stock = Share(ticker['symbol'])
a = stock.get_open()
#print(thread_id, ":", ticker['symbol'], a, dir(stock))
cap = stock.get_market_cap()
if 'B' in cap:
print(ticker['symbol'], cap)
good.append(ticker['symbol'])
except Exception as e:
pass
示例7: get_company_info
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_market_cap [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 {}
示例8: generate_comment
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_market_cap [as 别名]
def generate_comment(tickers):
"""
Generate text for a comment given the ticker names
"""
strings = []
for ticker in sorted(tickers):
stk = Share(ticker)
now = datetime.now()
strings.append('''
### {}
=======
* Price: {}
* Market Cap: {}
######*as of {} via [Openfolio](http://www.openfolio.com)*
'''.format(ticker.upper(), stk.get_price(), stk.get_market_cap(),
now.strftime('%Y/%m/%d %H:%M:%S')))
return "\n".join(strings)
示例9: get_one_stock
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_market_cap [as 别名]
def get_one_stock(thread_id, tickers, good, big, small):
for ticker in tickers:
try:
stock = Share(ticker['symbol'])
print(thread_id, ":", ticker['symbol'])
cap = stock.get_market_cap()
if 'B' in cap:
position = cap.find('B')
big.append(float(cap[:position]) *1000000000.0)
print(ticker['symbol'], cap)
good.append(ticker['symbol'])
if 'M' in cap:
position = cap.find('M')
small.append(float(cap[:position]) *1000000.0)
print(ticker['symbol'], cap)
except Exception as e:
pass
示例10: rec
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_market_cap [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: solar_value
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_market_cap [as 别名]
def solar_value(myString):
print(myString)
Ticker = input("What's the ticker symbol of solar company?")
stock_ticker = Share(Ticker)
print("Now lets figure out how valuable this company is")
print("Market Capital is: ")
market_cap = (stock_ticker.get_market_cap())
print(market_cap)
market_cap_num = str(market_cap[:-1])
#print(market_cap_num)
stock_price = stock_ticker.get_price()
share_count = (float(market_cap_num) / float(stock_price))
print("~Share Count is: ")
print(share_count)
solar_output = input("How much gigiwatt does " + Ticker + " output per year?")
solar_output_num = float(solar_output)
print(solar_output_num)
value = (float(market_cap_num) / float(solar_output_num))
print("The value of this solar company as an investment is: ")
print("%.4f" % value)
print("1.0 being strong buy and .01 being strong sell")
print("-For Billion market capital companies, move decimal over 3 places")
示例12: getStockInfo
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_market_cap [as 别名]
def getStockInfo():
messageBody = request.values.get('Body')
try:
"""Splitting the text input into action and ticker"""
actionMessage = messageBody.split(" ")[0]
stockTicker = messageBody.split(" ")[1].upper()
"""Using the Yahoo api to respond to user requests"""
stock = Share(stockTicker)
if actionMessage.upper() == "QUOTE":
message = "Last Trading Price: "+ stock.get_price()
elif actionMessage.upper() == "VOLUME":
message = "Last Trading VOLUME: "+ stock.get_volume()
elif actionMessage.upper() == "MCAP":
message = "MarketCap: "+ stock.get_market_cap()
elif actionMessage.upper() == "EBITDA":
message = "EBITDA: "+ stock.get_ebitda()
except:
message = "Wrong input, please try again"
resp = twilio.twiml.Response()
resp.sms(message)
return str(resp)
示例13: main
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_market_cap [as 别名]
def main():
# 1. get the time
day = Time.get_utc_day()
hours_mins = Time.get_utc_hours_minutes()
# 1. Get all the list of stocks
stocks = base.managers.stock_manager.get_many()
# 2. go through stock and update the desired values
for stock in stocks:
ticker = stock.get('ticker')
try:
# 2.1 Get the info from the yahoo API
updated_stock = Share(ticker)
except:
print "-->Failed to update: %s with Yahoo API" % ticker
continue
price = updated_stock.get_price()
open = updated_stock.get_open()
days_high = updated_stock.get_days_high()
days_low = updated_stock.get_days_low()
year_high = updated_stock.get_year_high()
year_low = updated_stock.get_year_low()
volume = updated_stock.get_volume()
market_cap = updated_stock.get_market_cap()
pe_ratio = updated_stock.get_price_earnings_ratio()
div_yield = updated_stock.get_dividend_yield()
change = updated_stock.get_change()
change_percent = updated_stock.data_set.get('ChangeinPercent')
# 2.2 Get the stock body
stock_body = stock.get('body')
stock_price = {hours_mins: price}
if stock_body:
# 1. Get the stock info for the day:
stock_info = stock_body.get(day)
if stock_info:
stock_price = stock_info.get('price')
stock_price.update({hours_mins: price})
else:
stock_body = {}
# 2.2.4 update the stock info dict
stock_info = {'price': stock_price}
stock_info.update({'open': open})
stock_info.update({'days_high': days_high})
stock_info.update({'days_low': days_low})
stock_info.update({'year_high': year_high})
stock_info.update({'year_low': year_low})
stock_info.update({'volume': volume})
stock_info.update({'market_cap': market_cap})
stock_info.update({'pe_ratio': pe_ratio})
stock_info.update({'div_yield': div_yield})
stock_info.update({'change': change})
stock_info.update({'change_percent': change_percent})
# update the stock body
stock_body.update({day: stock_info})
stock.body = stock_body
# 3. update the stock in the DB
try:
base.managers.stock_manager.update_one(stock)
except:
print "-->Failed to update: %s in DB" % ticker
continue
示例14:
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_market_cap [as 别名]
except:
pass
try:
russell3000.set_value(s,'Volume',shy.get_volume())
except:
pass
try:
russell3000.set_value(s,'Open',shy.get_open())
except:
pass
try:
russell3000.set_value(s,'Average daily volume',shy.get_avg_daily_volume())
except:
pass
try:
russell3000.set_value(s,'Market cap',shy.get_market_cap())
except:
pass
try:
russell3000.set_value(s,'Book value',shy.get_book_value())
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:
示例15: open
# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_market_cap [as 别名]
import csv
import time
Symbol = []
with open('Screen2_res.csv', newline='') as csv_file:
reader = csv.reader(csv_file)
for row in reader:
Symbol.append(row[0])
i = 0
with open('Screen2_3_res.csv', 'w', newline='') as f:
writer = csv.writer(f)
writer.writerow(['Symbol', 'Price', '1Y_low', 'Standard deviation', 'Marcket cap'])
while i < len(Symbol):
print(i/len(Symbol)*100)
# print(Share(i).get_market_cap())
# print (Pre_Process.str2float(Share(i).get_market_cap()))
try:
temp = Share(Symbol[i])
cur = float(temp.get_price())
low = float(temp.get_year_low())
if (cur-low)/low < 3/100:
writer.writerow([Symbol[i], cur, low, (cur-low)/low*100, temp.get_market_cap()])
except ConnectionError:
print('Sleep')
time.sleep(10)
except AttributeError or KeyError:
pass
i += 1