Everyone should have access to sentiment analysis project
The yellow mark indicates that the user has not accepted the invitation to join the project.
I can send again for people who want access. Just email me directly.
To access the compute engine navigate to the compute engine
Click on VM instances
Click on drop down arrow next to SSH
Open in browser window
Click Allow SSH-in-browser to connect to VMs.
You are now in the linux shell
Code is in /home/public
admin@instance-2:~$ cd /home/public
admin@instance-2:/home/public$
All code is in subdirectories
admin@instance-2:/home/public$ ls -lt
total 36
drwxr-xr-x 3 admin admin 4096 Jun 24 07:50 SnScrape
drwxr-xr-x 2 admin admin 4096 Jun 19 20:50 uconn
drwxr-xr-x 2 admin admin 4096 Jun 10 14:18 yahoo
drwxr-xr-x 2 admin admin 4096 Jun 9 19:52 pyex
drwxr-xr-x 3 admin admin 4096 Jun 8 22:17 sentiment-gcp-with-entities-v2
drwxr-xr-x 3 admin admin 4096 Jun 8 22:16 BERTvsGPTFinancialSentimentAnalysisAccuracy
drwxr-xr-x 4 admin admin 4096 Jun 8 22:16 Sentiment-gcp-v1
drwxr-xr-x 3 admin admin 4096 Jun 8 22:01 datastore
drwxrwxrwx 3 root root 4096 Jun 4 15:29 sec
admin@instance-2:/home/public$
admin@instance-2:/home/public/yahoo$ ls -lt
total 16
-rw-r--r-- 1 admin admin 286 Jun 26 00:52 yfa.py
-rw-r--r-- 1 admin admin 1738 Jun 25 15:24 yf-msft.py
-rw-r--r-- 1 admin admin 84 Jun 10 14:18 yfb.py
-rw-r--r-- 1 admin admin 1738 Jun 10 14:01 yf.py
admin@instance-2:/home/public/yahoo$
I can use yfa.py to get the latest price of apple stock
admin@instance-2:/home/public/yahoo$ cat yfa.py
import yfinance as yf
symbol = "AAPL"
stock = yf.Ticker(symbol)
latest_price = stock.history(period='1d')['Close'][0]
# Completely optional but I recommend having some sort of round(er?).
# Dealing with 148.60000610351562 is a pain.
estimate = round(latest_price, 2)
print (estimate)
admin@instance-2:/home/public/yahoo$
To execute I type
admin@instance-2:/home/public/yahoo$ python3 yfa.py
186.68
It returns the latest price of apple stock which is 186.68
You can copy the program and pick your own stock just replace the symbol AAPL with stock you want to get price for e.g.
admin@instance-2:/home/public/yahoo$ cp yfa.py yfn.py
Edit code to cover NVDA or Nvidia
admin@instance-2:/home/public/yahoo$ vim yfn.py
mport yfinance as yf
symbol = "NVDA"
stock = yf.Ticker(symbol)
latest_price = stock.history(period='1d')['Close'][0]
# Completely optional but I recommend having some sort of round(er?).
# Dealing with 148.60000610351562 is a pain.
estimate = round(latest_price, 2)
admin@instance-2:/home/public/yahoo$ python3 yfn.py
422.09
No comments:
Post a Comment