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


Python Share.refresh方法代码示例

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


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

示例1: print_stats

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import refresh [as 别名]
def print_stats(ticker,is_trading_hours):
  stock = Share(ticker)
  stock.refresh()
  
  if(is_trading_hours == True):
    print("Current Price:  $" + stock.get_price() + "\n--------------------------------------")
  else:
    print("Previous Close: $" + stock.get_prev_close())
    print("Opening Price:  $" + stock.get_open())
    print("Current Price:  $" + stock.get_price() + "\n--------------------------------------")
开发者ID:ppourmand,项目名称:stockchecker,代码行数:12,代码来源:stocks.py

示例2: stock

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import refresh [as 别名]
def stock(message):
  ticker = Share(message)
  ticker.refresh()
  quote = ticker.get_price()
  if quote is None:
    resp = str(message) + " is not a valid ticker symbol"
  else:
    change = ticker.get_change()
    resp = message + ": " + quote + " " + change
  __send_response(resp, icon_money)
  quote = ""
开发者ID:rpkish,项目名称:botiana,代码行数:13,代码来源:botiana.py

示例3: stalk

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import refresh [as 别名]
def stalk(stock):
    bad = True
    share = Share(stock["symbol"])

    price = float(share.get_price())

    while bad:
        # check if in range
        if price > stock["price"] - stock["range"] and price < stock["price"] + stock["range"]:
            # send a yo
            data = {"username": stock["username"], "api_token": os.environ.get("API_TOKEN")}

            res = requests.post("http://api.justyo.co/yo/", params=data)
            print res

            bad = False
        else:
            share.refresh()
开发者ID:kapadiamush,项目名称:YoStock,代码行数:20,代码来源:stocker.py

示例4: get_one_stock

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import refresh [as 别名]
def get_one_stock(thread_id, tickers, good):
    #print(thread_id, len(tickers))
    for ticker in tickers:
        try:
            stock = Share(ticker)
            stock.refresh()
            my_data = stock.data_set
            #for x in my_data.keys():
            #    print(x)
            #print(ticker, my_data)
            tmp = {}
            tmp[ticker]=my_data
            if is_good(my_data):
                #print('!!!!!!', thread_id, tmp)
                good.append(tmp)

        except Exception as e:
            #pass
            print("Exception in get_one_stock:" +str(e))
开发者ID:carlwu66,项目名称:stock,代码行数:21,代码来源:filter.py

示例5: __init__

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import refresh [as 别名]
class YahooFinanceData:
    """Get data from Yahoo Finance."""

    def __init__(self, symbol):
        """Initialize the data object."""
        from yahoo_finance import Share

        self._symbol = symbol
        self.state = None
        self.price_change = None
        self.price_open = None
        self.prev_close = None
        self.stock = Share(self._symbol)

    def update(self):
        """Get the latest data and updates the states."""
        self.stock.refresh()
        self.state = self.stock.get_price()
        self.price_change = self.stock.get_change()
        self.price_open = self.stock.get_open()
        self.prev_close = self.stock.get_prev_close()
开发者ID:EarthlingRich,项目名称:home-assistant,代码行数:23,代码来源:yahoo_finance.py

示例6: YahooFinanceData

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import refresh [as 别名]
class YahooFinanceData(object):
    """Get data from Yahoo Finance."""

    def __init__(self, name, symbol):
        """Initialize the data object."""
        from yahoo_finance import Share

        self._name = name
        self._symbol = symbol
        self.state = None
        self.price_change = None
        self.price_open = None
        self.prev_close = None
        self.stock = Share(symbol)

    @Throttle(MIN_TIME_BETWEEN_UPDATES)
    def update(self):
        """Get the latest data and updates the states."""
        self.stock.refresh()
        self.state = self.stock.get_price()
        self.price_change = self.stock.get_change()
        self.price_open = self.stock.get_open()
        self.prev_close = self.stock.get_prev_close()
开发者ID:Bart274,项目名称:home-assistant,代码行数:25,代码来源:yahoo_finance.py

示例7: Share

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

yahoo = Share('SPY')
print yahoo.get_open()
print yahoo.get_price()
print yahoo.get_trade_datetime()
yahoo.refresh()

spyprice = yahoo.get_historical('2000-01-01', '2016-04-25')
pprint(yahoo.get_historical('2014-04-25', '2014-04-29'))
开发者ID:jingriver,项目名称:testPython,代码行数:13,代码来源:testYahoo.py

