Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Fractional Orders Error (APIError: qty must be integer) #156

Closed
2 tasks done
markolonius opened this issue Sep 6, 2022 · 2 comments
Closed
2 tasks done

[Bug]: Fractional Orders Error (APIError: qty must be integer) #156

markolonius opened this issue Sep 6, 2022 · 2 comments

Comments

@markolonius
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Using code from example in creating-an-order does not work.

from alpaca.trading.client import TradingClient
from alpaca.trading.requests import MarketOrderRequest
from alpaca.trading.enums import OrderSide, TimeInForce

trading_client = TradingClient('api-key', 'secret-key', paper=True)

# preparing orders
market_order_data = MarketOrderRequest(
                    symbol="SPY",
                    qty=0.023,
                    side=OrderSide.BUY,
                    time_in_force=TimeInForce.DAY
                    )

# Market order
market_order = trading_client.submit_order(
                order_data=market_order_data
               )

Code above produces error:
alpaca.common.exceptions.APIError: {"code":40010001,"message":"qty must be integer"}

When trying notional instead of qty causes error:
alpaca.common.exceptions.APIError: {"code":40010001,"message":"qty is required"}

Expected Behavior

above code should produce a market order request

SDK Version I encountered this issue in

alpaca-py version: 0.5.4

Steps To Reproduce

1. poetry new market_order_test
2. poetry add alpaca-py
3. run following example with poetry run python test.py:
`
from alpaca.trading.client import TradingClient
from alpaca.trading.requests import MarketOrderRequest
from alpaca.trading.enums import OrderSide, TimeInForce

trading_client = TradingClient('api-key', 'secret-key', paper=True)

# preparing orders
market_order_data = MarketOrderRequest(
                    symbol="SPY",
                    qty=0.023,
                    side=OrderSide.BUY,
                    time_in_force=TimeInForce.DAY
                    )

# Market order
market_order = trading_client.submit_order(
                order_data=market_order_data
               )
`

Filled out the Steps to Reproduce section?

  • I have entered valid steps to reproduce my issue or have attached a minimally reproducible case in code that shows my issue happening; and understand that without this my issue will be flagged as invalid and closed after 30 days.

Anything else?

seems similar to alpacahq/alpaca-trade-api-python#404

@markolonius
Copy link
Author

I was able to resolve this issue by resetting the paper trade account. This issue may be marked as close.

Should be in docs possibly as a troubleshoot to reset paper trade account with this issue or other similar.

@aoot
Copy link

aoot commented Jan 16, 2024

I was able to resolve this issue by resetting the paper trade account. This issue may be marked as close.

Should be in docs possibly as a troubleshoot to reset paper trade account with this issue or other similar.

Agree with @markolonius , I was having similar "qty is required" issue when notional value is specified on "BTC/USD" and the issue is gone when the paper trading account is reset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants