#!/usr/bin/python

# Package imports
	
import requests
import csv

# Stock information

symbol = input('Enter a stock symbol: ').upper()

stock = dict( [
	( 'name' , 'Excellent Co.' ),
	( 'symbol' , symbol ),
    ( 'phone' , '800-YOU-GAIN' ),
    ( 'currentPrice' , '150' ),
    ( 'yearHigh' , '12' ),
    ( 'yearLow' , '5' ),
    ( 'marketCap' , '$100 Million' ),
    ( 'dayDollarVolume' , '$1 Million' ),
    ( 'sales' , '$50 Million' ),
    ( 'netProfitMargin' , '25%' ),
    ( 'cash' , '$10 Million' ),
    ( 'totalDebt' , '$2.5 Million' ),
    ( 'salesPerShare' , '$15' ),
    ( 'cashFloatingPerShare' , '$0.45' ),
    ( 'earningsPerShare' , '$4' ),
    ( 'dividendYield' , 'N/A' ),
    ( 'returnOnEquity' , '20%' ),
    ( 'insiderBuy' , '10' ),
    ( 'insiderOwn' , '30%' ),
    ( 'stockBuyback' , 'Yes' ),
    ( 'epsRank' , '95' ),
    ( 'rpsRank' , '95' ),
    ( '5yrSales' , '20%' ),
    ( '5yrPrice' , '900%' ),
    ( 'projSales' , '25%' ),
    ( 'projHi' , '100' ),
    ( 'projLow' , '60' ),
    ( 'time' , '1' ),
    ( 'safety' , '2' ),
    ( 'stars' , '5' ),
    ( 'fairValue' , '5' ),
    ( 'currentPE' , '2.5' ),
    ( 'averagePE' , '5' ),
    ( 'ps' , '0.67' ),
    ( 'pb' , '0.5' ),
    ( 'currentRatio' , '10' ),
    ( 'quickRatio' , '2' ),
    ( 'smaMacdRsi' , 'strongUp' )
] )

'''
# Search the website for the quote and grab the information
# This gives me of the statistics that we need for the
# table but not everything. May need to explore multiple sites.

r = requests.get( 'http://www.google.com/finance?q=' + symbol ) 
print( r.text )
'''

# Output the statistics to a CSV formatted file

with open('worksheet.csv','w',newline='') as csvfile:
	writer = csv.writer( csvfile, delimiter=' ', quoting=csv.QUOTE_MINIMAL )
	writer.writerow( [
		'Company Name, Symbol, and Phone',
		'Current Price',
		'52 wk Hi/Lo',
		'Market Cap',
		'Day Dollar Volume',
		'Sales',
		'Net Profit Margin',
		'Cash',
		'Total Debt',
		'Sales / Share',
		'Cash Flow / Share',
		'Earnings / Share',
		'Dividend Yield',
		'ROE',
		'Insider Buy/Own',
		'Stock Buyback',
        'EPS Rank',
        'RPS Rank',
        '5 yr Sales',
        '5 yr Price',
        'Proj Sales',
        'Proj Hi/Lo',
        'Time Safe',
        'STARS Fair Val',
        'Current P/E',
        'Average P/E',
        'P/S',
        'P/B',
        'Current Ratio',
        'Quick Ratio',
        'SMA MACD RSI' ] )

	writer.writerow( [
		str( stock['name'] +  ', ' +  stock['symbol'] +  ', ' + stock['phone'] ),
		str( stock['currentPrice'] ),
		str( stock['yearHigh'] + '/' + stock['yearLow'] ),
		str( stock['marketCap'] ),
		str( stock['dayDollarVolume'] ),
		str( stock['sales'] ),
		str( stock['netProfitMargin'] ),
		str( stock['cash'] ),
		str( stock['totalDebt'] ),
		str( stock['salesPerShare'] ),
		str( stock['cashFloatingPerShare'] ),
		str( stock['earningsPerShare'] ),
		str( stock['dividendYield'] ),
		str( stock['returnOnEquity'] ),
		str( stock['insiderBuy'] + '/' + stock['insiderOwn'] ),
		str( stock['stockBuyback'] ),
		str( stock['epsRank'] ),
		str( stock['rpsRank'] ),
		str( stock['5yrSales'] ),
		str( stock['5yrPrice'] ),
		str( stock['projSales'] ),
		str( stock['projHi'] + '/' + stock['projLow'] ),
		str( stock['time'] + '/' + stock['safety'] ),
		str( stock['stars'] + '/' + stock['fairValue'] ),
		str( stock['currentPE'] ),
		str( stock['averagePE'] ),
		str( stock['ps'] ),
		str( stock['pb'] ),
		str( stock['currentRatio'] ),
		str( stock['quickRatio'] ),
		str( stock['smaMacdRsi'] ) ] )
