Skip to content

Stock-Monitoring-App#15

Open
gold-amaechi wants to merge 2 commits intoalexnaylor99:mainfrom
gold-amaechi:main
Open

Stock-Monitoring-App#15
gold-amaechi wants to merge 2 commits intoalexnaylor99:mainfrom
gold-amaechi:main

Conversation

@gold-amaechi
Copy link

Hi Alex, I hope you are able to see my script.

# The event name I set up in my IFTTT applet.
ifttt_event_name = 'stock_price_drop'

# My IFTTT webhook key.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment not necessary, your variable name is clear enough.

I have to index with:.iloc, if not an alert appears, warning that method of indexing may change in a future Pandas version. It suggests using the iloc method to ensure it is compatible with future versions. '''
def get_stock_price(stock):
stock_data = yf.Ticker(stock)
price = stock_data.history(period='1d')['Close'].iloc[0] # I had to add .iloc here (explained above).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can save a line of code by directly returning line 23 instead of creating a variable

url = f'https://maker.ifttt.com/trigger/{ifttt_event_name}/with/key/{ifttt_webhook_key}'
response = requests.post(url, json=notification)
print(f'Notification sent: {notification}')
print('£' * 50)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this line is here. Was it a test?

stocks = ['TSLA', 'AAPL', 'MSFT', 'GOOGL', 'NKE']

# This is a dictionary that stores the previous prices of the stocks.
previous_prices = {}
Copy link

@virginiacodes virginiacodes Oct 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add key and value of 0 to your dictionary so it gets updated in your function. {'TSLA': 0, etc...

import time # Provide functions related to time and delays.

# The event name I set up in my IFTTT applet.
ifttt_event_name = 'stock_price_drop'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Const can be written in all caps :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants