• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python ystockquote.get_all函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中ystockquote.get_all函数的典型用法代码示例。如果您正苦于以下问题:Python get_all函数的具体用法?Python get_all怎么用?Python get_all使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: handle

def handle(text, mic, profile):
    """
        Responds to user-input, typically speech text, with a summary of
        the day's top news headlines, sending them to the user over email
        if desired.

        Arguments:
        text -- user-input, typically transcribed speech
        mic -- used to interact with the user (for both input and output)
        profile -- contains information related to the user (e.g., phone
                   number)
    """
    mic.say("Getting Stock Info")
    try:
        output = ''
        for symbol in profile['stocks']:
            print symbol
            stock_info = ys.get_all(symbol)
            print stock_info
            current_out = symbol + " Current Price is " + stock_info['price'] + \
            " with a daily change of " + stock_info['change'] + " ... "
            print current_out
            output = output + current_out
        mic.say(output)
    except:
        mic.say("Error retrieving stocks")
开发者ID:computercolinx,项目名称:jasper-client,代码行数:26,代码来源:Stocks.py


示例2: percent_change

    def percent_change(self):
        tick_data = []
        repull_all = raw_input("Would you like to pull ticker data? (Y/N): ")
        ask_print = raw_input("Show after pull? (Y/N): ")
        if "y" in repull_all:
            pbar = ProgressBar()
            for ticker in pbar(self.ticker_list):
                # print str(ticker_list.index(ticker) + 1) + ' / ' + str(len(ticker_list)) + '  ' + str((float(ticker_list.index(ticker) + 1) / len(ticker_list))) + '%'

                try:
                    tick_data = ysq.get_all(ticker)
                    percentage = (
                        float(tick_data["change"]) / (float(tick_data["price"]) - float(tick_data["change"]))
                    ) * 100

                    if percentage > 0:
                        self.rising.append([ticker, tick_data["price"]])
                    if percentage > 3:
                        self.rising_three.append([ticker, tick_data["price"]])
                    if percentage < 0:
                        self.dipping.append([ticker, tick_data["price"]])
                    if percentage < -3:
                        self.dipping_three.append([ticker, tick_data["price"]])

                except Exception, e:
                    # print "Data Pull Error For: " + str(ticker)
                    self.error_list.append(ticker)
                    pass
            self.write_cache()
开发者ID:4tified,项目名称:stock_screener,代码行数:29,代码来源:screener.py


示例3: fetchQuotes

def fetchQuotes(sym, start=FROM_DATE, end=CURRENT_DATE):
    his = None
    data = None
    try:
        # print start, end
        data = ystockquote.get_historical_prices(sym, start, end)
    except Exception:
        print "Please check the dates. Data might not be available. 404 returned"

        # 404 due to data yet not available
    if data:
        his = DataFrame(collections.OrderedDict(sorted(data.items()))).T
        his = his.convert_objects(convert_numeric=True)
        his.index = pd.to_datetime(his.index)
        his.insert(0, 'symbol', sym, allow_duplicates=True)
        # insert the date as dataframe too
        his.insert(1, 'date', his.index)
        # his.columns = getColumns('stock_quote_historical')   # Removing as db dependency is removed
        his.columns = getColumnsNoSql('stock_quote_historical')

    daily = ystockquote.get_all(sym)
    # print daily
    # persist(his, daily, sym, end)

    return his, daily
开发者ID:Sandeep-Joshi,项目名称:stocks-comparison,代码行数:25,代码来源:Project.py


示例4: stock

def stock(bot, trigger):
  if not trigger.group(2):
    bot.reply("Please enter a stock ticker. Ex. TWTR")
  else:
    ticker = trigger.group(2).upper()
    s = ystockquote.get_all(ticker)
    bot.reply("%s %s, Price: $%s, Change: %s, Volume: %s, 52 Week High: $%s. " % (ticker, s['stock_exchange'], s['price'], s['change'], s['volume'], s['52_week_high']))
开发者ID:kiddzero,项目名称:williebot,代码行数:7,代码来源:stock.py


示例5: main

