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


Python Share.get_volume方法代码示例

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


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

示例1: updateInfos

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

示例2: get_stock_price_and_volume

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_volume [as 别名]
def get_stock_price_and_volume(symbol, start_date, end_date, dates):
	share = Share(symbol)
	hist_data = share.get_historical(start_date, end_date)
	hist_data.reverse()
	volume = []
	price = []
	i = 0
	for d in dates:
		if i < len(hist_data):
			if (hist_data[i]['Date'] == d):
				# Weekday
				price.append(hist_data[i]['Close'])
				volume.append(hist_data[i]['Volume'])
				i += 1
			else:
				# Weekend
				price.append(0)
				volume.append(0)
		else:
			# Get the current price and volume instead from historical data
			price.append(share.get_price())
			volume.append(share.get_volume())
	if len(dates) != len(volume) and len(dates) != len(price):
		print 'Dates and volume and/or price lists are not of same lenght!'
	return [price, volume]
开发者ID:benzemann,项目名称:TwitterStockAnalyzer,代码行数:27,代码来源:stock_data_downloader.py

示例3: data_frame_companies_amount

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_volume [as 别名]
    def data_frame_companies_amount(list_companies,porcentaje_volumnen_diario,max_var_pvd):

        # Es una funcion que toma una lista de empresas (codificadas por yahoo.finance), el porcentaje (tanto por uno)
        # sobre el volumen diario a considerar y la maxima variacion en porcentaje (tanto por uno) sobre este porcentaje.



        list_index=["ask5","ask4","ask3","ask2","ask1","bid1","bid2","bid3","bid4","bid5"]
        companies_amount=pd.DataFrame(index=list_index)
        for i in list_companies:

            company = Share(i)
            volume=company.get_volume()
            cantidad_per_ba=float(company.get_avg_daily_volume())*porcentaje_volumnen_diario
            num=cantidad_per_ba*max_var_pvd # variacion maxima respecto al 1% del volumen diario
            vec_list_amount=[]

            for h in range(0,len(list_index)):

                vec_list_amount.append(round(cantidad_per_ba+np.random.randint(-num,num,1)))

            vec_amount=np.array(vec_list_amount)
            companies_amount[i]=vec_amount   

        return companies_amount
开发者ID:romcra,项目名称:settings_package,代码行数:27,代码来源:init.py

示例4: createInfos

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

示例5: get_quote

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

示例6: stock_summary

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

示例7: process_symbol

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_volume [as 别名]
def process_symbol(net, symbol):
 settings = load(symbol+'.set')
 if(len(settings)==0):
  return
 yahoo = Share(symbol)
 mp = 2.0*settings['maxc']
 p = float(yahoo.get_price())/mp 
 d = yahoo.get_trade_datetime()
 wd = datetime.datetime.strptime(d[:10],"%Y-%m-%d").weekday()/6.0 
 v = float(yahoo.get_volume())/(2*settings['maxv'])
 ts = UnsupervisedDataSet(3,) 
 ts.addSample((wd,p,v),)
 ret = net.activate([wd,p,v])
 print "IK, K, V ", ret
开发者ID:ZwenAusZwota,项目名称:aktien,代码行数:16,代码来源:process.py

示例8: fetch

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_volume [as 别名]
def fetch():
    for share in Share.objects.all():
        try:
            sh = YahooShare(share.share)
        except:
            print('exception occurred while fetching stock...')
            continue

        sv, created = ShareValue.objects.get_or_create(share=share, price=sh.get_price(), open=sh.get_open(),
                                                       volume=sh.get_volume(),
                                                       time=datetime.strptime(sh.get_trade_datetime(),
                                                                              '%Y-%m-%d %H:%M:%S %Z%z'))
        if not created:
            print('%s market is closed' % sv.share)
开发者ID:corallus,项目名称:algotrading,代码行数:16,代码来源:utils.py

示例9: getStockInfoNow

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_volume [as 别名]
def getStockInfoNow(request):
	if request.method == 'GET':
		sid = request.GET['sid']
		try:
			s = Share(sid+'.TW')
			p = float(s.get_price())
			c = float(s.get_change())
			v = float(s.get_volume())/1000
			pc = float(s.get_prev_close())
		except:
			return JsonResponse({"success": 'false', 'error': 'wrong sid'})
		return JsonResponse({'price': p, 'change': c, 'volume': v, 'prev_close': pc})
	else:
		return JsonResponse({"success": 'false', 'error': 'wrong method'})
开发者ID:jlee58,项目名称:finance_web,代码行数:16,代码来源:views.py

示例10: realTime

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_volume [as 别名]
def realTime(request):
    company_name = str(request.GET.get('name'))
    stock = Share(company_name)
    rowlist = []
    d = collections.OrderedDict()
    cursor = connection.cursor()
    cursor.execute('select max(id) from stockPrediction_onedaystock')
    idd = cursor.fetchone()[0]
    print idd
    d["id"] = idd
    d["time"] = datetime.now()
    d["price"] = stock.get_price()
    d["volume"] = stock.get_volume()
    rowlist.append(d)
    return Response(rowlist)
