So I'm pretty new to the world of tech and coding. I have a python script that i would like to host on google cloud platform, so it can continuously scrape yahoo finance and save prices at 5min intervals. Im able to run it on my personal machine but struggle to get it up on GCP. I already made an account a compute engine. Im just not sure where i need to go to install the extra packages and then run the script.
!pip install numpy
!pip install pandas
!pip install yfinance
!pip install datetime
from pandas_datareader import data as pdr
import yfinance as yf
import datetime
import pandas as pd
import numpy as np
def test_yfinance():
# list of stocks, ETF, Currencies you would like to test or trade
for symbol in ['SPY', 'AAPL', 'MSFT', 'IWO', 'VFINX']:
# START DATE FOR THE BACKTEST
data = yf.download(symbol, start='1993-01-01', interval='5')
# SAVE DATA TO THIS LOCATION AS A CSV AND XLSX FILE
data.to_csv("/content/drive/MyDrive/yfinanceData/stocks/{}.csv".format(symbol))
if __name__ == "__main__":
test_yfinance()
I was running this code on Googles Colaboratory's Jupyter Notebook
The VM instances that im running on GCP is Ubuntu-Pro-1604-xenial