Tap Forms – Organizer Database App for Mac, iPhone, and iPad › Forums › Script Talk › Stock /investment auto imports
- This topic has 10 replies, 4 voices, and was last updated 1 year, 5 months ago by Daniel Leu.
-
AuthorPosts
-
September 21, 2020 at 10:33 AM #42006
matt coxonParticipantHi everyone , is there a way to import stock and fund prices directly into tapforms. I currently do this with google sheets mostly using the importhtml function. But would really like to transfer to tap fit for it .I’ve had a look through the forums but can’t find similar
Thanks
All
MattSeptember 21, 2020 at 2:41 PM #42007
Daniel LeuParticipantYou mean to get the current stock price? There are many APIs out there. Here is a free one for low volume requests:
const APIKEY = "your-api-key"; let symbol = 'ibm'; let url = 'https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol='+symbol+'&apikey='+APIKEY; var d = Utils.getJsonFromUrl(url) console.log(JSON.stringify(d, null, 3));
You can get your own API key from https://www.alphavantage.co/support/#api-key
September 22, 2020 at 12:57 AM #42012
matt coxonParticipanthi Daniel, great, thank you I’ll try it out later
much appreciated
MattSeptember 24, 2020 at 8:10 AM #42026
matt coxonParticipantThanks again , it worked
September 24, 2020 at 8:54 AM #42027
Daniel LeuParticipantGreat! Just watch out for the limits that the free API imposes: max 500 requests per day, 5 per minute!
June 14, 2023 at 4:22 PM #49590
Steve RomanoParticipantHow does one enter the results into a record with files of the same name?
June 14, 2023 at 6:35 PM #49596
BrendanKeymasterHi Steve,
Are you referring to the topic of this thread about fetching stock quotes from a web service?
Could you please elaborate a bit more about what you mean and what you’re trying to achieve with regards to this?
Thanks,
Brendan
June 15, 2023 at 2:57 AM #49600
Steve RomanoParticipantI’d like to populate a record with the results of the API.
Running the API provides this via console.log
{
“Global Quote”: {
“09. change”: “0.6400”,
“10. change percent”: “0.3491%”,
“01. symbol”: “AAPL”,
“05. price”: “183.9500”,
“06. volume”: “56522724”,
“04. low”: “182.0200”,
“02. open”: “183.3700”,
“07. latest trading day”: “2023-06-14”,
“03. high”: “184.3900”,
“08. previous close”: “183.3100”
}
}
June 15, 2023 at 7:53 AM #49601
Daniel LeuParticipantThe result is stored in the variable d. So you can take this and store the values in their respective fields.
record.setFieldValue(symbol_field_id, d["Global Quote"]["01. symbol"]); ... document.saveAllChanges();
Most likely you want to create a new record where you save all these information so you can do some analysis over time.
The JavaScript API documentation is here: https://www.tapforms.com/help-mac/5.3/en/topic/javascript-api
June 15, 2023 at 11:54 AM #49603
Steve RomanoParticipantBrilliant!. Thank you it works…But the form doesn’t update. I have to close the database/document and reopen to see the results. I am executing the operation with form level script and I am using the “document.saveAllChange();” command but it doesn’t show results until I close and reopen.
Thoughts?
Thanks again!
June 15, 2023 at 2:36 PM #49604
Daniel LeuParticipantGreat! Sometimes you have to click on the
Recalculate formulas
button for changes to become visible ☹️ -
AuthorPosts
You must be logged in to reply to this topic.