Skip to content

Commit

Permalink
Add position intent to PlaceOrderRequest (#294)
Browse files Browse the repository at this point in the history
* chore: added position intent to entities.go

* chore: added position intent to PlaceOrderRequest type

* chore: moved side constants below type declaration
  • Loading branch information
ankitsridhar16 authored Jul 9, 2024
1 parent 66a52e0 commit 8642da9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
9 changes: 9 additions & 0 deletions alpaca/entities.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,15 @@ const (
Sell Side = "sell"
)

type PositionIntent string

const (
BuyToOpen PositionIntent = "buy_to_open"
BuyToClose PositionIntent = "buy_to_close"
SellToOpen PositionIntent = "sell_to_open"
SellToClose PositionIntent = "sell_to_close"
)

type OrderType string

const (
Expand Down
31 changes: 16 additions & 15 deletions alpaca/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,21 +518,22 @@ func (c *Client) GetOrders(req GetOrdersRequest) ([]Order, error) {
}

type PlaceOrderRequest struct {
Symbol string `json:"symbol"`
Qty *decimal.Decimal `json:"qty"`
Notional *decimal.Decimal `json:"notional"`
Side Side `json:"side"`
Type OrderType `json:"type"`
TimeInForce TimeInForce `json:"time_in_force"`
LimitPrice *decimal.Decimal `json:"limit_price"`
ExtendedHours bool `json:"extended_hours"`
StopPrice *decimal.Decimal `json:"stop_price"`
ClientOrderID string `json:"client_order_id"`
OrderClass OrderClass `json:"order_class"`
TakeProfit *TakeProfit `json:"take_profit"`
StopLoss *StopLoss `json:"stop_loss"`
TrailPrice *decimal.Decimal `json:"trail_price"`
TrailPercent *decimal.Decimal `json:"trail_percent"`
Symbol string `json:"symbol"`
Qty *decimal.Decimal `json:"qty"`
Notional *decimal.Decimal `json:"notional"`
Side Side `json:"side"`
Type OrderType `json:"type"`
TimeInForce TimeInForce `json:"time_in_force"`
LimitPrice *decimal.Decimal `json:"limit_price"`
ExtendedHours bool `json:"extended_hours"`
StopPrice *decimal.Decimal `json:"stop_price"`
ClientOrderID string `json:"client_order_id"`
OrderClass OrderClass `json:"order_class"`
TakeProfit *TakeProfit `json:"take_profit"`
StopLoss *StopLoss `json:"stop_loss"`
TrailPrice *decimal.Decimal `json:"trail_price"`
TrailPercent *decimal.Decimal `json:"trail_percent"`
PositionIntent PositionIntent `json:"position_intent"`
}

type TakeProfit struct {
Expand Down

0 comments on commit 8642da9

Please sign in to comment.