You've successfully subscribed to Alpaca Learn | Developer-First API for Stocks, Options, and Crypto
Great! Next, complete checkout for full access to Alpaca Learn | Developer-First API for Stocks, Options, and Crypto
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info is updated.
Billing info update failed.
Search
Broker API

Introducing The New Portfolio History Endpoint at Alpaca

Patrick Valoppi

As we continue to build new products and expand into different asset classes we improved our Portfolio History API endpoint. This blog post delves into the new changes we have built out for Alpaca traders using the portfolio history API endpoint.

New Changes With V2

  1. Realtime updates on portfolio history endpoint for deposits, withdrawals, fees (such as coin pair trade fees)
  2. 24/7 support.
  3. Complete support for corporate actions such as stock splits.
  4. Comprehensive support across US stocks and cryptocurrencies as well as non-USD based accounts (Local Currency Trading) and Just-In-Time funding accounts.
  5. Ad-hoc URL parameter to compare the old and new implementations.

Note: To calculate the equity values we are using the following prices:

  • Between 4:00am and 10:00pm on trading days the valuation will be calculated based on the last trade (extended hours and normal hours respectively).
  • After 10:00pm, until the next session open the equities will be valued at their official closing price on the primary exchange.

V2: A Shift to Realtime

We embarked on a complete rewrite of the Portfolio History engine. The new version uses a sophisticated state machine that not only understands but also accurately reflects Non Trade Activities (NTAs). This redesign also includes balance authorization holds for more precise representation of ACH transfers, and, crucially, introduces 24/7 support for portfolio history across multiple asset classes, aligning with the non-stop nature of our cryptocurrency offering and future asset class growth.

For our users, this transition is seamless. The v2 engine uses the same endpoint and maintains backward compatibility from a schema perspective. Unlike the previous API, which booked NTAs at End of Day (EOD), the new engine updates in real-time, ensuring that traders have up-to-the-minute information on their portfolio.

We have been running the new engine on our Trading API users in the dashboard for the last 4 months and the behavior has been verified.

We've ensured that traders will have fast and accurate portfolio history irregardless of asset class or time. The response format remains the same, and we've added new non-breaking fields such as base_value_asof, which indicates the trading basis for the profit and loss calculations.

What Do You Need to Do?


For Trading API traders

No action is needed. The new engine has been running in the dashboard already.

For Broker API partners

The new implementation is ready and new partners default to it. For existing partners who have been using the old implementation, the engine hasn't been replaced unless you have been notified. Please contact your success manager to decide when to switch.

In doing so, please be advised on the following:

  • The new implementation applies NTA in real-time for the intraday time frame. If you have implemented this on your side, you need to update your logic and can test it in the sandbox before switching to it.
  • There is a new URL parameter (`force_engine_version`) that tells API to use the new implementation, so that you can test in live for selected users before switching to all of your users.

Please find the updated API documentation for more details.

In Summary

The launch of the v2 Portfolio History endpoint at Alpaca is more than just an upgrade; it's a testament to our commitment to delivering cutting-edge, reliable, and user-friendly trading solutions. This enhancement not only addresses the challenges of the previous version but also sets a new standard in portfolio management tools. By staying attuned to the evolving needs of our traders and leveraging advanced technologies, we continue to pave the way for a more efficient and inclusive trading future for developers and traders.


This is not an offer, solicitation of an offer, or advice to buy or sell securities or cryptocurrencies, or open a brokerage account or cryptocurrency account in any jurisdiction where Alpaca Securities or Alpaca Crypto respectively, are not registered or licensed, as applicable.

Securities brokerage services are provided by Alpaca Securities LLC ("Alpaca Securities"), member FINRA/SIPC, a wholly-owned subsidiary of AlpacaDB, Inc. Technology and services are offered by AlpacaDB, Inc.

Cryptocurrency services are made available by Alpaca Crypto LLC ("Alpaca Crypto"), a FinCEN registered money services business (NMLS # 2160858), and a wholly-owned subsidiary of AlpacaDB, Inc. Alpaca Crypto is not a member of SIPC or FINRA. Cryptocurrencies are not stocks and your cryptocurrency investments are not protected by either FDIC or SIPC. Please see the Disclosure Library for more information.

The Paper Trading API is offered by AlpacaDB, Inc. and does not require real money or permit a user to transact in real securities in the market. Providing use of the Paper Trading API is not an offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, given or in any manner endorsed by AlpacaDB, Inc. or any AlpacaDB, Inc. affiliate and the information made available through Paper Trading is not an offer or solicitation of any kind in any jurisdiction where AlpacaDB, Inc. or any AlpacaDB, Inc. affiliate is not authorized to do business.

Interested in learning more about Broker API?

Don't miss out on any updates about our Broker API suite of solutions! Share your details with us and be the first to know about our latest content.

Broker APITrading API