Python API

Python packages for accessing AWTS APIs are generated automatically by Buf and can be installed using pip. In addition, we provide a rich SDK for easier access to data and integration with your workflows.

API client library

The API client is auto-generated and provides raw access to the AWTS APIs. Use this for maximum flexibility, and/or for functionality not yet covered by the SDK.

Installation

pip install grpcio
pip install --extra-index-url=https://buf.build/gen/python alphaweighted-awts-protocolbuffers-python
pip install --extra-index-url=https://buf.build/gen/python alphaweighted-awts-grpc-python

Connect

Set up a connection to the server. Note that each service (Data, News, Results, etc) has a different path and therefore should be set up as a separate stub. All follow the same naming convention for imports.

If you run the Mux module you should specify the Mux hostname/port to connect to for all services; mux will automatically route requests to the right underlying module, irrespective of which service or how many are running in your environment.

import awts.data.v1.data_pb2 as awtsdata
from awts.data.v1.data_pb2_grpc import DataServiceStub

import grpc

channel = grpc.insecure_channel('localhost:36000')
stub = DataServiceStub(channel)

Make API calls

Here is a brief example of a request to get the current price for QQQ and print it:

req = awtsdata.ValueRequest()
req.ref = "POLYGON:QQQ"

resp = stub.Value(req)
print(resp.last.value)

SDK

The Python SDK sits atop the client libraries and bundles additional local functionality to make it quicker/easier to work with AWTS systems and to integrate with your existing workflows.

The SDK can be used to easily:

  • pull market data into pandas dataframes
  • run Python-based strategies, leveraging the AWTS engine, execution and results management
  • plug new/custom data sources into your AWTS environment

All of these things, and more, are of course possible through the underlying APIs (which the SDK uses), but the SDK on top makes it easier and faster to work with.

The Python SDK is not yet published. Please contact us for early access.