Python/Webservice/Java Programmers
The Northfield ACES Software Platform is accessible to Python, Webservice and Java programmers.
NISACES Java API
The Java components and webservice model are documented in the "ACES Software Platform" section of this website. The full javadoc for the java API is available here.
NISACES Python API
NISACES provides a Python library that allows you to access Northfield ACES from your own Python programs. The NISACES library automatically manages secure connections to the Northfield servers and exports three modules that you can use in your own applications:
- nisopt - constructs input JSON for the NISOPT optimizer webservice API and provides helper functions to parse output JSON into useful reports.
- nisaces - constructs input JSON for the NISMDL model data webservice API. It makes model data available for your own analytics, and also manages automatic integrattion with the NISOPT optimizer webservice and the NISRAT Risk Analytics Toolkit webservices.
- nishelperfunctions - provides useful functions to interact with projects and files constructed by the Northfield Windows desktop optimizer application.
NISACES Python Installation
The NISACES Python library is installed using "pip" so that all dependencies and the operating environment are setup automatically for you. We recommend installing NISACES in a virtual Python environment in the following manner.
python3 -m venv .venv/
source .venv/bin/activate
python3 -m pip install --upgrade pip
python3 -m pip install https://saas.northinfo.com/wui/nisaces-5.0.0.tar.gz
python3 <your program>.py
deactivate
NISACES Python Usage
The following example demonstrates how you would use NISACES in your own Python program.
from nisaces import nisaces
from nisaces import nisopt
from nisaces import nishelperfunctions
# Establish a connection
auth_code = "<your CCS connection token>"
optimizer = nisopt.Northfield_Optimizer_API()
optimizer.set_auth_key(auth_code)
...
# Load data from a desktop project
portfolio_data = nishelperfunctions.read_csv_into_list_of_lists("cash.csv")
benchmark_data = nishelperfunctions.read_csv_into_list_of_lists("stock.hld")
buylist_data = nishelperfunctions.read_csv_into_list_of_lists("buylist.hld")
alpha_data = nishelperfunctions.read_csv_into_list_of_lists("alpha.alp")
attributes_data = nishelperfunctions.read_attributes_from_file("attributes.csv")
asset_universe = nishelperfunctions.get_asset_universe(portfolio_data,benchmark_data,buylist_data)
...
# Load the risk model data from the ACES NISMDL web service
risk_model_data = nisaces.run_ACES(auth_code,"nis-mdl-02m-usd","20240930",asset_universe)
mdl_aces_data = risk_model_data["data"]["mdl-factors"]
cor_aces_data = risk_model_data["data"]["mdl-correlations"]
exp_aces_data = risk_model_data["data"]["mdl-exposures"]
...
# Setup the optimiser with file and NISMDL data.
opt_request = nisopt.Optimizer_Request()
opt_request.add_risk_model_data(mdl_aces_data,cor_aces_data,exp_aces_data,headers=True)
opt_request.add_holdings_data(portfolio_data,benchmark_data)
opt_request.add_security_selection_data(buy_list=buylist_data,alphas=alpha_data)
opt_request.add_security_constraints_data(security_maximum_default_weight=5,position_threshold=.05)
opt_request.add_portfolio_constraints(maximum_number_of_assets=50)
opt_request.add_attributes_data(attributes_data)
optimizer.set_input_json(opt_request.to_json())
optimizer.run_optimization()
...
# Save data for local use.
optimizer.write_risk_decomposition_report("report_riskDecompOptimal.csv",True)
optimizer.write_risk_decomposition_report("report_riskDecompInitial.csv",False)
Access and Support
The Northfield team provides personal support to Application programmers. We will help you establish access to the ACES Platform, develop a business scenario with you and your stakeholders, and provide you with a working model of your scenario in your language of choice that you can then use in your own programs.
For more information please contact our programmer support team.