In [22]:
import googlefinance.client as gfc





def nameto():
    print "Please enter names of the stocks separated by commas, example: GOOGL, APPL, TWRT"
    x=str(raw_input())
    quotes=[]
    
    for i in (x.split(",")):
        i=i.strip()
        dict={'q':i}
        quotes.append(dict)
        

    period = "5M"
    # get closing price data (return pandas dataframe)
    df = gfc.get_closing_data(quotes, period)
    print(df)
    

    
""" 
# Dow Jones
param = {
    'q': ".DJI", # Stock symbol (ex: "AAPL")
    'i': "86400", # Interval size in seconds ("86400" = 1 day intervals)
    'x': "INDEXDJX", # Stock exchange symbol on which stock is traded (ex: "NASD")
    'p': "1Y" # Period (Ex: "1Y" = 1 year)
}
# get price data (return pandas dataframe)
df = gfc.get_price_data(param)
#print(df)
#                          Open      High       Low     Close     Volume
# 2016-05-17 05:00:00  17531.76   17755.8  17531.76  17710.71   88436105
# 2016-05-18 05:00:00  17701.46  17701.46  17469.92  17529.98  103253947
# 2016-05-19 05:00:00  17501.28  17636.22  17418.21  17526.62   79038923
# 2016-05-20 05:00:00  17514.16  17514.16  17331.07   17435.4   95531058
# 2016-05-21 05:00:00  17437.32  17571.75  17437.32  17500.94  111992332
# ...                       ...       ...       ...       ...        ...

params = [
    # Dow Jones
    {
        'q': 'GOOGL',
        #'x': "NASDAQ",
    },
    # NYSE COMPOSITE (DJ)
    {
        'q': 'NYA',
        #'x': "INDEXNYSEGIS",
    },
    # S&P 500
    {
        'q': '.INX',
        #'x': "INDEXSP",
    }
]
period = "1Y"
# get closing price data (return pandas dataframe)
df = gfc.get_closing_data(quotes, period)
print(df)
#                 .DJI         NYA     .INX
# 2016-05-17  17710.71  10332.4261  2066.66
# 2016-05-18  17529.98  10257.6102  2047.21
# 2016-05-19  17526.62  10239.6501  2047.63
# 2016-05-20  17435.40  10192.5015  2040.04
# 2016-05-21  17500.94  10250.4961  2052.32
# ...              ...         ...      ...
"""


Out[22]:
' \n# Dow Jones\nparam = {\n    \'q\': ".DJI", # Stock symbol (ex: "AAPL")\n    \'i\': "86400", # Interval size in seconds ("86400" = 1 day intervals)\n    \'x\': "INDEXDJX", # Stock exchange symbol on which stock is traded (ex: "NASD")\n    \'p\': "1Y" # Period (Ex: "1Y" = 1 year)\n}\n# get price data (return pandas dataframe)\ndf = gfc.get_price_data(param)\n#print(df)\n#                          Open      High       Low     Close     Volume\n# 2016-05-17 05:00:00  17531.76   17755.8  17531.76  17710.71   88436105\n# 2016-05-18 05:00:00  17701.46  17701.46  17469.92  17529.98  103253947\n# 2016-05-19 05:00:00  17501.28  17636.22  17418.21  17526.62   79038923\n# 2016-05-20 05:00:00  17514.16  17514.16  17331.07   17435.4   95531058\n# 2016-05-21 05:00:00  17437.32  17571.75  17437.32  17500.94  111992332\n# ...                       ...       ...       ...       ...        ...\n\nparams = [\n    # Dow Jones\n    {\n        \'q\': \'GOOGL\',\n        #\'x\': "NASDAQ",\n    },\n    # NYSE COMPOSITE (DJ)\n    {\n        \'q\': \'NYA\',\n        #\'x\': "INDEXNYSEGIS",\n    },\n    # S&P 500\n    {\n        \'q\': \'.INX\',\n        #\'x\': "INDEXSP",\n    }\n]\nperiod = "1Y"\n# get closing price data (return pandas dataframe)\ndf = gfc.get_closing_data(quotes, period)\nprint(df)\n#                 .DJI         NYA     .INX\n# 2016-05-17  17710.71  10332.4261  2066.66\n# 2016-05-18  17529.98  10257.6102  2047.21\n# 2016-05-19  17526.62  10239.6501  2047.63\n# 2016-05-20  17435.40  10192.5015  2040.04\n# 2016-05-21  17500.94  10250.4961  2052.32\n# ...              ...         ...      ...\n'

