Help

Can someone help me with this stock quote script?

Topic Labels: Integrations
1802 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Mark_Fleming
6 - Interface Innovator
6 - Interface Innovator

I’m trying to get a stock quote script to work for me. I’m not someone that understands scripts, but I think I have it right. Although something is wrong and not sure what.

The API is from financialmodelingprep.com/developer/docs/, which I found mentioned in this forum.

When I run it I get this result:

Blockquote Updating stock prices

Updating price of aapl…
Can’t update the price of stock with no name
Can’t update the price of stock with no name
aapl’s price right now is: $undefined

Done!

Here is the script I have, with the field names changed to my field names (Symbol, Price, Price Date)

(Sorry for the way the code looks below, not sure how to paste in code)

output.markdown ("# Updating stock prices");

let table = base.getTable (“Holdings”),
records = await table.selectRecordsAsync ();

await Promise.all (

records.records.map (async record => {

    let stock = record.getCellValue ("Symbol");

    if (! stock) {

        output.text ("Can't update the price of stock with no name");

        return;
    }

    output.text (`Updating price of ${stock}...`);

    // make request
    var requestResult = await fetch (
        `https://financialmodelingprep.com/api/v3/stock/real-time-price/${stock}`
    ).then (r => r.json ());

    // print fetched data
    output.markdown (`${stock}'s price right now is: **$${requestResult.price}**`)

    // update record in table
    return await table.updateRecordAsync (record, {
        "Price": requestResult.price,
        "Price Date": new Date ()
    });
})

);
output.markdown ("# Done!");

1 Reply 1
ron_w
4 - Data Explorer
4 - Data Explorer

Hello,

I hope you’re doing great!

I would be happy to work with you. Please give me a suitable time to discuss your requirements. looking forward to hearing from you
Thanks and regards
ron