예제 #1
0
def getAllStockData(ticker):
    '''Get a few random tickers.'''
    stock = Share(ticker)
    stock.refresh()
    data = {
        'name': stock.get_name(),
        'price': stock.get_price(),
        'change': stock.get_change(),
        'volume': stock.get_volume(),
        'prev_close': stock.get_prev_close(),
        'open': stock.get_open(),
        'avg_daily_volume': stock.get_avg_daily_volume(),
        'stock_exchange': stock.get_stock_exchange,
        'market_cap': stock.get_market_cap(),
        'book_value': stock.get_book_value(),
        'ebitda': stock.get_ebitda(),
        'dividend_share': stock.get_dividend_share(),
        'dividend_yield': stock.get_dividend_yield(),
        'earnings_share': stock.get_earnings_share(),
        'days_high': stock.get_days_high(),
        'days_low': stock.get_days_low(),
        'year_high': stock.get_year_high(),
        'year_low': stock.get_year_low(),
        '50day_moving_avg': stock.get_50day_moving_avg(),
        '200day_moving_avg': stock.get_200day_moving_avg(),
        'price_earnings_ratio': stock.get_price_earnings_ratio(),
        'price_earnings_growth_ratio': stock.get_price_earnings_growth_ratio(),
        'get_price_sales': stock.get_price_sales(),
        'get_price_book': stock.get_price_book(),
        'get_short_ratio': stock.get_short_ratio(),
        'trade_datetime': stock.get_trade_datetime(),
        'percent_change_from_year_high': stock.get_percent_change_from_year_high(),
        'percent_change_from_year_low': stock.get_percent_change_from_year_low(),
        'change_from_year_low': stock.get_change_from_year_low(),
        'change_from_year_high': stock.get_change_from_year_high(),
        'percent_change_from_200_day_moving_average': stock.get_percent_change_from_200_day_moving_average(),
        'change_from_200_day_moving_average': stock.get_change_from_200_day_moving_average(),
        'percent_change_from_50_day_moving_average': stock.get_percent_change_from_50_day_moving_average(),
        'change_from_50_day_moving_average': stock.get_change_from_50_day_moving_average(),
        'EPS_estimate_next_quarter': stock.get_EPS_estimate_next_quarter(),
        'EPS_estimate_next_year': stock.get_EPS_estimate_next_year(),
        'ex_dividend_date': stock.get_ex_dividend_date(),
        'EPS_estimate_current_year': stock.get_EPS_estimate_current_year(),
        'price_EPS_estimate_next_year': stock.get_price_EPS_estimate_next_year(),
        'price_EPS_estimate_current_year': stock.get_price_EPS_estimate_current_year(),
        'one_yr_target_price': stock.get_one_yr_target_price(),
        'change_percent_change': stock.get_change_percent_change(),
        'divended_pay_date': stock.get_dividend_pay_date(),
        'currency': stock.get_currency(),
        'last_trade_with_time': stock.get_last_trade_with_time(),
        'days_range': stock.get_days_range(),
        'years_range': stock.get_year_range()
    }
    return data
예제 #2
0
def get_symbol_yahoo_stats_yql(symbols, exclude_name=False):
    """
    Get the symbols' basic statistics from Yahoo Finance.
    Input:
       symbols - a list of symbol strings, e.g. ['AAPL']
    Output: stats in Pandas DataFrame.
    This function is ported from pandas_datareader/yahoo/components.py
    """
    sym_list = str2list(symbols)
    if sym_list == None:
        return DataFrame()

    # Yahoo Finance tags, refer to http://www.financialwisdomforum.org/gummy-stuff/Yahoo-data.htm
    tags = ['Symbol']
    if not exclude_name:
        tags += ['Name']
    tags += ['Exchange', 'MarketCap', 'Volume', 'AverageDailyVolume', 'BookValue', 'P/E', 'PEG', 'Price/Sales',
            'Price/Book', 'EBITDA', 'EPS', 'EPSEstimateNextQuarter', 'EPSEstimateCurrentYear', 'EPSEstimateNextYear',
            'OneyrTargetPrice', 'PriceEPSEstimateCurrentYear', 'PriceEPSEstimateNextYear', 'ShortRatio',
            'Dividend/Share', 'DividendYield', 'DividendPayDate', 'ExDividendDate']
    lines = []
    for sym in sym_list:
        stock = Share(sym)
        line = [sym]
        if not exclude_name:
            line += [stock.get_name()]
        line += [stock.get_stock_exchange(), str2num(stock.get_market_cap(), m2b=True),
                str2num(stock.get_volume()), str2num(stock.get_avg_daily_volume()), str2num(stock.get_book_value()),
                str2num(stock.get_price_earnings_ratio()), str2num(stock.get_price_earnings_growth_ratio()),
                str2num(stock.get_price_sales()), str2num(stock.get_price_book()), str2num(stock.get_ebitda()),
                str2num(stock.get_earnings_share()), str2num(stock.get_EPS_estimate_next_quarter()),
                str2num(stock.get_EPS_estimate_current_year()), str2num(stock.get_EPS_estimate_next_year()),
                str2num(stock.get_one_yr_target_price()), str2num(stock.get_price_EPS_estimate_current_year()),
                str2num(stock.get_price_EPS_estimate_next_year()), str2num(stock.get_short_ratio()),
                str2num(stock.get_dividend_share()), str2num(stock.get_dividend_yield()), stock.get_dividend_pay_date(),
                stock.get_ex_dividend_date()]
        lines.append(line)

    stats = DataFrame(lines, columns=tags)
    stats = stats.drop_duplicates()
    stats = stats.set_index('Symbol')
    return stats
예제 #3
0
print "refresh:", tesla.refresh()
print "get_percent_change_from_year_high:", tesla.get_percent_change_from_year_high(
)
print "get_percent_change_from_year_low:", tesla.get_percent_change_from_year_low(
)
print "get_change_from_year_low:", tesla.get_change_from_year_low()
print "get_change_from_year_high:", tesla.get_change_from_year_high()
print "get_percent_change_from_200_day_moving_average:", tesla.get_percent_change_from_200_day_moving_average(
)
print "get_change_from_200_day_moving_average:", tesla.get_change_from_200_day_moving_average(
)
print "get_percent_change_from_50_day_moving_average:", tesla.get_percent_change_from_50_day_moving_average(
)
print "get_change_from_50_day_moving_average:", tesla.get_change_from_50_day_moving_average(
)
print "get_EPS_estimate_next_quarter:", tesla.get_EPS_estimate_next_quarter()
print "get_EPS_estimate_next_year:", tesla.get_EPS_estimate_next_year()
print "get_ex_dividend_date:", tesla.get_ex_dividend_date()
print "get_EPS_estimate_current_year:", tesla.get_EPS_estimate_current_year()
print "get_price_EPS_estimate_next_year:", tesla.get_price_EPS_estimate_next_year(
)
print "get_price_EPS_estimate_current_year:", tesla.get_price_EPS_estimate_current_year(
)
print "get_one_yr_target_price:", tesla.get_one_yr_target_price()
print "get_change_percent_change:", tesla.get_change_percent_change()
print "get_dividend_pay_date:", tesla.get_dividend_pay_date()
print "get_currency:", tesla.get_currency()
print "get_last_trade_with_time:", tesla.get_last_trade_with_time()
print "get_days_range:", tesla.get_days_range()
print "get_year_range:", tesla.get_year_range()