# Postman Visualizer Example with Stock Trading Data

**URL:** <https://community.postman.com/t/postman-visualizer-example-with-stock-trading-data/8964>\
**Category:** Help Hub\
**Tags:** visualizer\
**Created:** [November 12, 2019, 4:34pm UTC](https://community.postman.com/t/postman-visualizer-example-with-stock-trading-data/8964 "2019-11-12T16:34:14Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![odanylewycz](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/odanylewycz/32/3240_2.png) [@odanylewycz](https://community.postman.com/u/odanylewycz)\
**Post date:** [November 12, 2019, 4:34pm UTC](https://community.postman.com/t/postman-visualizer-example-with-stock-trading-data/8964/1 "2019-11-12T16:34:14Z")

</div>

Hi everyone!

I made a Postman Visualizer tutorial and breakdown that I thought would be helpful. I based it on an existing template they had, and created one with financial data from [worldtradingdata.com](http://worldtradingdata.com), showing stock performance over the day.

How to Visualize Data in Postman

[![](https://img.youtube.com/vi/EFoelwSszoU/maxresdefault.jpg "How to Visualize Data in Postman") ](https://www.youtube.com/watch?v=EFoelwSszoU)

Hope this is helpful!

Thanks,  
Orest

---

<div class="post-metadata">

**Author:** ![jetison](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/jetison/32/12_2.png) [@jetison](https://community.postman.com/u/jetison)\
**Post date:** [November 12, 2019, 5:23pm UTC](https://community.postman.com/t/postman-visualizer-example-with-stock-trading-data/8964/2 "2019-11-12T17:23:43Z")

</div>

🏆 Nicely done @odanylewycz !

---

<div class="post-metadata">

**Author:** ![odanylewycz](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/odanylewycz/32/3240_2.png) [@odanylewycz](https://community.postman.com/u/odanylewycz)\
**Post date:** [November 12, 2019, 5:54pm UTC](https://community.postman.com/t/postman-visualizer-example-with-stock-trading-data/8964/3 "2019-11-12T17:54:29Z")

</div>

Thank you @jetison! 😄

---

<div class="post-metadata">

**Author:** ![thomas.zdon](https://avatars.discourse-cdn.com/v4/letter/t/6a8cbe/32.png) [@thomas.zdon](https://community.postman.com/u/thomas.zdon)\
**Post date:** [November 18, 2019, 11:44am UTC](https://community.postman.com/t/postman-visualizer-example-with-stock-trading-data/8964/4 "2019-11-18T11:44:39Z")

</div>

Great video… but I’m really struggling with how to get to data in more complex arrays. Where would you suggest I start to learn how to acccess these? For example - I may have an array of 'portfolio’s - each with an array of securities and values, followed by an array of totals. I tried your object.keys and object.values but can’t get to where I need to … any hints on where to go to learn apprediated.

---

<div class="post-metadata">

**Author:** ![odanylewycz](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/odanylewycz/32/3240_2.png) [@odanylewycz](https://community.postman.com/u/odanylewycz)\
**Post date:** [November 18, 2019, 1:17pm UTC](https://community.postman.com/t/postman-visualizer-example-with-stock-trading-data/8964/5 "2019-11-18T13:17:09Z")

</div>

Hi @thomas.zdon!

Thanks for watching my video! 🙂

Now as for accessing those values, and getting them back in an array, you can use lodash to do that.

For example, you have an array of porfolios, each with an array of securities.

To first get access to it, I assume we have a an object named `results`

To get your porfolios array, we can do:

```
var portfolios = results.porfolios

```

Now to get all the securities values, we can do this:

```
var securities = _.map(Object.values(porfolios), 'securities')

```

That should get you the values of all the securities in an array.

If you needed to go even deeper, just start with a deeper nested object, and then use lodash to put them together. Assuming totals is under securities…

```
var totals = _.map(Object.values(results.porfolios.securities), 'totals')

```

This should get you an array of all the totals.

I did not explicitly test this code out, but it should work.

If you have an example to provide, I can gladly test it out against it to validate that this works 🙂

In terms of finding places to learn this more, I would start with Lodash.

> **[Lodash](https://lodash.com)**
>
> A JavaScript utility library delivering consistency, modularity, performance, & extras.

Hope it helps!

Regards,  
Orest

---

<div class="post-metadata">

**Author:** ![thomas.zdon](https://avatars.discourse-cdn.com/v4/letter/t/6a8cbe/32.png) [@thomas.zdon](https://community.postman.com/u/thomas.zdon)\
**Post date:** [November 18, 2019, 1:42pm UTC](https://community.postman.com/t/postman-visualizer-example-with-stock-trading-data/8964/6 "2019-11-18T13:42:23Z")

</div>

Thank you - I will definately try out lodash. Here is my json:

```
{
    "report": {
        "title": "Test Adhoc Report",
        "periodInclusionTime": "2018-08-09T12:00:00Z",
        "reportGenerationStarted": "2019-11-18T13:38:32.220381Z",
        "reportGenerationCompleted": "2019-11-18T13:38:32.377346Z",
        "metadata": {
            "columnTypes": {
                "assetType": "STRING",
                "strategy": "STRING",
                "financialAccount": "STRING",
                "manager": "STRING",
                "basket": "STRING",
                "symbol": "STRING",
                "quantity": "DOUBLE",
                "nativeCost": "DOUBLE",
                "bookMarketValuePercent": "DOUBLE",
                "reportMarketValuePercent": "DOUBLE"
            },
            "columnTotalMethods": {
                "assetType": "NONE",
                "strategy": "NONE",
                "financialAccount": "NONE",
                "manager": "NONE",
                "basket": "NONE",
                "symbol": "NONE",
                "quantity": "SUM",
                "nativeCost": "SUM",
                "bookMarketValuePercent": "SUM",
                "reportMarketValuePercent": "SUM"
            }
        },
        "portfolios": [
            {
                "portfolioName": "Control",
                "groups": [
                    {
                        "groupName": "United States of America",
                        "data": [
                            {
                                "assetType": "EQUITY",
                                "strategy": "Unicorn LS",
                                "financialAccount": "On Hand",
                                "manager": "SUID12Z34V3QWKL45",
                                "basket": "Basket001",
                                "symbol": "A",
                                "quantity": 2100,
                                "nativeCost": 141800.23,
                                "bookMarketValuePercent": 0.6637931034482759,
                                "reportMarketValuePercent": 0.6637931034482759
                            },
                            {
                                "assetType": "EQUITY",
                                "strategy": "Unicorn LS",
                                "financialAccount": "On Hand",
                                "manager": "SUID12Z34V3QWKL45",
                                "basket": "Basket001",
                                "symbol": "AABA",
                                "quantity": 750,
                                "nativeCost": 1000,
                                "bookMarketValuePercent": 0.33620689655172414,
                                "reportMarketValuePercent": 0.33620689655172414
                            },
                            {
                                "assetType": "EQUITY",
                                "strategy": "Asia Growth",
                                "financialAccount": "On Hand",
                                "manager": "SUID13Z34V3QWKL12",
                                "basket": "Basket002",
                                "symbol": "AA",
                                "quantity": 0,
                                "nativeCost": 0,
                                "bookMarketValuePercent": 0,
                                "reportMarketValuePercent": 0
                            }
                        ],
                        "total": {
                            "quantity": 2850,
                            "nativeCost": 142800.23,
                            "bookMarketValuePercent": 1,
                            "reportMarketValuePercent": 1
                        }
                    }
                ],
                "total": {
                    "quantity": 2850,
                    "nativeCost": 142800.23,
                    "bookMarketValuePercent": 1,
                    "reportMarketValuePercent": 1
                }
            }
        ]
    },
    "request": {
        "tenantId": 6,
        "knowledgeTime": "2018-08-09T23:59:59Z",
        "reportTime": "2018-08-09T12:00:00Z",
        "portfolioIds": [
            2
        ],
        "currencyId": 148,
        "priceSourceGroupId": 0,
        "fxPriceSourceGroupId": 3,
        "validationRuleCollectionId": 1,
        "bookId": 0,
        "adhocReport": {
            "title": "Test Adhoc Report",
            "columns": [
                {
                    "columnType": "ASSET_TYPE"
                },
                {
                    "columnType": "SYMBOL"
                },
                {
                    "columnType": "FINANCIAL_ACCOUNT"
                },
                {
                    "columnType": "MANAGER"
                },
                {
                    "columnType": "STRATEGY"
                },
                {
                    "columnType": "BASKET"
                },
                {
                    "columnType": "QUANTITY"
                },
                {
                    "columnType": "NATIVE_COST"
                },
                {
                    "columnType": "BOOK_MARKET_VALUE_PERCENT"
                },
                {
                    "columnType": "REPORT_MARKET_VALUE_PERCENT"
                }
            ],
            "groups": [
                {
                    "groupType": "NATION"
                }
            ],
            "filters": [
                {
                    "filterType": "ASSET_TYPE",
                    "value": 0
                }
            ]
        }
    }
}
```

---

<div class="post-metadata">

**Author:** ![thomas.zdon](https://avatars.discourse-cdn.com/v4/letter/t/6a8cbe/32.png) [@thomas.zdon](https://community.postman.com/u/thomas.zdon)\
**Post date:** [November 18, 2019, 1:44pm UTC](https://community.postman.com/t/postman-visualizer-example-with-stock-trading-data/8964/7 "2019-11-18T13:44:03Z")

</div>

This was an easy one - the one that I need to get working ahs multiple countries - with each country having multiple securities with %'s that are then totaled. And what I am trying to map out is the bars should be the %'s by country.

---

<div class="post-metadata">

**Author:** ![odanylewycz](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/odanylewycz/32/3240_2.png) [@odanylewycz](https://community.postman.com/u/odanylewycz)\
**Post date:** [November 18, 2019, 6:53pm UTC](https://community.postman.com/t/postman-visualizer-example-with-stock-trading-data/8964/8 "2019-11-18T18:53:04Z")

</div>

Hi @thomas.zdon,

Thanks for the clarification!

Given the json you provided, its a little more complicated than what I had mentioned earlier.

I was grinding away at the json and I came up with this javascript that I believe should be what you need. However, if its not, please be a little more clear, such as providing the kind of json you want to create from the one you provided.

```
var obj = JSON.parse(jsonProvided)

```

`var portfolios = obj.report.portfolios`

```
var result = _.flatMap(portfolios, ({ groups }) => _.flatMap(groups, ({ data }) => _.map(data, item => ({ quantity: item.quantity }))));

```

`[{ quantity: 2100 }, { quantity: 750 }, { quantity: 0 }]`

`var totals1 = _.flatMap(portfolios, ({ groups }) => _.map(groups, group => ({ firstTotal: group.total.quantity })));`  
`[{ firstTotal: 2850 }]`

`var totals2 = _.map(portfolios, portfolio => ({ secondTotal: portfolio.total.quantity }));`  
`[{ secondTotal: 2850 }]`

Hope this helps!

Regards,  
Orest

---

<div class="post-metadata">

**Author:** ![thomas.zdon](https://avatars.discourse-cdn.com/v4/letter/t/6a8cbe/32.png) [@thomas.zdon](https://community.postman.com/u/thomas.zdon)\
**Post date:** [November 18, 2019, 7:22pm UTC](https://community.postman.com/t/postman-visualizer-example-with-stock-trading-data/8964/9 "2019-11-18T19:22:50Z")

</div>

wow. Thank you. How do I learn this?

Thomas Zdon

---

<div class="post-metadata">

**Author:** ![odanylewycz](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/odanylewycz/32/3240_2.png) [@odanylewycz](https://community.postman.com/u/odanylewycz)\
**Post date:** [November 18, 2019, 8:40pm UTC](https://community.postman.com/t/postman-visualizer-example-with-stock-trading-data/8964/10 "2019-11-18T20:40:19Z")

</div>

You’re welcome @thomas.zdon!

Its really my pleasure.

If I’m being brutally honest, I really don’t know all this that well. But I am familiar with the concepts enough in that I was able to google it quite a bit, get some code snippets from StackOverflow, use that to piece together the Javascript that I shared, after some trial and error to get it working 😄 .

Its mostly about understanding the concepts well enough. Once you do, you can piece together anything really.

Best way to learn is to just get out there and when you encounter something you don’t know, get to the concepts first. Then learn to apply them by just going out and trying to do whatever it is that you need to accomplish.

I know that’s a bit vague, but I’m just being honest. It’s at least how I learned this stuff (let alone most things in IT 😄)

Good Luck!  
Orest

---

<div class="post-metadata">

**Author:** ![thomas.zdon](https://avatars.discourse-cdn.com/v4/letter/t/6a8cbe/32.png) [@thomas.zdon](https://community.postman.com/u/thomas.zdon)\
**Post date:** [November 27, 2019, 1:24pm UTC](https://community.postman.com/t/postman-visualizer-example-with-stock-trading-data/8964/11 "2019-11-27T13:24:03Z")

</div>

Orest,

Tried this solution but Postman tells me \_.flatmap is not a function.

---

<div class="post-metadata">

**Author:** ![singhsivcan](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/singhsivcan/32/1595_2.png) [@singhsivcan](https://community.postman.com/u/singhsivcan)\
**Post date:** [November 27, 2019, 2:39pm UTC](https://community.postman.com/t/postman-visualizer-example-with-stock-trading-data/8964/12 "2019-11-27T14:39:56Z")

</div>

@thomas.zdon

You’ll have to require lodash (it’s the 4.x+ version)

```javascript
_ = require('lodash');

// Now you can use _.flatMap

```

---

<div class="post-metadata">

**Author:** ![odanylewycz](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/odanylewycz/32/3240_2.png) [@odanylewycz](https://community.postman.com/u/odanylewycz)\
**Post date:** [November 27, 2019, 2:44pm UTC](https://community.postman.com/t/postman-visualizer-example-with-stock-trading-data/8964/13 "2019-11-27T14:44:14Z")

</div>

@singhsivcan Beat me to it!

@thomas.zdon, that should suffice. My apologies for leaving it out. Additionally, not too sure if case matters, but I’d do \_.flatMap over \_.flatmap.

Let us know if this works!

—Orest

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [December 12, 2024, 2:46pm UTC](https://community.postman.com/t/postman-visualizer-example-with-stock-trading-data/8964/14 "2024-12-12T14:46:56Z")

</div>

Closed on December 12, 2024, 2:46pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
