A TD Ameritrade API client for Python. Includes historical data for equities and ETFs, options chains, streaming order book data, complex order construction, and more.
orderSym has the value 'FDX' and orderQty has the value 1 with class int
Expected Behavior
I am expecting this code to place a market buy to close order.
Actual Behavior
Results in ValueError: quantity must be positive
Error/Exception Log, If Applicable
Traceback (most recent call last):
File "C:\Users\Robert\Anaconda3\envs\tda-api_1.6.0\Scripts\trading_strategy_TSX2_local_PC_version_long_and_short_trades_2022_11-28.py", line 914, in
placeOrderReturnValue = placeOrder(client = client_short,
File "C:\Users\Robert\Anaconda3\envs\tda-api_1.6.0\Scripts\trading_strategy_TSX2_local_PC_version_long_and_short_trades_2022_11-28.py", line 376, in placeOrder
closeShortMarketOrder = (equity_buy_to_cover_market(symbol = orderSym,
File "C:\Users\Robert\Anaconda3\envs\tda-api_1.6.0\lib\site-packages\tda\orders\equities.py", line 133, in equity_buy_to_cover_market
return (OrderBuilder()
File "C:\Users\Robert\Anaconda3\envs\tda-api_1.6.0\lib\site-packages\tda\orders\generic.py", line 442, in add_equity_leg
return self.__add_order_leg(
File "C:\Users\Robert\Anaconda3\envs\tda-api_1.6.0\lib\site-packages\tda\orders\generic.py", line 418, in __add_order_leg
raise ValueError('quantity must be positive')
ValueError: quantity must be positive
Windows 10 Python 3.9 in a conda environment tda-api version 1.6.0
Description of Bug When calling
equity_buy_to_cover_market()
my script raises ValueError: quantity must be positiveCode to Reproduce This is line 376 as referenced in the error message
orderSym
has the value 'FDX' andorderQty
has the value 1 with class intExpected Behavior I am expecting this code to place a market buy to close order.
Actual Behavior Results in ValueError: quantity must be positive
Error/Exception Log, If Applicable Traceback (most recent call last): File "C:\Users\Robert\Anaconda3\envs\tda-api_1.6.0\Scripts\trading_strategy_TSX2_local_PC_version_long_and_short_trades_2022_11-28.py", line 914, in
placeOrderReturnValue = placeOrder(client = client_short,
File "C:\Users\Robert\Anaconda3\envs\tda-api_1.6.0\Scripts\trading_strategy_TSX2_local_PC_version_long_and_short_trades_2022_11-28.py", line 376, in placeOrder
closeShortMarketOrder = (equity_buy_to_cover_market(symbol = orderSym,
File "C:\Users\Robert\Anaconda3\envs\tda-api_1.6.0\lib\site-packages\tda\orders\equities.py", line 133, in equity_buy_to_cover_market
return (OrderBuilder()
File "C:\Users\Robert\Anaconda3\envs\tda-api_1.6.0\lib\site-packages\tda\orders\generic.py", line 442, in add_equity_leg
return self.__add_order_leg(
File "C:\Users\Robert\Anaconda3\envs\tda-api_1.6.0\lib\site-packages\tda\orders\generic.py", line 418, in __add_order_leg
raise ValueError('quantity must be positive')
ValueError: quantity must be positive