开发者ID:Weilin1992,项目名称:Web-Final-Project,代码行数:17,代码来源:views.py

示例11: tesfile

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

示例12: get_today_stock_data

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_volume [as 别名]
 def get_today_stock_data(ticker):
     try:
         s = Share(ticker)
         data = {
             'Open': float(s.get_open()),
             'Close': float(s.get_prev_close()),
             'High': float(s.get_days_high()),
             'Low': float(s.get_days_low()),
             'Volume': int(s.get_volume()),
             'Date': datetime.date.today(),
         }
         return data
     except YQLQueryError:
         logger.error("Daily data not found for {}".format(ticker))
     except Exception as e:
         logger.error("Unexpected error occurred: {}".format(e))
     return {}
开发者ID:kacperadach,项目名称:stock_market_analysis,代码行数:19,代码来源:Data_Fetcher.py

示例13: main

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

    PATH_OF_DATA = 'data'
    error_log_file = open('error.log', 'a')

    index_lists = [ f[:-4] for f in listdir(PATH_OF_DATA) if f[-4:] == '.csv' ]

    skipFlag = True if len(sys.argv) > 1 else False
    tillFlag = True if len(sys.argv) > 2 else False
    for stock_index in index_lists:
        if skipFlag:
            if stock_index != sys.argv[1]:
                continue
            else:
                skipFlag = False
        if tillFlag:
            if stock_index == sys.argv[2]:
                break

        filename = join(PATH_OF_DATA, stock_index+'.csv')
        if isfile(filename):# 如果已經有檔案,就讀出最後一行然後插入在後面
            lastline = get_last_row(filename)
            print 'lastline = ', lastline
            try:
                st = Share(stock_index+'.tw')

                if not time_after(lastline[0], st.get_trade_datetime()[:10]):
                    print 'time : ', st.get_trade_datetime()[:10]
                    fo = open(filename, 'ab')
                    cw = csv.writer(fo, delimiter=',')

                    # 更新當天資料
                    cw.writerow([st.get_trade_datetime()[:10], st.get_open(), st.get_days_high(),
                                     st.get_days_low(), st.get_price(), st.get_volume(), '0.0'])
                    print "更新一筆!"
                else:
                    print "不需要更新"

            except:
                print stock_index, "update error!"
                error_log_file.write('%s, Update Error\n' % (stock_index))
开发者ID:shihyu,项目名称:crawl-stock,代码行数:43,代码来源:crawl.py

示例14: fetch_current_data

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_volume [as 别名]
 def fetch_current_data(self, sym):
     ts = get_latest_trading_date(get_cur_time())
     if ts in self.datasets_daily[sym].keys() or ts > self.endDate:
         return
     try:
         sdata = Share(sym)
         gquote = gQuotes(sym)
     except:
         # live with the fact that data from the most recent day is missing
         return
     self.datasets_daily[sym][ts] = t = {}
     t['Date']  = '3000-01-01' #debugging purposes, so we know this is current. This won't be saved to file
     t['High']  = float(sdata.get_days_high())
     t['Low']   = float(sdata.get_days_low())
     t['Open']  = float(sdata.get_open())
     # t['Close'] = sdata.get_price()
     t['Close'] = float(gquote[0]['LastTradePrice']) # use google data for latest 'Close', which is more accurate
     t['Volume'] = float(sdata.get_volume())
     for k in t.keys():
         if t[k] == None:
             raise Exception('missing most recent daily', sym)
开发者ID:codelol,项目名称:pstock,代码行数:23,代码来源:usdata.py

示例15: displayStockQuotes

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import get_volume [as 别名]
def displayStockQuotes(symbols, seconds):
    """
    Display each symbol's price, volume and percent change for seconds

    :param: symbols: List of stock symbols in Yahoo format.  E.g. 'AMZN' or 'BRK-B' (NOTE: not 'BRK.B').
    :param: seconds: Number of seconds to display each stock.
    
    # The following Adafruit_CharLCD library is found here: 
    # https://github.com/adafruit/Adafruit_Python_CharLCD 
    # See this tutorial for a hello world Python/Raspberry Pi/LCD tutorial:
    # https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/python-code
    """
 
    lcd = Adafruit_CharLCD()
    while True:
      for symbol in symbols:
        stock = Share(symbol)
        lcd.clear()
        lcd.message(symbol + ":  $")	
        lcd.message(stock.get_price() + "\n")
        volume = stock.get_volume()
        change = stock.get_change()
        lcd.message(change + "|")
      
        open = stock.get_open()
      
      if type(open) is str and type(change) is str:
        percentChange = float(change) / float(open)
        # format percent change in human-readable format: "1%" instead of ".01"
	lcd.message("{0:.00%}".format(percentChange))
      else:
        lcd.message("?")

      if volume:
        lcd.message("|" + volume)
      else:
        lcd.message("|?")

      sleep(seconds) # Delay between each stock/symbol			
开发者ID:JohnAllen,项目名称:PiStockTicker,代码行数:41,代码来源:pi_stock_ticker.py


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