Dashboards are useful for visualizing and simplifying large amounts of data. For example, you can create an internet-of-things (IoT) dashboard that displays information about your home's thermostat, door locks, security cameras, and environmental sensors. Or you can create a dashboard that compares a stock's price to a market index to evaluate the stock's performance. The dashboard can visualize data with a true/false display and a line chart.
This tutorial shows you how to create a stock performance dashboard using test data from a Postman mock server. You can view the completed flow in the Utility Flows workspace.
Create a flow that quantifies a stock's performance by comparing it to a market index.
Begin by forking (copying) the stocks collection and the stocks-tutorial environment from the Utility Flows workspace to your workspace. In your fork of the stocks-tutorial environment, replace the <your-api-key>
value with your Polygon.io API key and select Save.
In the first two HTTP Request blocks, select the get the close price request. In the third HTTP Request block, select the get stock SMA request.
In the first HTTP Request block, select the stocks-tutorial environment. Flows prompts you to select the same environment for the other two HTTP Request blocks. Select Update All.
Add a String block to assign the VOO
market index to the ticker
variable in the first request. The flow will compare your stock's performance to this index to check if your stock is outperforming the market.
Add another String block to assign AAPL
to the ticker
variables in the second and third HTTP Request blocks.
Connect an Evaluate block to the first HTTP Request block. Change value
to benchmark
and select body
.
In the FQL window, enter "((benchmark.close - benchmark.open) / benchmark.open) * 100". This will get a percentage of the difference between the VOO
index's open and close price.
Connect another Evaluate block to the Evaluate block you created. In the FQL window, enter "value2 > value1". You'll add value2
in a later step.
Connect a Display block to the value2 > value1
Evaluate block and select Boolean from the dropdown list.
Go back to the second HTTP Request block and connect an Evaluate block to it. In this new Evaluate block, change value1
to yours
and select body
. In the FQL window, enter "((yours.close - yours.open) / yours.open) * 100" to get a percentage of the difference between this stock's open and close price.
key
input on the value2 > value1
block. Flows automatically renames the variable value2
.Connect the yours
Evaluate block to a new Display block and select Gauge from the dropdown list. Set the Gauge output block's minimum value to -5
and its maximum value to 5
.
AAPL
String block with to a Display block and rename the Display block Your ticker
.Go back the third HTTP Request block and connect a Select block to it. In the Select block, select body.results.values
. Connect an Evaluate block to the Select block and rename value1
to list
. In the FQL window, enter "$reverse(list)". This arranges the dates in the results in chronological order.
Connect a For block to the $reverse(list)
Evaluate block, then connect an Evaluate block to the For block. In the Evaluate block, change value1
to item
. In the FQL window, enter "$month(item.timestamp) & '-' & $day(item.timestamp)". This converts timestamps in the results to a readable date format. Connect a Collect block to the Evaluate block's Result output.
Connect another Evaluate block to the $reverse(list)
Evaluate block and rename value1
to list
. In the FQL window, enter "list.value".
Create a List block and add two Select blocks to it. Connect the list.value
Evaluate block to the List block's 0
input. Connect the Collect block's List output to the List block's 1
input.
Simple moving average
.Run the flow and check your dashboard of Display blocks. Use it to view your stock ticker, if your stock is outperforming or underperforming the market, and how much it's outperforming or underperforming. You can also view a chart displaying the stock's simple moving average.
Last modified: 2025/01/25
Additional resources
Blog posts