Package: fds.sdk.VirtualPortfolioAPIforDigitalPortals
Virtual Portfolio API for Digital Portals client library for PythonThe virtual portfolio enables the analysis of the current allocation, broken down by asset classes, currencies,
regions, sectors, style, capitalization, style, maturity, risk, and more.Relative performance and monthly returns can be measured against benchmarks, using portfolio position transaction (buy/sell) data.
Both the realized profit/loss (resulting from closed transactions) and the potential profit/loss (resulting from positions that have not been sold yet) can be queried.Portfolio endpoints allow creation and managing a transaction-based portfolio. A transaction-based portfolio contains a gapless history of all transactions to be able to accurately reproduce the investment record of the portfolio.An instrument added to a portfolio is called a position. Each position consists of multiple buy and sell events called transactions.
Portfolios are limited to 100 positions and 1000 transactions; adding more will result in an error.A transaction-based portfolio can consist of the following transactions:A buy transaction opens or adds to a position in the portfolio, decreasing the cash value by the purchase price at the same time. If there is not enough cash in the portfolio to cover the transaction, the cash value becomes negative.A sell transaction decreases or closes a position in the portfolio, increasing the cash value by the sale price at the same time. A sell transaction can only be created if the number of shares of a given position exceeds the number being sold.A cash transaction increases or decreases the cash position of the portfolio. A portfolio can have only one cash position. The cash position is tracked automatically as each buy or sell transaction implicitly affects it. The cash position can be negative as a buy transaction does not check whether enough cash is available. The cash position does not generate interest; its performance is always 0%.The chosen prices and key figures in the endpoints are using the same quality, which is configurable per application. Possible values are delayed (DLY), best (BST), end-of-day (EOD) or realtime (RLT). The default value for the price quality is BST.The portfolio endpoints use different methods to calculate key figures. All key figures except the risk in /portfolio/detail/list, /portfolio/get, and /portfolio/position/list are calculated on-the-fly with current prices. The risk key figures are calculated on-the-fly with current prices, but the result is cached for 24 hours. The key figures in /portfolio/evaluation/list are calculated on end-of-day basis.The Virtual Portfolio API for Digital Portals is fully integrated with the corresponding Quotes API, allowing access to detailed price and performance information of instruments in a watchlist. This also supports basic security identifier cross-reference. To complement the Watchlist API and Virtual Portfolio API with direct access to price histories, please refer to the Time Series API for Digital Portals.This Python package is automatically generated by theOpenAPI Generatorproject:API version: 2Package version: 0.9.5Build package: org.openapitools.codegen.languages.PythonClientCodegenRequirementsPython >= 3.7InstallationPoetrypoetryaddfds.sdk.utilsfds.sdk.VirtualPortfolioAPIforDigitalPortalspippipinstallfds.sdk.utilsfds.sdk.VirtualPortfolioAPIforDigitalPortalsUsageGenerate authentication credentials.Setup Python environment.Install and activate python 3.7+. If you're usingpyenv:pyenvinstall3.9.7
pyenvshell3.9.7(optional)Install poetry.Install dependencies.Run the following:fromfds.sdk.utils.authenticationimportConfidentialClientimportfds.sdk.VirtualPortfolioAPIforDigitalPortalsfromfds.sdk.VirtualPortfolioAPIforDigitalPortals.apiimportportfolio_apifromfds.sdk.VirtualPortfolioAPIforDigitalPortals.modelsimport*fromdateutil.parserimportparseasdateutil_parserfrompprintimportpprint# See configuration.py for a list of all supported configuration parameters.# Examples for each supported authentication method are below,# choose one that satisfies your use case.# (Preferred) OAuth 2.0: FactSetOAuth2# See https://github.com/FactSet/enterprise-sdk#oauth-20# for information on how to create the app-config.json file# See https://github.com/FactSet/enterprise-sdk-utils-python#authentication# for more information on using the ConfidentialClient classconfiguration=fds.sdk.VirtualPortfolioAPIforDigitalPortals.Configuration(fds_oauth_client=ConfidentialClient('/path/to/app-config.json'))# Basic authentication: FactSetApiKey# See https://github.com/FactSet/enterprise-sdk#api-key# for information how to create an API key# configuration = fds.sdk.VirtualPortfolioAPIforDigitalPortals.Configuration(#     username='USERNAME-SERIAL',#     password='API-KEY'# )# Enter a context with an instance of the API clientwithfds.sdk.VirtualPortfolioAPIforDigitalPortals.ApiClient(configuration)asapi_client:# Create an instance of the API classapi_instance=portfolio_api.PortfolioApi(api_client)id="id_example"# str |attributes=["_attributes_example",]# [str] | Limit the attributes returned in the response to the specified set. (optional)try:# Details of a portfolio.api_response=api_instance.get_portfolio_get(id,attributes=attributes)pprint(api_response)exceptfds.sdk.VirtualPortfolioAPIforDigitalPortals.ApiExceptionase:print("Exception when calling PortfolioApi->get_portfolio_get:%s\n"%e)# Get response, http status code and response headers# try:#     # Details of a portfolio.#     api_response, http_status_code, response_headers = api_instance.get_portfolio_get_with_http_info(id, attributes=attributes)#     pprint(api_response)#     pprint(http_status_code)#     pprint(response_headers)# except fds.sdk.VirtualPortfolioAPIforDigitalPortals.ApiException as e:#     print("Exception when calling PortfolioApi->get_portfolio_get: %s\n" % e)# Get response asynchronous# try:#     # Details of a portfolio.#     async_result = api_instance.get_portfolio_get_async(id, attributes=attributes)#     api_response = async_result.get()#     pprint(api_response)# except fds.sdk.VirtualPortfolioAPIforDigitalPortals.ApiException as e:#     print("Exception when calling PortfolioApi->get_portfolio_get: %s\n" % e)# Get response, http status code and response headers asynchronous# try:#     # Details of a portfolio.#     async_result = api_instance.get_portfolio_get_with_http_info_async(id, attributes=attributes)#     api_response, http_status_code, response_headers = async_result.get()#     pprint(api_response)#     pprint(http_status_code)#     pprint(response_headers)# except fds.sdk.VirtualPortfolioAPIforDigitalPortals.ApiException as e:#     print("Exception when calling PortfolioApi->get_portfolio_get: %s\n" % e)Documentation for API EndpointsAll URIs are relative tohttps://api.factset.com/wealth/v1ClassMethodHTTP requestDescriptionPortfolioApiget_portfolio_getGET/portfolio/getDetails of a portfolio.PortfolioApiget_portfolio_listGET/portfolio/listList of portfolios with keyfigures.PortfolioApiget_portfolio_name_listGET/portfolio/name/listList of portfolios.PortfolioApiget_portfolio_position_listGET/portfolio/position/listList all open positions of a portfolio.PortfolioApiget_portfolio_transaction_listGET/portfolio/transaction/listList of transactions in a portfolio.PortfolioApipost_portfolio_createPOST/portfolio/createCreate a portfolio.PortfolioApipost_portfolio_deletePOST/portfolio/deleteDelete a portfolio.PortfolioApipost_portfolio_evaluation_listPOST/portfolio/evaluation/listEvaluate a portfolio.PortfolioApipost_portfolio_modifyPOST/portfolio/modifyModify a portfolio.PortfolioApipost_portfolio_payout_createPOST/portfolio/payout/createAdd a payout to a portfolio.PortfolioApipost_portfolio_payout_deletePOST/portfolio/payout/deleteDelete a payout of a portfolio.PortfolioApipost_portfolio_payout_listPOST/portfolio/payout/listList of payouts in a portfolio.PortfolioApipost_portfolio_payout_modifyPOST/portfolio/payout/modifyModify a payout in a portfolio.PortfolioApipost_portfolio_position_closed_listPOST/portfolio/position/closed/listList all closed positions of a portfolio.PortfolioApipost_portfolio_transaction_cash_createPOST/portfolio/transaction/cash/createAdd a cash transaction to a portfolio.PortfolioApipost_portfolio_transaction_cash_deletePOST/portfolio/transaction/cash/deleteDelete a cash transaction.PortfolioApipost_portfolio_transaction_createPOST/portfolio/transaction/createAdd a transaction to a portfolio.PortfolioApipost_portfolio_transaction_deletePOST/portfolio/transaction/deleteDelete a transaction of a portfolio.PortfolioApipost_portfolio_transaction_modifyPOST/portfolio/transaction/modifyModify a transaction in a portfolio.WatchlistApiget_watchlist_getGET/watchlist/getDetails of a watchlist.WatchlistApiget_watchlist_listGET/watchlist/listList of watchlists.WatchlistApiget_watchlist_position_listGET/watchlist/position/listList of positions of a watchlist.WatchlistApipost_watchlist_createPOST/watchlist/createCreate a watchlist.WatchlistApipost_watchlist_deletePOST/watchlist/deleteDelete a watchlist.WatchlistApipost_watchlist_modifyPOST/watchlist/modifyModify a watchlist.WatchlistApipost_watchlist_position_createPOST/watchlist/position/createAdd a position to a watchlist.WatchlistApipost_watchlist_position_deletePOST/watchlist/position/deleteDelete a position of a watchlist.WatchlistApipost_watchlist_position_getPOST/watchlist/position/getDetails of the position of a watchlist.WatchlistApipost_watchlist_position_modifyPOST/watchlist/position/modifyModify a position in a watchlist.Documentation For ModelsAttributesMemberCursorBasedPaginationOutputObjectCursorBasedPaginationOutputObjectWithoutTotalErrorMetaObjectErrorObjectInlineObjectInlineObject1InlineObject10InlineObject11InlineObject12InlineObject13InlineObject14InlineObject15InlineObject16InlineObject17InlineObject18InlineObject19InlineObject2InlineObject20InlineObject3InlineObject4InlineObject5InlineObject6InlineObject7InlineObject8InlineObject9InlineResponse200InlineResponse2001InlineResponse20010InlineResponse20010DataInlineResponse20010DataInstrumentInlineResponse20010DataPayoutInlineResponse20010DataPositionsInlineResponse20010DataProfitLossInlineResponse20010DataTransactionInlineResponse20010DataTransactionBuyInlineResponse20010DataTransactionBuyCurrencyInlineResponse20010DataTransactionBuyNotationInlineResponse20010DataTransactionSellInlineResponse20010DataTransactionSellCurrencyInlineResponse20010DataTransactionSellNotationInlineResponse20011InlineResponse20011DataInlineResponse20011NotationInlineResponse20012InlineResponse20012DataInlineResponse20013InlineResponse20013DataInlineResponse20014InlineResponse20014DataInlineResponse20014DataNotationInlineResponse20015InlineResponse20015DataInlineResponse20015NotationInlineResponse2001DataInlineResponse2001DataCurrencyInlineResponse2001DataLifecycleInlineResponse2001DataLifecycleTransactionInlineResponse2001DataProfitLossInlineResponse2001DataProfitLossPotentialInlineResponse2001DataProfitLossRealizedInlineResponse2001DataProfitLossTodayInlineResponse2001DataProfitLossTotalInlineResponse2001DataRiskKeyFiguresInlineResponse2001DataSummaryInlineResponse2001DataSummaryCashInlineResponse2001DataSummaryTransactionsInlineResponse2001DataSummaryTransactionsBuyInlineResponse2001DataSummaryTransactionsSellInlineResponse2001DataSummaryTransactionsTotalInlineResponse2002InlineResponse2002CurrencyInlineResponse2002DataInlineResponse2002ProfitLossInlineResponse2002SummaryInlineResponse2002SummaryTransactionsInlineResponse2003InlineResponse2004InlineResponse2004DataInlineResponse2004DataKeyfiguresInlineResponse2004DataPeriodInlineResponse2004DataPeriodProfitLossInlineResponse2004DataProfitLossInlineResponse2005InlineResponse2005DataInlineResponse2006InlineResponse2007InlineResponse2007DataInlineResponse2007InstrumentInlineResponse2007MetaInlineResponse2007NotationInlineResponse2007TransactionInlineResponse2008InlineResponse2009InlineResponse2009DataInlineResponse2009DataCurrencyInlineResponse2009DataInstrumentInlineResponse2009DataInstrumentAssetClassInlineResponse2009DataInstrumentTypeInlineResponse2009DataNotationInlineResponse2009DataNotationPriceInlineResponse2009DataPositionsInlineResponse2009DataProfitLossInlineResponse2009DataProfitLossIntradayInlineResponse2009DataProfitLossPotentialInlineResponse2009DataPurchaseInlineResponse2009DataSharesInlineResponse201InlineResponse2011InlineResponse2011DataInlineResponse2012InlineResponse2012DataInlineResponse2013InlineResponse2013DataInlineResponse2014InlineResponse2014DataInlineResponse201DataInlineResponse201MetaLanguageMemberOffsetBasedPaginationOutputObjectOffsetBasedPaginationOutputObjectWithoutTotalPartialOutputObjectPortfolioCreateDataPortfolioCreateDataCurrencyPortfolioCreateMetaPortfolioDeleteDataPortfolioEvaluationListDataPortfolioEvaluationListDataRangePortfolioModifyDataPortfolioPayoutCreateDataPortfolioPayoutCreateDataNotationPortfolioPayoutCreateDataTransactionPortfolioPayoutDeleteDataPortfolioPayoutDeleteDataPayoutPortfolioPayoutListDataPortfolioPayoutListDataFilterPortfolioPayoutListDataFilterInstrumentPortfolioPayoutListMetaPortfolioPayoutListMetaPaginationPortfolioPayoutModifyDataPortfolioPayoutModifyDataPayoutPortfolioPayoutModifyDataPayoutNotationPortfolioPayoutModifyDataPayoutTransactionPortfolioPositionClosedListDataPortfolioPositionClosedListDataRangePortfolioPositionClosedListMetaPortfolioPositionClosedListMetaPaginationPortfolioTransactionCashCreateDataPortfolioTransactionCashDeleteDataPortfolioTransactionCreateDataPortfolioTransactionCreateDataParentTransactionPortfolioTransactionDeleteDataPortfolioTransactionDeleteDataTransactionPortfolioTransactionModifyDataPortfolioTransactionModifyDataTransactionStatusObjectWatchlistCreateDataWatchlistDeleteDataWatchlistModifyDataWatchlistPositionCreateDataWatchlistPositionDeleteDataWatchlistPositionDeleteDataPositionWatchlistPositionGetDataWatchlistPositionGetDataPositionWatchlistPositionModifyDataWatchlistPositionModifyDataPositionDocumentation For AuthorizationFactSetApiKeyType: HTTP basic authenticationFactSetOAuth2Type: OAuthFlow: applicationAuthorization URL:Scopes: N/ANotes for Large OpenAPI documentsIf the OpenAPI document is large, imports in fds.sdk.VirtualPortfolioAPIforDigitalPortals.apis and fds.sdk.VirtualPortfolioAPIforDigitalPortals.models may fail with a
RecursionError indicating the maximum recursion limit has been exceeded. In that case, there are a couple of solutions:Solution 1:
Use specific imports for apis and models like:from fds.sdk.VirtualPortfolioAPIforDigitalPortals.api.default_api import DefaultApifrom fds.sdk.VirtualPortfolioAPIforDigitalPortals.model.pet import PetSolution 2:
Before importing the package, adjust the maximum recursion limit as shown below:import sys
sys.setrecursionlimit(1500)
import fds.sdk.VirtualPortfolioAPIforDigitalPortals
from fds.sdk.VirtualPortfolioAPIforDigitalPortals.apis import *
from fds.sdk.VirtualPortfolioAPIforDigitalPortals.models import *ContributingPlease refer to thecontributing guide.CopyrightCopyright 2022 FactSet Research Systems IncLicensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless 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.