Hello everyone,
I am having an issue with selling shares. What I have done is define the number of shares as:
number_of_shares = int(cash/most_recent_price)
and then have the algorithm purchase these shares after certain requirements are met by saying:
order(context.security, +number_of_shares)
This seems to work but the problem arises when I try to sell the shares by saying:
order(context.security, -number_of_shares)
This does not seem to sell all the shares, but instead only like 7 or 10 shares and my algorithm ends up losing more money. I think my problem is trying to define the amount.
Any suggestions?
Thanks,
Alex