Daily automatic update of stock quotes via REST API and Cronjob. Or is there a more sophisticated way?
I'm building a stock database with WordPress. There is a custom Post Type stocks
with the fields last_price
and ytd_return
(ACF). The database will hold around 2000 stocks.
For the stock quotes I plan to use alphavantage (https://www.alphavantage.co) which offers a REST API to pull updated quotes.
As I only want end-of-day data I plan the following: Every night run a "CronJob" inside Wordpress which pulls the updated stock quotes for all the stocks and calculates YTD performance.
Now the question:
What is the most straightforward way to do this?
Is it wise to loop through all my posts (stocks) and use wp_remote_get()
to update the data?
I expect to get problems with php execution times...
Or is there a better way to accomplish my goal with another php solution? For example I thought about setting up an own table in the sql db and insert the new data there.
Topic wp-remote-get json api Wordpress
Category Web