Stock /investment auto imports

Viewing 9 reply threads
  • Author
    Posts
  • September 21, 2020 at 10:33 AM #42006

    matt coxon
    Participant

    Hi 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
    Matt

    September 21, 2020 at 2:41 PM #42007

    Daniel Leu
    Participant

    You 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 coxon
    Participant

    hi Daniel, great, thank you I’ll try it out later

    much appreciated
    Matt

    September 24, 2020 at 8:10 AM #42026

    matt coxon
    Participant

    Thanks again , it worked

    September 24, 2020 at 8:54 AM #42027

    Daniel Leu
    Participant

    Great! 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 Romano
    Participant

    How does one enter the results into a record with files of the same name?

    June 14, 2023 at 6:35 PM #49596

    Brendan
    Keymaster

    Hi 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 Romano
    Participant

    I’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 Leu
    Participant

    The 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 Romano
    Participant

    Brilliant!. 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 Leu
    Participant

    Great! Sometimes you have to click on the Recalculate formulas button for changes to become visible ☹️

Viewing 9 reply threads

You must be logged in to reply to this topic.