Title: Why my python (Spyder) got stuck (i.e. did not return result) when I was trying to run the code of retrieving stock data from yahoo finance · Issue #1 · LastAncientOne/SimpleStockAnalysisPython · GitHub
Open Graph Title: Why my python (Spyder) got stuck (i.e. did not return result) when I was trying to run the code of retrieving stock data from yahoo finance · Issue #1 · LastAncientOne/SimpleStockAnalysisPython
X Title: Why my python (Spyder) got stuck (i.e. did not return result) when I was trying to run the code of retrieving stock data from yahoo finance · Issue #1 · LastAncientOne/SimpleStockAnalysisPython
Description: I have a list of US stocks ( around 3000 stocks) in excel and I want to get the stock price and other related daily stock info on each stock in certain time period. So I wrote a for loop to get all related stock info on each stock ( and ...
Open Graph Description: I have a list of US stocks ( around 3000 stocks) in excel and I want to get the stock price and other related daily stock info on each stock in certain time period. So I wrote a for loop to get all...
X Description: I have a list of US stocks ( around 3000 stocks) in excel and I want to get the stock price and other related daily stock info on each stock in certain time period. So I wrote a for loop to get all...
Opengraph URL: https://github.com/LastAncientOne/SimpleStockAnalysisPython/issues/1
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Why my python (Spyder) got stuck (i.e. did not return result) when I was trying to run the code of retrieving stock data from yahoo finance","articleBody":"I have a list of US stocks ( around 3000 stocks) in excel and I want to get the stock price and other related daily stock info on each stock in certain time period. So I wrote a for loop to get all related stock info on each stock ( and I have tried both yahoo_fin.stock_info and yfinance packages). But then it just got stuck at certain stock and never return the result. I am using spyder for my python coding. below is the code:\r\n```\r\nimport pandas as pd\r\nimport numpy as np\r\nimport yahoo_fin.stock_info as si\r\n\r\nticker_list = pd.read_excel(r'C:\\Users\\user\\Desktop\\ticker_list.xlsx',engine=\"openpyxl\")\r\n\r\nn=[]\r\net=[] \r\ndf_empty=[]\r\nfor i in range(len(ticker_list)): \r\n try:\r\n df = df_empty[0:0]\r\n df=si.get_data(ticker_list.iloc[i]['ticker'], start_date='2021-09-30', end_date='2022-04-25') \r\n# I used yf.download for using yfinance package\r\n mkt_cap=si.get_quote_table(ticker_list.iloc[i]['ticker'])[\"Market Cap\"]\r\n df.insert (7,\"mkt_cap\",mkt_cap) \r\n print(ticker_list.iloc[i]['ticker'])\r\n df.replace(np.inf, np.nan) \r\n df = df.dropna()\r\n df.reset_index(inplace=True) \r\n n.append(df) \r\n except:\r\n et.append(ticker_list.iloc[i]['ticker'])\r\n print('error: ' + ticker_list.iloc[i]['ticker'])\r\n pass\r\nprint(n)\r\n```\r\nwhen I run the code below what it shows in my console:\r\n\r\n```\r\nPython 3.8.13 (default, Mar 28 2022, 06:59:08) [MSC v.1916 64 bit (AMD64)]\r\nType \"copyright\", \"credits\" or \"license\" for more information.\r\n\r\nIPython 7.31.1 -- An enhanced Interactive Python.\r\n\r\nrunfile('C:/Users/USER/get_all_stock_data.py', wdir='C:/Users/USER')\r\nBYDDY\r\nCHTR\r\nJD\r\nKYCCF\r\nRY-PT\r\nGE\r\nBP\r\nMO\r\nVLKPF\r\nSMAWF\r\nAMAT\r\n```\r\n\r\nI tired many times already , everytime it just stuck on different ticker everytime. Also I have also tried to leave the code running for a day but it just stop it right there and never give me return. when I tried to debug, it also stop running at either the si.get.data line or si.get_quote_table line. I actually use this code since last year and it work fine, it just start not working when I run this code again last week. I also tried several other packages ( e.g. pandas_datareader.data) still not able to get the stock info. Appreciate if anyone can let me know what is the problem.\r\n","author":{"url":"https://github.com/kk0186","@type":"Person","name":"kk0186"},"datePublished":"2022-04-29T09:49:27.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/1/SimpleStockAnalysisPython/issues/1"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3671073d-7a71-317a-c1a9-9a18d6e5c926 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 957C:168F99:A14219:D0036A:699082A5 |
| html-safe-nonce | 76ac4ef20bbba402ff88c55f856e1a7873fcec739ba0ff8682dadf50f4a5d99e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NTdDOjE2OEY5OTpBMTQyMTk6RDAwMzZBOjY5OTA4MkE1IiwidmlzaXRvcl9pZCI6IjE2MjY0MDMwMzA0MTU5OTk2NTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ba74763dee41292d65ac0cb6163d899d12a9e72199b4599b29dc0327bfd09f38 |
| hovercard-subject-tag | issue:1220385163 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/LastAncientOne/SimpleStockAnalysisPython/1/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e6add4b7592c1aede1fc53a687be16728ad71e88e779423869fe1c8dd44ff1b8/LastAncientOne/SimpleStockAnalysisPython/issues/1 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e6add4b7592c1aede1fc53a687be16728ad71e88e779423869fe1c8dd44ff1b8/LastAncientOne/SimpleStockAnalysisPython/issues/1 |
| og:image:alt | I have a list of US stocks ( around 3000 stocks) in excel and I want to get the stock price and other related daily stock info on each stock in certain time period. So I wrote a for loop to get all... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kk0186 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 42c603b9d642c4a9065a51770f75e5e27132fef0e858607f5c9cb7e422831a7b |
| turbo-cache-control | no-preview |
| go-import | github.com/LastAncientOne/SimpleStockAnalysisPython git https://github.com/LastAncientOne/SimpleStockAnalysisPython.git |
| octolytics-dimension-user_id | 4218171 |
| octolytics-dimension-user_login | LastAncientOne |
| octolytics-dimension-repository_id | 126881529 |
| octolytics-dimension-repository_nwo | LastAncientOne/SimpleStockAnalysisPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 126881529 |
| octolytics-dimension-repository_network_root_nwo | LastAncientOne/SimpleStockAnalysisPython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3b33c5aedc9808f45bc5fcf0b1e4404cf749dac7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width