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

feat: Extend Order API with commission_type #462

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

matebudai
Copy link
Contributor

@matebudai matebudai commented May 27, 2024

Context

Extend Order API with a new field called commission_type.

Possible values:

  • notional(default, API backward compatible so that when type is not specified notional is assumed)
  • qty(charge commission on a per quantity basis, which make it possible to charge commission on per contract basis in case of options)
  • bps
class CommissionType(str, Enum):
    """
    Represents the available ways of charging commission. This determines how
    the value in the commission field is interpreted.
    """

    NOTIONAL = "notional"
    BPS = "bps"
    QTY = "qty"

Changes

  • Introduce the new enum type.
  • Extend broker API order request model with the new field.
  • poetry update black

@matebudai matebudai requested a review from hiohiohio as a code owner May 27, 2024 12:25
Copy link
Contributor

@hiohiohio hiohiohio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM! Left small comments.

alpaca/broker/requests.py Show resolved Hide resolved
@@ -0,0 +1,182 @@
from alpaca.broker.client import BrokerClient
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

tests/broker/broker_client/test_order_commission_routes.py Outdated Show resolved Hide resolved
tests/broker/broker_client/test_order_commission_routes.py Outdated Show resolved Hide resolved
tests/broker/broker_client/test_order_commission_routes.py Outdated Show resolved Hide resolved
tests/broker/broker_client/test_order_commission_routes.py Outdated Show resolved Hide resolved
assert reqmock.call_count == 2
assert isinstance(mo_response, Order)
assert mo_response.status == OrderStatus.ACCEPTED
assert mo_response.commission == 1.25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something like this?

Suggested change
assert mo_response.commission == 1.25
assert mo_response.commission == 0
assert mo_response.commission_bps == 100

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.
efc9a61

@matebudai matebudai marked this pull request as draft May 30, 2024 12:24
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

Successfully merging this pull request may close these issues.

2 participants