Releases: alpacahq/alpaca-trade-api-go
Add support for trailing stop orders
In this release we add support for the new added feature - trailing stop:
- submit_order now supports a new type
trailing_stop
. - 2 new optional args to submit_order:
trail_price
,trail_percent
Also:
- Trade id changed to string
- Added oto and oco to OrderClass
- Changed the polygon websocket to socket.polygon.io
- Fix typo on AccountActivity
Support new Alpaca Data API
No change from 1.5.0rc1. This was made official.
This release adds support for
LastQuote()
LastTrade()
Data streaming for trades, quotes and bars
The stream package now chooses Alpaca data streaming by default which is a behavior change from the previous releases.
RC1 for new Alpaca Data API
This release adds support for
- LastQuote()
- LastTrade()
- Data streaming for trades, quotes and bars
The stream
package now chooses Alpaca data streaming by default which is a behavior change from the previous releases.
Note these are currently in beta.
Replace specification of portfolio history period with string
An API change allows for arbitrary specification of period histories. This contradicts what was released in the last version - this updates the parameters of the portfolio history method to accept a string as a parameter rather than the typed value.
Add support for Portfolio History endpoint
Documentation on the Alpaca website for the portfolio history endpoint is forthcoming, but it will allow you to get the data that is used to generate your portfolio performance chart on the dashboard. You can specify either a start and end date and a timeframe, or a "period," the valid values of which are enumerated in the new typed parameters.
type HistoryPeriod string
const (
Month1 HistoryPeriod = "1M"
Month3 HistoryPeriod = "3M"
Month6 HistoryPeriod = "6M"
Year HistoryPeriod = "1A"
AllHistory HistoryPeriod = "all"
Intraday HistoryPeriod = "intraday"
)
type RangeFreq string
const (
Min1 RangeFreq = "1Min"
Min5 RangeFreq = "5Min"
Min15 RangeFreq = "15Min"
Hour1 RangeFreq = "1H"
Day1 RangeFreq = "1D"
)
No matter which way you specify the range requested, the returned PortfolioHistory object looks like this:
type PortfolioHistory struct {
BaseValue decimal.Decimal `json:"base_value"`
Equity []decimal.Decimal `json:"equity"`
ProfitLoss []decimal.Decimal `json:"profit_loss"`
ProfitLossPct []decimal.Decimal `json:"profit_loss_pct"`
Timeframe RangeFreq `json:"timeframe"`
Timestamp []int64 `json:"timestamp"`
}
Bracket Order Support
This release adds support for bracket orders. Bracket orders are submitted to the Alpaca API like so:
{
"side": "buy",
"symbol": "SPY",
"type": "market",
"qty": "100",
"time_in_force": "gtc",
"class": "bracket",
"take_profit": {
"limit_price": "301"
},
"stop_loss": {
"stop_price": "299",
"limit_price": "298.5"
}
}
Fields matching these have been added to the PlaceOrderRequest object. Please also note the inclusion of the new nested
parameter in the order list call. Specifying nested
as true
will make it so that bracket orders have legs
fields which will contain their child orders. Child orders will be in this nested field rather than the main array of orders. For more information about using bracket orders with Alpaca, please refer to https://docs.alpaca.markets.
Add Polygon v2 data endpoints
In this release, support has been added for the following Polygon endpoints:
Historic Trades v2: https://polygon.io/docs/#!/Stocks--Equities/get_v2_ticks_stocks_trades_ticker_date
Historic Quotes v2: https://polygon.io/docs/#!/Stocks--Equities/get_v2_ticks_stocks_nbbo_ticker_date
The methods using the v1 endpoints have been marked as deprecated and will be removed from the library in a future release, as Polygon intends to remove them from the API.
API Additions
In this release, a few Alpaca API extensions have been added. The following API endpoints are now supported:
Account Activities
Account Configurations
Additionally, some general bugfixes were made - check the GitHub tag notes since the last release for more information.
Improve websocket reconnection
Previously, reconnects could fail if the websocket did not allow reconnection immediately. It's now more lenient - if the websocket disconnects, a few attempts are made before errors occur.
Fix Websocket Reconnection
There were several issues with the previous attempt at handling websocket disconnects. This release addresses those - websocket subscriptions should now be resumed when the new connection is opened.
Additionally, Alpaca has added limited support for OAuth authentication, and a new environment variable has been added to support it.