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.
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.
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
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)
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)
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:
pandas
dataframesAll 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.