Order quantity not matching up with positions

Currently, I am paper trading through Python 3.10, using the API instead of the SDK.

I’m trying to place purchase orders for a specific amount of crypto and once a target is met, the position will be liquidated. I noticed lately I sometimes get “leftovers” after trading.

As an example, I would have holdings in LTC/USD for quantities around 0.001. As a result, I am unable to liquidate the position (since the smallest allowed quantity is 0.01).

This amount shouldn’t be the difference in quantity in buy and sell orders for the following reasons:

  1. I am using FOK time-in-force, which should mean I will be getting the whole order amount.

  2. I am not using sell orders, but instead using a close position endpoint, which means I should be liquidating all holdings in a given position.

I have noticed that sometimes I get a partial fill even with FOK, so perhaps that is relevant?
I have gone through my code to make sure I am ordering the correct quantities.
Any ideas on how to avoid this issue?

Code for orders

order = requests.post(
            '{0}/v2/orders'.format(ALPACA_BASE_URL), headers=HEADERS, json={
                'symbol': symbol,
                'qty': qty,
                'side': side,
                'type': 'market',
                'time_in_force': 'fok',

Code for closing position

order = requests.delete('{0}/v2/positions/{1}'.format(ALPACA_BASE_URL, symbol),