Forums

"The error only occurs in the scheduled task

.

import FinanceDataReader as fdr

df_f = fdr.DataReader("US500", "2023-08-01", "2023-08-23")

The above code generates an error when run as a scheduled task. The code runs normally when executed directly or as an Always On task. The error message generated by the scheduled task is as follows.

HTTP Error 401: Unauthorized  - symbol "US500"not found or invalid periods

It does not appear that the execution of the code and the execution of the scheduled task are performed on different servers. I am writing to inquire about this.

I apologize for my poor English.

[edit by admin: formatting]

Your code runs on different servers depending which feature you use. Could you run the sam command as you use in the scheduled task in a Bash console and check if that would work?

It works well in the Bash console. Why does it only have problems in Scheduled Task? Thank you for your help.

Could you show us the command you use to run the task? Also -- did you change your ~/.bashrc file?

python3.7 /home/jhyunByun/INVEST_DATA_Daily.py

The task command and command in bash console are as shown above, and Bashrc file was not modified.

What service is it connecting to? It might have blocked one of our machines running Scheduled Tasks.

I was able to successfully receive the S&P 500 index price starting Monday. It seems that the target server blocked the Scheduled Tasks for some reason. Thank you for your help.

Glad to hear it's working now, at least!