In [23]:
nameto()


Please enter names of the stocks separated by commas, example: GOOGL, APPL, TWRT
 GOOGL , AAPL , NYA
             GOOGL    AAPL         NYA
2017-04-10  841.70  143.17  11464.3411
2017-04-11  839.88  141.63  11473.6193
2017-04-12  841.46  141.80  11423.1700
2017-04-13  840.18  141.05  11324.5286
2017-04-17  855.13  141.83  11427.0770
2017-04-18  853.99  141.20  11378.5777
2017-04-19  856.51  140.68  11342.4210
2017-04-20  860.08  142.44  11426.9140
2017-04-21  858.95  142.27  11389.1300
2017-04-24  878.93  143.64  11531.7900
2017-04-25  888.84  144.53  11603.2800
2017-04-26  889.14  143.68  11592.9093
2017-04-27  891.44  143.79  11578.5160
2017-04-28  924.52  143.65  11536.0800
2017-05-01  932.82  146.58  11536.4899
2017-05-02  937.09  147.51  11551.3000
2017-05-03  948.45  147.06  11529.6591
2017-05-04  954.72  146.53  11534.7100
2017-05-05  950.28  148.96  11615.6100
2017-05-08  958.69  153.01  11595.2591
2017-05-09  956.71  153.99  11567.5188
2017-05-10  954.84  153.26  11598.9850
2017-05-11  955.89  153.95  11563.6014
2017-05-12  955.14  156.10  11547.0537
2017-05-15  959.22  155.70  11614.2317
2017-05-16  964.61  155.47  11606.4862
2017-05-17  942.17  150.25  11423.5300
2017-05-18  950.50  152.54  11434.0649
2017-05-19  954.65  153.06  11542.6881
2017-05-22  964.07  153.99  11585.2072
...            ...     ...         ...
2017-07-26  965.31  153.46  11964.9100
2017-07-27  952.51  150.56  11963.2288
2017-07-28  958.33  149.50  11954.6899
2017-07-31  945.50  148.73  11967.6682
2017-08-01  946.56  150.05  12000.0200
2017-08-02  947.64  157.14  11979.3700
2017-08-03  940.30  155.57  11956.5162
2017-08-04  945.79  156.39  11984.8869
2017-08-07  945.75  158.81  11987.7739
2017-08-08  944.19  160.08  11949.9700
2017-08-09  940.08  161.06  11929.4645
2017-08-10  923.59  155.32  11771.6000
2017-08-11  930.09  157.48  11763.2100
2017-08-14  938.93  159.85  11856.0600
2017-08-15  938.08  161.60  11843.4800
2017-08-16  944.27  160.95  11868.8500
2017-08-17  927.66  157.86  11712.7155
2017-08-18  926.18  157.50  11699.8313
2017-08-21  920.87  157.21  11719.2665
2017-08-22  940.40  159.78  11805.2900
2017-08-23  942.58  159.98  11785.9221
2017-08-24  936.89  159.27  11773.8000
2017-08-25  930.50  159.86  11812.0277
2017-08-28  928.13  161.47  11800.2193
2017-08-29  935.75  162.91  11791.8786
2017-08-30  943.63  163.35  11805.0710
2017-08-31  955.24  164.00  11875.6930
2017-09-01  951.99  164.05  11918.0805
2017-09-05  941.48  162.08  11827.1500
2017-09-08  941.41  158.63  11887.9800

[104 rows x 3 columns]

In [ ]: