Qluxzz / avanza

A Python library for the unofficial Avanza API
https://qluxzz.github.io/avanza/
MIT License
85 stars 40 forks source link

Get your volume of a asset part solved #58

Open HermanRoberth42quack opened 1 year ago

HermanRoberth42quack commented 1 year ago

i was using get_order_book() to get my volume. lets say i had bought a warrant or certificate or stock, and i want to program to sell my specific volume the get_order_book() was what I used, since its stopped I have a workaround.

if current_positions_value>100:

Position_volume=avanza.get_positions().get("instrumentPositions")[0].get("positions")[0].get("volume")

you need the first if statment since a account with no positions will return an error in .get("instrumentPositions")[0] since there are #no positions to get. so just use the if statment to stop the errors.

hope this is useful some