def main():
    # ticker_file = "input/tickers.txt"
    # bucket_name = "edgarsentimentbucket"

    # conn = S3Connection(argv[1], argv[2])
    # path_bucket = conn.get_bucket(bucket_name)
    # k = Key(path_bucket)
    # k.key = ticker_file
    # pathfile = k.get_contents_as_string()
    # try:
    #     lines = pathfile.split('\n')
    # except AttributeError:
    #     lines = pathfile

    
    try:
        print "started"
        # for linie in open(ticker_file, "r"):
        for linie in sys.stdin:
            try:
                print linie
                ticker_arr = linie.split('\t')
                curr_ticker = ticker_arr[1]
                curr_cik = ticker_arr[2]
                curr_date = ticker_arr[3]
                if not '-' in curr_date:
                    curr_date = curr_date[0:4] + '-' + curr_date[4:6] + '-' + curr_date[6:8]
                curr_date = curr_date.strip()
                curr_date_obj = crteDateObj(curr_date)
                yest_date_obj = curr_date_obj - timedelta(days=1)
                yest_date = crteDateStr(yest_date_obj)
                try:
                    price_dict = ystockquote.get_historical_prices(curr_ticker, yest_date, curr_date)
                    curr_close = price_dict[curr_date]['Close']
                    curr_adj_close = price_dict[curr_date]['Adj Close']
                    curr_open = price_dict[curr_date]['Open']
                    yest_close = price_dict[yest_date]['Close']
                    yest_adj_close = price_dict[yest_date]['Adj Close']
                    yest_open = price_dict[yest_date]['Close']
                except:
                    curr_close = "NA"
                    curr_adj_close = "NA"
                    curr_open = "NA"
                    yest_close = "NA"
                    yest_adj_close = "NA"
                    yest_open = "NA"

                try:
                    all_dict = ystockquote.get_all(curr_ticker)
                    curr_mkt_cap = all_dict['market_cap']
                except:
                    curr_mkt_cap = "NA"

                print curr_ticker + '\t' + curr_cik + '\t' + curr_date + '\t' + curr_open + '\t' + \
                 curr_close + '\t' + curr_adj_close + '\t' + yest_open + '\t' + yest_close + '\t' + \
                 yest_adj_close + '\t' + curr_mkt_cap
            except:
                print "bad"
    except:
        print "didn't start"
开发者ID:rsoni1,项目名称:edgar,代码行数:60,代码来源:get_quotes_emr.py


示例6: test_get_all_alignment

 def test_get_all_alignment(self):
     """ Compare bulk 'all_info' values to individual values.
     Currently broken due to misalignment from invalid CSV in
     fields: f6, k3, and maybe j2, a5, b6.
     """
     symbol = 'GOOG'
     all_info = ystockquote.get_all(symbol)
     self.assertIsInstance(all_info, dict)
     self.assertEquals(
         all_info['previous_close'],
         ystockquote.get_previous_close(symbol))
     self.assertEquals(
         all_info['volume'],
         ystockquote.get_volume(symbol))
     self.assertEquals(
         all_info['bid_realtime'],
         ystockquote.get_bid_realtime(symbol))
     self.assertEquals(
         all_info['ask_realtime'],
         ystockquote.get_ask_realtime(symbol))
     self.assertEquals(
         all_info['last_trade_price'],
         ystockquote.get_last_trade_price(symbol))
     self.assertEquals(
         all_info['today_open'],
         ystockquote.get_today_open(symbol))
     self.assertEquals(
         all_info['todays_high'],
         ystockquote.get_todays_high(symbol))
     self.assertEquals(
         all_info['last_trade_date'],
         ystockquote.get_last_trade_date(symbol))
开发者ID:jplehmann,项目名称:ystockquote,代码行数:32,代码来源:test_ystockquote.py


