Skip to content

Releases: alpacahq/alpaca-trade-api-python

Support new Alpaca Data API

28 Apr 20:39
Compare
Choose a tag to compare
Pre-release

This is the first RC release to support new Alpaca Data API.

  • get_last_trade()
  • get_last_quote()
  • StreamConn() can now connect to streams of trade, quotes and minute bars

Update timestamp format for portfolio history dataframe

05 Mar 03:37
Compare
Choose a tag to compare

The API specification changed after the release of v0.45 - timestamps are now provided in milliseconds rather than seconds. This update fixes the dataframe's index.

Add support for Polygon open/close and Alpaca equity history endpoints

02 Mar 05:42
Compare
Choose a tag to compare

As it says in the title, support has been added for a couple new endpoints.

Polygon open/close: https://polygon.io/docs/#!/Stocks--Equities/get_v1_open_close_symbol_date
Documentation for Alpaca portfolio history is forthcoming, but is documented as such in the readme for the moment:

REST.get_portfolio_history(date_start=None, date_end=None, period=None, timeframe=None, extended_hours=None)
Calls GET /account/portfolio/history and returns a PortfolioHistory entity. PortfolioHistory.df can be used to get the results as a dataframe.

Fix missing Alpha Vantage package declaration

06 Feb 15:33
Compare
Choose a tag to compare

The Alpha Vantage package added in the last release was not declared in setup.py, leading to some installation issues. We've added it now, so it should be picked up when you try to run the SDK.

Bracket Orders, Watchlist API, and AlphaVantage Integration

06 Feb 06:37
853c73f
Compare
Choose a tag to compare

In this release, support for advanced order types - bracket orders - is added. You can now submit bracket orders 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"
  }
}

Please note the inclusion of the new nested parameter in the order list call. Specifying nested=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.

Watchlist endpoint support was also added - learn more about using it here: https://docs.alpaca.markets/api-documentation/api-v2/watchlist/.

Additionally, support for Alpha Vantage has been added for those looking for more data sources akin to our Polygon integration. Please see the updated README.md for information about using the Alpha Vantage API. We also corrected an issue where Position-closing endpoints were not returning the created Order objects.

Add Polygon v2 data endpoints

03 Dec 17:00
Compare
Choose a tag to compare

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.

Account Activities API

24 Oct 04:02
Compare
Choose a tag to compare

In this release, support for the Account Activities API endpoint has been added. This endpoint allows you to see information about transactions related to your account such as dividends, interest payments, and trade executions. Please see the documentation page for a full set of usage instructions.

Order Replacement and Account Configurations

06 Oct 06:07
db50c0e
Compare
Choose a tag to compare

In this release, support has been added for the order replacement and account configuration APIs. Documentation for these can be found here: https://docs.alpaca.markets/api-documentation/api-v2/orders/ and [https://docs.alpaca.markets/api-documentation/api-v2/account-configuration](account configurations). Order replacement allows you to update an order without having to first go through the process of cancelling it and waiting to receive confirmation that the cancel worked. Account configurations allows you to specify some account-level behavior. The following parameters can currently be configured in this way:

  • no_shorting: Allows you to prevent new short sales from happening - if you attempt a short sale with this set to true, you'll receive an "insufficient qty" error.
  • dtbp_check: Controls [https://docs.alpaca.markets/user-protections/#day-trade-margin-call-dtmc-protection-at-alpaca](Day Trading Margin Call) checks. Please see our documentation for more information on the options.
  • trade_confirm_email: If "none" (the string, not python's None) is specified, emails for order fills are not sent.
  • suspend_trade: If true, new orders are blocked.

Additionally, an issue was fixed where user code exceptions would be swallowed by the websocket handler code, which could lead to some errors being difficult to debug.

Alpaca Websocket reconnection

23 Aug 03:47
Compare
Choose a tag to compare

In this release, automatic reconnection was added for the Alpaca Websocket stream. This should help with cases in which the network connection is unstable or where the machine running an application using the SDK may go to sleep or otherwise pause execution. Additionally, a fix was made for cases in which async code was using the SDK's websocket connection, and support for OAuth authentication was added.

Add order cancellation and position liquidation endpoints

31 Jul 23:10
Compare
Choose a tag to compare

We've added a few new methods to the Alpaca API, described below.

cancel_all_orders(): Cancels all open orders.
close_position(symbol): Closes any open position for the given symbol at market price.
close_all_positions(): Closes all open positions at market price.

Official documentation can be found here:
https://docs.alpaca.markets/api-documentation/api-v2/orders/#cancel-all-orders
https://docs.alpaca.markets/api-documentation/api-v2/positions/#close-all-positions