示例8: print_menu

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import refresh [as 别名]
def print_menu(menuid, errorid):
	global selected_Ticker

	namesTicker = ["Stocks", "Exchanges", "Catagory", "Number Selection"]

	if selected_Ticker is not None:
		print("Selected:\t"+selected_Ticker.name)
		print("Type:\t\t"+namesTicker[selected_Ticker.typeof])
		if selected_Ticker.typeof == 0:
			stock = Share(selected_Ticker.name)
			stock.refresh()
			print(stock.get_info())
			print(stock.get_price())
			print(stock.get_change())
			print(stock.get_volume())
		print("\n\n")

	if menuid == 0:
		print("------Menu------")
		print("    (e) exit")
		print("    (l) list")
		print("    (s) stats")
		error(errorid)
	elif menuid == 1:
		print("------Stats Menu------")
		print("    (a) all")
		print("    (u) uniques")
		print("    (b) back")
		if selected_Ticker is not None:
			print("    (r) run data collector")
			print("    (c) clear")
		error(errorid)
	elif menuid == 2:
		print("------All Data Menu------")
		print("    (e) exchanges")
		print("    (c) catagories")
		print("    (n) catagory Number")
		print("    (b) back")
		error(errorid)
	elif menuid == 3:
		print("------Unique Menu------")
		print("    (s) stock")
		print("    (e) exchange")
		print("    (c) catagories")
		print("    (n) catagory Number")
		print("    (b) back")
		error(errorid)
	elif menuid == 4:
		print("------Stock Tickers Selection------")
		exchanges_display(0)
		error(errorid)
	elif menuid == 5:
		print("------Exchanges Selection------")
		exchanges_display(1)
		error(errorid)
	elif menuid == 6:
		print("------Catagory Selection------")
		exchanges_display(2)
		error(errorid)
	elif menuid == 7:
		print("------Number Catagory Selection------")
		exchanges_display(3)
		error(errorid)
开发者ID:abhishekpratapa,项目名称:artificial-intelligence,代码行数:65,代码来源:get_stocks_data.py

示例9: Share

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

# Collect 30 mins of Finance data on 5 companies, one value per minute

share = Share(sys.argv[1])

for i in range(30):
	share.refresh();
	print share.get_price()
	time.sleep(60)

# RUN SCRIPT IN PYTHON
# python yahoo.py LNKD> linkedin.txt
# python yahoo.py FB> facebook.txt
# python yahoo.py IBM> ibm.txt
# python yahoo.py YHOO> yahoo.txt
# python yahoo.py NYT> nyt.txt
开发者ID:cathyq,项目名称:yahoo-finance,代码行数:21,代码来源:yahoo.py

示例10: print

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import refresh [as 别名]
#print(stocks)
row_title = "\nticker price    price%  volume     volume% open      day_low   day_high  year_low  year_high market_cap P/E     avg_50" +\
    "    avg_200"

i=0
for ticker in stocks:

    sys.exit()
    try:
        if (i%10) == 0:
            print(row_title)
        ticker = ticker.rstrip()
        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)
开发者ID:carlwu66,项目名称:stock,代码行数:33,代码来源:old_yahoo.py

示例11: open

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import refresh [as 别名]
import sqlite3
from yahoo_finance import Share
f = open('tick.txt','r')
con=sqlite3.connect('stocks.db')
c = con.cursor()



##historical data using yahoo
# sh = ['FB', 'INTC']
sh = f.readlines()

for tick in sh:
	print(tick)
	equity = Share(tick)
	equity.refresh()
	lst = equity.get_historical('2000-04-25', '2015-09-29')
	for x in lst:
		print(type(x))
		close = x.get('Adj_Close')
		date = x.get('Date')
		hi = x.get('High')
		lo = x.get('Low')
		tck = x.get('Symbol')
		vol = x.get('Vol')
		opn = x.get('Open')
		c.execute("INSERT INTO price VALUES (?,?,?,?,?,?);",(tck,date,opn,hi,lo,close))

con.commit()
con.close()
##real time data using google
开发者ID:caraoz,项目名称:custom-stock,代码行数:33,代码来源:store.py

示例12: open

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

inp = open('input.txt', 'r')
out = open('output.txt', 'w')
for line in inp:
	temp = Share(line)
	temp.refresh()
	out.write(line.rstrip("\n") + "," + temp.get_price() + "," + temp.get_change() + "\n")
	#FORMAT:  Symbol, last closing price, last change
temp = Share('FUSVX')
print(temp.get_stock_exchange())
开发者ID:Alex-Gurung,项目名称:SymbolToInfo,代码行数:13,代码来源:main.py

示例13: Share

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import refresh [as 别名]
# find the date of yesterday
now = datetime.datetime.now()

# connect the sqlite
conn = lite.connect('StockHistory.db')
cursor = conn.cursor()
# every time empty data
cursor.execute('DELETE FROM TrueTimeValue')
conn.commit()
# get the records ranging from max date in DB to yesterday
BeginTime = now.replace(hour=9, minute=0, second=0, microsecond=0)
EndTime = now.replace(hour=16, minute=0, second=0, microsecond=0)
# LocalTime = T.strftime('%Y-%m-%d ',T.localtime(T.time()))
while now > BeginTime and now < EndTime:
    StockList = ['YHOO', 'GOOG', 'AAPL', 'TWTR', 'AMZN']
    for stock in StockList:
        Symbol = stock
        Company = Share(stock)
        Price = Company.get_price()
        Time = Company.get_trade_datetime()
        Volume = Company.get_volume()
        purchases = (Symbol, Price, Time, Volume)
        cursor.execute('INSERT INTO TrueTimeValue VALUES (?,?,?,?)', purchases)
        conn.commit()
        Company.refresh()
    cursor.execute('SELECT * FROM TrueTimeValue')
    print(cursor.fetchall())
    T.sleep(60)