示例7: get

    def get(self):
        stock_name = self.request.path[7:]
        # Checking if request is from valid user
        if 'HMAC' not in self.request.headers:
            self.request.headers['HMAC'] = None
        hmac_sign = self.request.headers['HMAC']
        if 'PKEY' not in self.request.headers:
            self.request.headers['PKEY'] = None
        public_key = self.request.headers['PKEY']
        data_dict = {'stock': stock_name}
        response = {}
        if not is_valid_user_request(hmac_sign,
                                     public_key,
                                     data_dict):
            response['status'] = False
            response['unathorized'] = True
            self.response.out.write(json.dumps(response))
            return

        response["name"] = stock_name
        try:
            if len(stock_name) < 1:
                raise Exception()
            details = ystockquote.get_all(stock_name)
            response["status"] = True
            response["details"] = details
        except:
            response["status"] = False
        self.response.out.write(json.dumps(response))
开发者ID:abhishek-anand,项目名称:tradegame,代码行数:29,代码来源:main.py


示例8: getStockLine

 def getStockLine (self, stocks):
     stock_list = stocks.split()
     stockLine = ""
     for stock in stock_list:
         stockData = ystockquote.get_all(stock)
         stockLine += stock + '[' + stockData['price'] + '/' + stockData['change'] + "] "
     return stockLine
开发者ID:barfle,项目名称:signboard,代码行数:7,代码来源:signboard.py


示例9: get_quote

 def get_quote(self):
     if self.quote is None:
         try:
             self.quote = ystockquote.get_all(self.symbol)
         except:
             self.quote = None
     return self.quote
开发者ID:arminbhy,项目名称:stock-market-analysis,代码行数:7,代码来源:ticker.py


示例10: compact_quote

def compact_quote(symbol):
    a = y.get_all(symbol)
    try:
        L52 = int(round(float(a['fifty_two_week_low']), 0))
    except ValueError:
        L52 = '_'
    try:
        P = round(float(a['price']), 1)
    except ValueError:
        P = '_'
    try:
        C = a['change']
    except ValueError:
        C = '_'
    try:
        H52 = int(round(float(a['fifty_two_week_high']), 0))
    except ValueError:
        H52 = '_'
    try:
        PE = round(float(a['price_earnings_ratio']), 1)
    except ValueError:
        PE = '_'
    try:
        Cp = int(round(float(C) / float(P) * 100))
    except ValueError:
        Cp = '_'
    return '{} {} {}% [{} {}] PE {}'.format(symbol, P, Cp, L52, H52, PE)[0:31]
开发者ID:zimolzak,项目名称:Raspberry-Pi-newbie,代码行数:27,代码来源:lcd_ticker.py


示例11: test_get_all

 def test_get_all(self):
     symbol = 'GOOG'
     all_info = ystockquote.get_all(symbol)
     self.assertIsInstance(all_info, dict)
     pc = all_info['previous_close']
     self.assertNotEqual(pc, 'N/A')
     self.assertGreater(float(pc), 0)
开发者ID:BChip,项目名称:ystockquote,代码行数:7,代码来源:test_ystockquote.py


示例12: get_fundamental_data

def get_fundamental_data(stock: str) -> dict:
    """
    Gets fundamental Data from yahoo finance. Some fundamentals and a lot af real-live prices.
    Enter a starting point and an endpoint as args after entering the symbol of a stock or an index. 
    The result will look like this:

      avg_daily_volume: 17735800,
      book_value: 9.33,
      change: -0.13,
      dividend_per_share: 0.12,
      dividend_yield: 1.23,
      earnings_per_share: -0.44,
      ebitda: 2.63B,
      fifty_day_moving_avg: 10.28,
      fifty_two_week_high: 11.50,
      fifty_two_week_low: 6.14,
      market_cap: 12.35B,
      price: 9.39,
      price_book_ratio: 1.02,
      price_earnings_growth_ratio: 2.50,
      price_earnings_ratio: N/A,
      price_sales_ratio: 0.59,
      short_ratio: 8.07,
      stock_exchange: "NYQ",
      two_hundred_day_moving_avg: 9.91,
      volume: 15300774},  

    """
    try:
        return ystockquote.get_all(stock)
    except:
        print("Something went wrong!")
开发者ID:kallinikator,项目名称:falcons-rest,代码行数:32,代码来源:Data_access_ystockquote.py


