Exemplo n.º 1
0
def sectors():

    params = [
        {
            'q': 'XLF',
            'x': 'NYSEARCA',
        },
        {
            'q': '.INX',
            'x': 'INDEXSP'
        }
    ]

    comparables = get_prices_time_data(params, period="10Y", interval="86400")

    index = ['XLF', '.INX']
    for name in index:
        comparables.drop(labels=[
            "{}_Open".format(name),
            "{}_High".format(name),
            "{}_Low".format(name),
            "{}_Volume".format(name),
        ],
            axis=1, inplace=True
        )
    comparables.to_csv('Sectors.csv')
Exemplo n.º 2
0
def goog_pull(request_again):

    if request_again == True:
        tickers = update_ticks()

    else:
        with open('SP500quotes.pickle', 'rb') as f:
            tickers = pickle.load(f)

    if not os.path.exists('stock_dfs'):
        os.makedirs('stock_dfs')
    else:
        print('Directory Exists')

    period = "5Y"
    interval = "86400"

    for stock in tickers:
        if not exists('SP500/{}.csv'.format(stock)):
            try:
                param = [
                    {
                        'q': stock,
                        'x': "INDEXSP",
                    },
                ]
                ticker = get_prices_time_data(param, period=period, interval=interval)
                drop_labs = [
                    '{}_Open'.format(stock),
                    '{}_High'.format(stock),
                    '{}_Low'.format(stock),
                    '{}_Volume'.format(stock),
                ]
                ticker.drop(drop_labs, axis=1, inplace=True)
                ticker.rename(columns={'{}_Close'.format(stock):stock}, inplace=True)
                ticker.to_csv('stock_dfs/{}.csv'.format(stock))
                print("Adding {} to stock_dfs directory".format(stock))
            except:
                print("Unable to read URL for: {}".format(stock))
Exemplo n.º 3
0
 def example_3(self):
     params = [
         # Dow Jones
         {
             'q': ".DJI",
             'x': "INDEXDJX",
         },
         # NYSE COMPOSITE (DJ)
         {
             'q': "NYA",
             'x': "INDEXNYSEGIS",
         },
         # S&P 500
         {
             'q': ".INX",
             'x': "INDEXSP",
         }
     ]
     period = "1Y"
     interval = 60 * 30  # 30 minutes
     # get open, high, low, close, volume time data (return pandas dataframe)
     df = get_prices_time_data(params, period, interval)
     print(df)
Exemplo n.º 4
0
# ...               ...        ...       ...         ...         ...

params = [
    # Dow Jones
    {
        'q': ".DJI",
        'x': "INDEXDJX",
    },
    # NYSE COMPOSITE (DJ)
    {
        'q': "NYA",
        'x': "INDEXNYSEGIS",
    },
    # S&P 500
    {
        'q': ".INX",
        'x': "INDEXSP",
    }
]
period = "1Y"
interval = 60 * 30  # 30 minutes
# get open, high, low, close, volume time data (return pandas dataframe)
df = get_prices_time_data(params, period, interval)
print(df)
#                      .DJI_Open  .DJI_High  .DJI_Low  .DJI_Close  .DJI_Volume  \
# 2016-07-19 23:00:00   18503.12   18542.13  18495.11    18522.47            0
# 2016-07-19 23:30:00   18522.44   18553.30  18509.25    18546.27            0
# 2016-07-20 00:00:00   18546.20   18549.59  18519.77    18539.93            0
# 2016-07-20 00:30:00   18540.24   18549.80  18526.99    18534.18            0
# 2016-07-20 01:00:00   18534.05   18540.38  18507.34    18516.41            0
# ...                        ...        ...       ...         ...          ...