cursor.close()
conn.close()
开发者ID:AlexWufan,项目名称:StockPrediction,代码行数:32,代码来源:realtimestock.py

示例14: open

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import refresh [as 别名]
filename3 = "microsoft.txt"
filename4 = "apple.txt"
filename5 = "amazon.txt"
while True:

	with open(filename1,"a") as f:
		f.write(yahoo.get_price())
		f.write(" ")
	with open(filename2,"a") as f:
		f.write(google.get_price())
		f.write(" ")
	with open(filename3,"a") as f:
		f.write(microsoft.get_price())
		f.write(" ")
	with open(filename4,"a") as f:
		f.write(apple.get_price())
		f.write(" ")
	with open(filename5,"a") as f:
		f.write(amazon.get_price())
		f.write(" ")	
	
	yahoo.refresh()
	google.refresh()
	microsoft.refresh()
	apple.refresh()
	amazon.refresh()
	
	time.sleep(30)
	c+=1
	if c > 60:
		break
开发者ID:BitTigerInst,项目名称:bigdata_analysis,代码行数:33,代码来源:stock.py

示例15: Ian

# 需要导入模块: from yahoo_finance import Share [as 别名]
# 或者: from yahoo_finance.Share import refresh [as 别名]
def Ian():	#function that loops (like a main function)
	run = True	#runnning parameter, failsafe if i missed a break somewhere
	for i in range(50):	#clean things up a bit
		print ''
	print row
	stc = raw_input('Stock Abrieviation (ex= YHOO):   ') #which stock to examine
	print row
	for i in range(50):	#clean things up a bit
		print ''
	print row
	o = raw_input('Daily, Weekly, Monthly or Yearly (D, W, M, Y):   ') #chosing timescale
	print row
	for i in range(50):
		print ''
	print row
	stdate = raw_input('Start date (YYYY-MM-DD)      :   ') #start date of data set, using yahoo_finance module syntax
	print row
	for i in range(50):
		print ''
	print row
	endate = raw_input('End date (YYYY-MM-DD)        :   ')  #end date of data set, using yahoo_finance module syntax
	print row
	for i in range(50):
		print ''
	print row
	stock = Share(stc)	#declaring the stock "Share" is imported from yahoo_finance
	stock.refresh()
	print 'Gathering data, (about a second per month of data)'
	print 'Building Data Structure'
	List = stock.get_historical(stdate, endate)	#actual data gathering
	val = times[o]	
	l = len(List)/val
	v = [0]*l
	for i in range(l):	#reformats the data into a list called v
		v[i] = float(List[i*val]['Open'])
	v = v[::-1]
	while run == True:	#main while loop
		tdate = raw_input('Algorithm value for what day?:   ')	#chosen date to examine momentum on
		if tdate == 'end':	#allows user to break code, useful for diagnostics
			run = False
			break
		"""
		HELP ME:
		i cant find a better way to measure the number of days the stock martket
		is open between start date and chosen date, without making a whole new
		list and measuring it
		"""
		print 'Finding number of market days'
		xList = stock.get_historical(stdate, tdate)
		x = len(xList)/val
		print ''
		for i in range(50): 
			print ''
		print tdate
		print 'ALGORITHM OUTPUT:'
		oval = SQT(x, v, l, val)	#actual algorith usage
		print oval
		if Monte != 'y' or 'Y' or 'Yes' or 'yes':	#for some reason this needed to be here
			pass
		elif Monte == 'y' or 'Y' or 'Yes' or 'yes':	#runnng the monte carlo measurements
			newV = v
			oList = []
			for i in range(n):	#compares output against outputs of the same data set, but in a random order				newV = shuffle(v)
				shuffle(newV)
				oList.append(SQT(l-1, newV, l, val))
			std = np.std(oList)
			mu = np.average(oList)
			zscore = (oval - mu)/std
			tot = 0
			for i in range(l):
				if oval>oList[i]:
					tot += 1
			sampleP = float(tot)/l
			print 'Sample percent lower than original output'	#You wan this to be low for a negative output, or high for a positive output
			print sampleP	#uses sample (of 30) data see globaly defined 'n' to change this number, defined at top of page, 30 is generally safe
			print 'Population percent lower than original based on 1-sample z-test'
			if m == 'z':
				print norm.cdf(zscore)	#some statistics stuff, you probly dont care, unless you wanna chack my stats work
			if m == 't':
				print t.cdf(zscore,n+1)	#if you chose t distributions this one happens, t is probly the right choice given the circumstances
		print''
		print 'enter "end" on the next prompt to quit, and try a new share'
		print row
开发者ID:geordieduncan,项目名称:IDSeniorProj,代码行数:85,代码来源:IansMethod.py


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