示例13: addRow

    def addRow(self, stockSym):
        self.sysmTextIn.delete(0, END)
        searchterms = [('Symbol', stockSym.upper(), '=', 'AND')]
        symbolCol = self.model.getColumnData(columnIndex=self.model.getColumnIndex(columnName="Symbol"),
                                             columnName="Symbol", filters=searchterms)
        if stockSym.upper() in symbolCol:
            return
        result = ystockquote.get_all(stockSym.upper())

        row = Rows(result, stockSym.upper())
        dictrow = row.getRow()
        colIndex = self.model.getColumnIndex(columnName="Symbol")
        stockSym = self.model.getValueAt(rowIndex=0, columnIndex=colIndex)
        if stockSym == " ":
            row0 = self.table.getSelectedRow()
            self.model.deleteRow(row0)
            self.table.setSelectedRow(row0-1)
            self.table.clearSelected()
        else:
            self.currentRow = self.currentRow + 1
        self.model.importDict({ "%s%d" % ("rec", self.currentRow) : dictrow})
        change = float(dictrow['Change'])
        if change > 0:
            self.model.setColorAt(rowIndex=self.model.getRecordIndex("%s%d" % ("rec", self.currentRow)),
                                  columnIndex=self.model.getColumnIndex(columnName="Change"),color="green", key="fg") 
            self.model.setColorAt(rowIndex=self.model.getRecordIndex("%s%d" % ("rec", self.currentRow)),
                                  columnIndex=self.model.getColumnIndex(columnName="%Change"),color="green", key="fg")
        if change < 0:
            self.model.setColorAt(rowIndex=self.model.getRecordIndex("%s%d" % ("rec", self.currentRow)),
                                  columnIndex=self.model.getColumnIndex(columnName="Change"),color="red", key="fg") 
            self.model.setColorAt(rowIndex=self.model.getRecordIndex("%s%d" % ("rec", self.currentRow)),
                                  columnIndex=self.model.getColumnIndex(columnName="%Change"),color="red", key="fg")
        self.table.redrawTable()
        self.after(5000, self.updateTableValue, "%s%d" % ("rec", self.currentRow))
开发者ID:shashank2685,项目名称:stockwatchList,代码行数:34,代码来源:watchlist.py


示例14: test_get_all_multiple

 def test_get_all_multiple(self):
     symbols = ['GOOG', 'TSLA']
     all_info = ystockquote.get_all(symbols)
     self.assertIsInstance(all_info, list)
     for row in all_info:
         self.assertIsInstance(row, dict)
         pc = row['previous_close']
         self.assertNotEqual(pc, 'N/A')
         self.assertGreater(float(pc), 0)
开发者ID:berdon,项目名称:ystockquote,代码行数:9,代码来源:test_ystockquote.py


示例15: main

def main():
  args = parse_args()
  if args.startDate and args.endDate:
    values = get_historical_prices(
        args.symbol, args.startDate, args.endDate).items()
  else:
    values = get_all(args.symbol).items()
  for val in sorted(values):
    print val
开发者ID:jplehmann,项目名称:ystockquote,代码行数:9,代码来源:query.py


示例16: yahoo

 def yahoo(symbols):
   """
      Downloads the latest quote for the given symbols
   """
   all = None
   try:
     return ystockquote.get_all(symbols)
   except Exception, e:
     logging.error('Could not download quote %s:%s', symbols, e)
     return None
开发者ID:robcos,项目名称:quote-portfolio,代码行数:10,代码来源:models.py


示例17: main

def main(tickers):
	for ticker in tickers:
		allInfo = ystockquote.get_all(ticker)
		print ticker + ":Exchange=" + allInfo["stock_exchange"] \
		+ ":Cap=" + allInfo["market_cap"] \
		+ ":P-Earn=" + allInfo["price_earnings_ratio"] \
		+ ":P-Sales=" + allInfo["price_sales_ratio"] \
		+ ":Range52=" + allInfo["fifty_two_week_low"] \
		+ "-" + allInfo["fifty_two_week_high"] \
		+ ":Price=" + allInfo["price"]
开发者ID:mattsoftware,项目名称:SmartTechDiscovery,代码行数:10,代码来源:stockquotes.py


示例18: compact_quote

def compact_quote(symbol):
    symbol = 'SYK'
    a = y.get_all(symbol)

    L52 = int(round(float(a['fifty_two_week_low']), 0))
    P = round(float(a['price']), 1)
    C = a['change']
    H52 = int(round(float(a['fifty_two_week_high']), 0))
    PE = round(float(a['price_earnings_ratio']), 1)
    Cp = int(round(float(C) / float(P) * 100))

    return '{} {} {}% [{} {}] PE {}'.format(symbol, P, Cp, L52, H52, PE)
开发者ID:zimolzak,项目名称:Raspberry-Pi-newbie,代码行数:12,代码来源:test.py


示例19: get_ticks

def get_ticks():        
    print "%(1)s %(2)s %(3)s %(4)s %(5)s %(6)s" % {"1" : "SYMBOLS".ljust(12), "2" : "Price".rjust(8), "3" : "Change".rjust(8), "4" : "Bought".rjust(8), "5" : "Vol(%)".rjust(8), "6" : "Action".ljust(5)}
    for stock in stocks:
        data= ystockquote.get_all(stock[1])
        prices.append((stock[0], data['price']))
        thisprices = []
        for price in prices:
            if price[0] == stock[0]:
                thisprices.append(float(price[1]))

        thisprevsma = data['price']        
        for price in prevsma:
            if price[0] == stock[0]:
                thisprevsma=price[1]

        thisprevema = data['price']        
        for price in prevema:
            if price[0] == stock[0]:
                thisprevema=price[1]
        bar =len(thisprices)-1
        currentsma = running_sma(bar, thisprices, 3, float(thisprevsma))
        currentema = ema(bar, thisprices, period, float(thisprevema), smoothing=None)

        Hit = False
        for i,value in enumerate(prevsma):
            if prevsma[i] == stock[0]:
                Hit=True
                prevsma[i] = currentsma

        if Hit==False:
             prevema.append((stock[0], currentsma))

        Hit = False
        for i,value in enumerate(prevema):
            if prevema[i] == stock[0]:
                Hit=True
                prevema[i] = currentema

        if Hit==False:
             prevema.append((stock[0], currentema))
        action = ""
        if float(currentsma) > float(currentema) :
            action = "long"
        elif float(currentema) > float(currentsma) :
            action = "short"
        
        vol=0
        
        if float(data['volume']) > 0 and float(data['avg_daily_volume']) > 0:
            vol = "{0:.2f}".format((float(data['volume']) /float(data['avg_daily_volume']))*100)

        color=Color_It(data['price'], stock[2])
        print colored("%(1)s %(2)s %(3)s %(4)s %(5)s %(6)s" % {"1" : stock[0].ljust(12), "2" : data['price'].rjust(8), "3" : data['change'].rjust(8), "4" : str(stock[2]).rjust(8), "5" : str(vol).rjust(8), "6" : action.ljust(5)}, color)
开发者ID:javaongsan,项目名称:stock_ticker,代码行数:53,代码来源:ticker.py


示例20: get_cached_quote

	def get_cached_quote(self, symbol):
		key = "quote_" + symbol
		valstr = memcache.get(key)

		if valstr is None:
			fullquote = None
			try:
				fullquote = ystockquote.get_all(symbol)
				valstr = "%s,%s,%s,%s,%s,%s" % (fullquote['price'], fullquote['52_week_high'], fullquote['52_week_low'], fullquote['50day_moving_avg'], fullquote['200day_moving_avg'], fullquote['change'])
				memcache.add(key, valstr, 60*10)
			except Exception, e:
				logging.error('error retrieving quote for %s (%s)', symbol, e)
开发者ID:beatty,项目名称:marketdash,代码行数:12,代码来源:main.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python ystockquote.get_historical_prices函数代码示例发布时间:2022-05-26
下一篇:
Python yoyo.step函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap