aggregated distinct positions from trades

1
I'm very new to Mendix - first time poster - so please bear with me! I have a financial application which reports aggregate 'Positions' on a series of 'Trades'. A trade is an individual buy or sell transaction of a given financial instrument for a given 'Quantity' (+ve/-ve for buy/sell) for a given price. A 'Position' is the aggregate 'Quantity' of all trades for each distinct 'Instrument Code' appearing in the 'trades' database/entity. In my domain model I have a 'trades' entity that has attributes : Instrument Code - the transacted financial instrument code. Quantity - how many units of the instrument that were bought/sold. Price - the unit price the transaction. Plus lots of other attributes. I'm looking to construct a microflow that will create a list of all these positions. So I would have something that listed : Instrument Code - the distinct transacted financial instrument codes. Aggregate Quantity - the sum of the quantities for all trades of the given distinct instrument codes. How would I achieve this? A 'view'/none-persistable-entity/a Data Grid with Xpath constraints of some sort?? Does OQL play a part - is it still part in 4.4.4 - would it help if it was? I'm sure this is trivial - and I'm once I know, the Mendix paradigm will start to become clearer for me. Thanks!
asked
2 answers
1

You cannot group a retrieve that easily because it does not let you do a distinct retrieve in that way. However what you can do is create a new entity, if you do not already have that, called instrument type. Instead of each trade having a instrument code you could link it to an instrument type that has the code.

Then when you want to generate your positions for all codes you retrieve all instrument types, which should return a distinct list of your codes and from there you retrieve and agregate the trades connected to each code.

answered
1

Thanks, Pieter. I solved this along the lines you mention by using the instrument type I already had. However, instead of retrieving all instrument types, I created a list of unique instruments from all the trades. I did this because there are many instruments that have not been traded.

answered