Skip to content

Commit

Permalink
Fix Transfer pydantic model to properly handle optional `relationsh…
Browse files Browse the repository at this point in the history
…ip_id`, `expires_at` and `updated_at` fields from Retrieve List of Transfers API for an Account endpoint (#496)
  • Loading branch information
dtatarkin authored Aug 20, 2024
1 parent cdf1c5a commit d209d79
Show file tree
Hide file tree
Showing 46 changed files with 40 additions and 105 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,4 @@ Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
7 changes: 4 additions & 3 deletions alpaca/broker/models/funding.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,10 @@ class Transfer(ModelWithID):

account_id: UUID
created_at: datetime
updated_at: datetime
expires_at: datetime
relationship_id: UUID
updated_at: Optional[datetime] = None
expires_at: Optional[datetime] = None
relationship_id: Optional[UUID] = None
bank_id: Optional[UUID] = None
amount: str
type: TransferType
status: TransferStatus
Expand Down
4 changes: 2 additions & 2 deletions alpaca/data/historical/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

"""
These functions were created and put in this file to handle all of the edge cases
for parsing data that exist in the market data API.
for parsing data that exist in the market data API.
v2/stocks and v1beta2/crypto
v2/stocks and v1beta2/crypto
"""


Expand Down
4 changes: 2 additions & 2 deletions docs/_templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
if (!cta) return;
cta.addEventListener("click", function() {
const eventName = window.location.pathname.includes("broker")
? "docs_python_sdk_broker_cta_clicked"
? "docs_python_sdk_broker_cta_clicked"
: "docs_python_sdk_lpca_cta_clicked";
amplitude.getInstance().logEvent(eventName,{
url,
Expand All @@ -119,4 +119,4 @@
}).join("").trim();
}
</script>
{% endblock %}
{% endblock %}
2 changes: 1 addition & 1 deletion docs/_templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,4 @@
</aside>
</div>
</div>
{%- endblock %}
{%- endblock %}
2 changes: 1 addition & 1 deletion docs/_templates/sidebar/navigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
<a class="reference external" href="https://forum.alpaca.markets/">Community</a>
</li>
</ul>
</div>
</div>
3 changes: 0 additions & 3 deletions docs/api_reference/broker/account_activities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,3 @@ Get Account Activities
----------------------

.. automethod:: alpaca.broker.client.BrokerClient.get_account_activities



2 changes: 0 additions & 2 deletions docs/api_reference/broker/accounts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,3 @@ Update Trade Configuration For Account
--------------------------------------

.. automethod:: alpaca.broker.client.BrokerClient.update_trade_configuration_for_account


2 changes: 1 addition & 1 deletion docs/api_reference/broker/assets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ Get All Assets
Get a Single Asset
------------------

.. automethod:: alpaca.broker.client.BrokerClient.get_asset
.. automethod:: alpaca.broker.client.BrokerClient.get_asset
1 change: 0 additions & 1 deletion docs/api_reference/broker/broker-client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ BrokerClient

.. autoclass:: alpaca.broker.client.BrokerClient
:members: __init__

1 change: 0 additions & 1 deletion docs/api_reference/broker/calendar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ Get Market Calendar
-------------------

.. automethod:: alpaca.broker.client.BrokerClient.get_calendar

1 change: 0 additions & 1 deletion docs/api_reference/broker/clock.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ Get Market Clock
----------------

.. automethod:: alpaca.broker.client.BrokerClient.get_clock

10 changes: 0 additions & 10 deletions docs/api_reference/broker/funding.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,3 @@ Cancel Transfer For Account
---------------------------

.. automethod:: alpaca.broker.client.BrokerClient.cancel_transfer_for_account










1 change: 0 additions & 1 deletion docs/api_reference/broker/journals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,3 @@ Cancel Journal by ID
--------------------

.. automethod:: alpaca.broker.client.BrokerClient.cancel_journal_by_id

1 change: 0 additions & 1 deletion docs/api_reference/broker/requests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,3 @@ GetJournalsRequest
------------------

.. autoclass:: alpaca.broker.requests.GetJournalsRequest

2 changes: 0 additions & 2 deletions docs/api_reference/broker/trading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@ Trading
trading/positions
trading/portfolio-history
trading/watchlists


1 change: 0 additions & 1 deletion docs/api_reference/broker/trading/orders.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,3 @@ Cancel an Order For Account By Id
---------------------------------

.. automethod:: alpaca.broker.client.BrokerClient.cancel_order_for_account_by_id

2 changes: 0 additions & 2 deletions docs/api_reference/broker/trading/portfolio-history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@ Get Portfolio History For Account
---------------------------------

.. automethod:: alpaca.broker.client.BrokerClient.get_portfolio_history_for_account


2 changes: 1 addition & 1 deletion docs/api_reference/broker/trading/positions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ Close All Positions For Account
Close A Position For Account
----------------------------

.. automethod:: alpaca.broker.client.BrokerClient.close_position_for_account
.. automethod:: alpaca.broker.client.BrokerClient.close_position_for_account
1 change: 0 additions & 1 deletion docs/api_reference/broker_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ Contents
broker/models
broker/requests
broker/enums

1 change: 0 additions & 1 deletion docs/api_reference/data/crypto/historical.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,3 @@ Get Crypto Latest Orderbook
---------------------------

.. automethod:: alpaca.data.historical.crypto.CryptoHistoricalDataClient.get_crypto_latest_orderbook

2 changes: 1 addition & 1 deletion docs/api_reference/data/crypto/requests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ CryptoLatestTradeRequest
CryptoSnapshotRequest
---------------------

.. autoclass:: alpaca.data.requests.CryptoSnapshotRequest
.. autoclass:: alpaca.data.requests.CryptoSnapshotRequest
2 changes: 1 addition & 1 deletion docs/api_reference/data/enums.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ MostActivesBy
MarketType
----------

.. autoclass:: alpaca.data.enums.MarketType
.. autoclass:: alpaca.data.enums.MarketType
1 change: 0 additions & 1 deletion docs/api_reference/data/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,3 @@ Movers
------

.. autoclass:: alpaca.data.models.screener.Movers

1 change: 0 additions & 1 deletion docs/api_reference/data/stock/historical.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,3 @@ Get Stock Snapshot
------------------

.. automethod:: alpaca.data.historical.stock.StockHistoricalDataClient.get_stock_snapshot

2 changes: 1 addition & 1 deletion docs/api_reference/data/stock/live.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ StockDataStream

.. autoclass:: alpaca.data.live.stock.StockDataStream
:members:
:inherited-members:
:inherited-members:
2 changes: 1 addition & 1 deletion docs/api_reference/data/stock/requests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ MostActivesRequest
MarketMoversRequest
-------------------

.. autoclass:: alpaca.data.requests.MarketMoversRequest
.. autoclass:: alpaca.data.requests.MarketMoversRequest
2 changes: 1 addition & 1 deletion docs/api_reference/data/stock/screener.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ Get Most Actives
Get Market Movers
-----------------

.. automethod:: alpaca.data.historical.screener.ScreenerClient.get_market_movers
.. automethod:: alpaca.data.historical.screener.ScreenerClient.get_market_movers
2 changes: 0 additions & 2 deletions docs/api_reference/data_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,3 @@ Market Data Reference
data/timeframe
data/models
data/enums


1 change: 0 additions & 1 deletion docs/api_reference/trading/account.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ Get Account Details
-------------------

.. automethod:: alpaca.trading.client.TradingClient.get_account

2 changes: 0 additions & 2 deletions docs/api_reference/trading/assets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,3 @@ Get Asset
---------

.. automethod:: alpaca.trading.client.TradingClient.get_asset


4 changes: 0 additions & 4 deletions docs/api_reference/trading/calendar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,3 @@ Get Calendar
------------

.. automethod:: alpaca.trading.client.TradingClient.get_calendar




2 changes: 1 addition & 1 deletion docs/api_reference/trading/clock.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ of the trading hours for a given day.
Get Clock
---------

.. automethod:: alpaca.trading.client.TradingClient.get_clock
.. automethod:: alpaca.trading.client.TradingClient.get_clock
2 changes: 0 additions & 2 deletions docs/api_reference/trading/contracts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@ Get Option Contract
-------------------

.. automethod:: alpaca.trading.client.TradingClient.get_option_contract


2 changes: 1 addition & 1 deletion docs/api_reference/trading/orders.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ Cancel All Orders
Cancel Order By Id
------------------

.. automethod:: alpaca.trading.client.TradingClient.cancel_order_by_id
.. automethod:: alpaca.trading.client.TradingClient.cancel_order_by_id
8 changes: 0 additions & 8 deletions docs/api_reference/trading/requests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,3 @@ GetCorporateAnnouncementsRequest
--------------------------------

.. autoclass:: alpaca.trading.requests.GetCorporateAnnouncementsRequest








2 changes: 1 addition & 1 deletion docs/api_reference/trading/trading-client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ TradingClient
=============

.. autoclass:: alpaca.trading.client.TradingClient
:members: __init__
:members: __init__
1 change: 0 additions & 1 deletion docs/api_reference/trading/watchlists.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,3 @@ Delete Watchlist By Id
----------------------

.. automethod:: alpaca.trading.client.TradingClient.delete_watchlist_by_id

1 change: 0 additions & 1 deletion docs/api_reference/trading_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ Contents
trading/models
trading/requests
trading/enums

5 changes: 0 additions & 5 deletions docs/broker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,3 @@ This will return a list of ``Position`` objects.
account_id = "c8f1ef5d-edc0-4f23-9ee4-378f19cb92a4"
positions = broker_client.get_all_positions_for_account(account_id=account_id)
3 changes: 0 additions & 3 deletions docs/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,3 @@ Broker API
To use the Broker API, you will need to sign up for a `broker account <https://broker-app.alpaca.markets/sign-up>`_ and retrieve
your Broker API keys. The API keys can be found on the dashboard once you've logged in. Alpaca also provides a sandbox environment to test out Broker API. To use the sandbox mode, provide your
sandbox keys. Once you have your keys, you can pass them into ``BrokerClient`` to get started.



8 changes: 3 additions & 5 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
.. meta::
:image: https://alpaca.markets/static/images/meta-image-alpaca-py.png
:description: The Official Python SDK for Alpaca's Suite of APIs


Alpaca-py Documentation
=======================

.. container:: homepage-banner

.. image:: images/alpaca-py-banner.png
:alt: The official Python SDK for Alpaca's APIs.



.. container:: badges-row
.. container:: badges-row

|GitHub stars|

Expand Down Expand Up @@ -100,5 +100,3 @@ Here are some libraries that work well with Alpaca-py.

* `Plaid <https://github.com/plaid/plaid-python>`_ - Connect user banking information.
* `Onfido <https://github.com/onfido/onfido-python>`_ - Identity verification / KYC.


8 changes: 2 additions & 6 deletions docs/market_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
Market Data
===========

The market data API allows you to access both live and historical data for equities, cryptocurrencies, and options.
Over 5 years of historical data is available for thousands of equity and cryptocurrency symbols.
The market data API allows you to access both live and historical data for equities, cryptocurrencies, and options.
Over 5 years of historical data is available for thousands of equity and cryptocurrency symbols.
Various data types are available such as bars/candles (OHLCV), trade data (price and sales), and quote data. For
crypto, there is also orderbook data. For more information on the data types available,
please look at the `API reference <https://alpaca.markets/docs/market-data/>`_.
Expand Down Expand Up @@ -192,7 +192,3 @@ Finally, you will need to call the ``run`` method to start receiving data.
wss_client.subscribe_quotes(quote_data_handler, "SPY")
wss_client.run()
3 changes: 0 additions & 3 deletions docs/trading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,3 @@ Here is an example
# start our websocket streaming
trading_stream.run()
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Google Colab Notebooks

Explore the examples for Stocks, Options, and Crypto utilizing alpaca-py in the notebooks provided below. Open them in Google Colab to jumpstart your development journey!
Explore the examples for Stocks, Options, and Crypto utilizing alpaca-py in the notebooks provided below. Open them in Google Colab to jumpstart your development journey!

| Notebooks | Open in Google Colab |
| :--------------------------------------------------------------------------------------- | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
Expand Down
25 changes: 13 additions & 12 deletions tests/broker/broker_client/test_funding_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,19 +266,20 @@ def setup_reqmock_for_paginated_transfers_response(account_id, reqmock):
resp_one = """
[
{
"id": "be3c368a-4c7c-4384-808e-f02c9f5a8afe",
"relationship_id": "0f08c6bc-8e9f-463d-a73f-fd047fdb5e94",
"account_id": "2a87c088-ffb6-472b-a4a3-cd9305c8605c",
"type": "ach",
"status": "COMPLETE",
"reason": null,
"amount": "498",
"id": "bf438b6d-4ea3-4241-9e1c-a0e55b47f4e0",
"account_id": "2d6cab28-c5d1-4ff8-91c6-b6404a9ee114",
"type": "wire",
"status": "CANCELED",
"currency": "USD",
"amount": "100",
"instant_amount": "0",
"direction": "INCOMING",
"created_at": "2021-05-05T07:55:31.190788Z",
"updated_at": "2021-05-05T08:13:33.029539Z",
"expires_at": "2021-05-12T07:55:31.190719Z",
"requested_amount": "500",
"fee": "2",
"created_at": "2024-07-15T13:40:01.963459Z",
"updated_at": "2024-07-22T08:22:29.990176Z",
"reason": null,
"hold_until": null,
"requested_amount": "100",
"fee": "0",
"fee_payment_method": "user"
},
{
Expand Down

0 comments on commit d209d79

Please sign in to comment.