Open
Conversation
| # The event name I set up in my IFTTT applet. | ||
| ifttt_event_name = 'stock_price_drop' | ||
|
|
||
| # My IFTTT webhook key. |
There was a problem hiding this comment.
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). |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 = {} |
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
Const can be written in all caps :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi Alex, I hope you are able to see my script.