How do I get the current (theoretical or actual) market position, either in aggregate, or for a specific security?

exitLong() throws an error message if the market position <= 0. To avoid that I want to check first if the marketPosition >= 0.

I have searched for:

- Position
- MarketPosition
- getPosition