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


Python Share.get_200day_moving_avg方法代码示例

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


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

示例1: combine

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_200day_moving_avg [as 别名]
def combine(onedayago, twodaysago, threedaysago, fivedaysago, oneweekago, companyname):
    print "Analyzing data from the past few days..."
    dates = [onedayago, twodaysago, threedaysago, fivedaysago, oneweekago]
    for i in dates:
        i == i.format('YYYY-MM-DD')


    # Just gets the info and puts it into programmer friendly names
    def getclosing(date, company):
        # Thanks to stackoverflow user 'TessellatingHeckler' for helping me out with this next function! At the time dictionaries were a foreign concept to me.
        readings = company.get_historical(date, date)
        for reading in readings:
            close = reading['Close']
            return close

    company = Share(companyname)
    closingonedayago = getclosing(str(dates[0]), company)
    closingtwodaysago = getclosing(str(dates[1]), company)
    closingthreedaysago = getclosing(str(dates[2]), company)
    closingfivedaysago = getclosing(str(dates[3]), company)
    closingoneweekago = getclosing(str(dates[4]), company)
    twohundredavg = company.get_200day_moving_avg()
    fiftyavg = company.get_50day_moving_avg()
    today = company.get_price()
    decision(today, closingonedayago, closingtwodaysago, closingthreedaysago, closingfivedaysago, closingoneweekago, twohundredavg, fiftyavg)
开发者ID:robbiebarrat,项目名称:Stock_advisor,代码行数:27,代码来源:Stocks.py

示例2: __init__

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

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

示例5: write_technical_files

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

示例6:

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_200day_moving_avg [as 别名]
		short = stock.get_short_ratio()
		print short

	if myargs.peratio is True:
		pe = stock.get_price_earnings_ratio()
		print pe

	if myargs.exchange is True:
		exchange = stock.get_stock_exchange()

	if myargs.ma50 is True:
		ma50 = stock.get_50day_moving_avg()
		print ma50

	if myargs.ma200 is True:
		ma200 = stock.get_200day_moving_avg()
		print ma200

	if myargs.marketcap is True:
		marketcap = stock.get_market_cap()
		print marketcap

	if myargs.getopen is True:
		getopen = stock.get_open()
		print getopen

	if myargs.getbook is True:
		getbook = stock.get_book_value()
		print getbook

	if myargs.dividendshare is True:
开发者ID:nhsb1,项目名称:config,代码行数:33,代码来源:yfcmd.py

示例7:

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_200day_moving_avg [as 别名]
	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:
		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:
开发者ID:isloux,项目名称:multiscaletools,代码行数:33,代码来源:realtimeyahoo.py

示例8: refresh_yahoo_api_data

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_200day_moving_avg [as 别名]
 def refresh_yahoo_api_data(self):
     yahoo_data = Share(self.symbol)
     self.fifty_moving_avg = yahoo_data.get_50day_moving_avg()
     self.two_hundred_moving_avg = yahoo_data.get_200day_moving_avg()
     self.year_high = yahoo_data.get_year_high()
     self.year_low = yahoo_data.get_year_low()
开发者ID:kaisaf,项目名称:Stock-Tracker,代码行数:8,代码来源:models.py

示例9: range

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

from Parser.models import EtfInfo, EtfData, StockInfo, StockDetail



etfResult = StockInfo.objects.values('ticker', 'name')

#for etfIdx in range(0, len(etfResult)) :
tickerStr = etfResult[0]['ticker']

share = Share(tickerStr)

dateStr = share.get_trade_datetime()[0:11].replace('-','')
ma_200Str = convert(share.get_200day_moving_avg())
ma_50Str = convert(share.get_50day_moving_avg())
book_valueStr = convert(share.get_book_value())
volume_avgStr = convert(share.get_avg_daily_volume())
ebitdaStr = convert(share.get_ebitda())
dividend_yieldStr = convert(share.get_dividend_yield())
market_capStr = convert(share.get_market_cap())
year_highStr = convert(share.get_year_high())
year_lowStr = convert(share.get_year_low())

print tickerStr, dateStr, ma_200Str, ma_50Str, book_valueStr, volume_avgStr, ebitdaStr, dividend_yieldStr, market_capStr, year_highStr, year_lowStr


# print share.get_change()
# print share.get_days_high()
# print share.get_days_low()
开发者ID:quantosauros,项目名称:MAProject,代码行数:32,代码来源:testYahooApi.py

示例10: len

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_200day_moving_avg [as 别名]
        if len(ticker) == 0:
            continue
        stock = Share(ticker)
        stock.refresh()
        change = (float(stock.get_price()) - float(stock.get_prev_close()))/float(stock.get_prev_close()) 
        change = round(change *100.0, 2)
        if change > 0.0:
            change= '+' + str(change)
        else:    
            change =str(change)
          
        line = ticker.ljust(7) 
        line += stock.get_price().ljust(9)+ change.ljust(8)+ stock.get_volume().ljust(11) + \
            str(round(float(stock.get_volume())/float(stock.get_avg_daily_volume())*100.0)).ljust(8) +\
            stock.get_open().ljust(10)+ \
            stock.get_days_low().ljust(10)+ \
            stock.get_days_high().ljust(10)+ \
            stock.get_year_low().ljust(10)+ \
            stock.get_year_high().ljust(10)
        line = line + str(stock.get_market_cap()).ljust(11) + \
            str(stock.get_price_earnings_ratio()).ljust(8)+\
            stock.get_50day_moving_avg().ljust(10) +\
            stock.get_200day_moving_avg().ljust(10) 
        print(line)    
    except Exception as e:
        print("Exception error:", str(e))
        traceback.print_exc()
    i+=1

#you get get a spy.txt and then filter everything by yourself
开发者ID:carlwu66,项目名称:stock,代码行数:32,代码来源:old_yahoo.py

示例11: view_stock

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_200day_moving_avg [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_200day_moving_avg方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。