Elevate Your Trading: Integrating Custom Data with OpenBB Terminal Pro

Now a change pace after last week’s deployment topic. In the ever-evolving financial technology landscape, the ability to customize and extend your trading tools can be a significant competitive advantage. OpenBB Terminal Pro, a powerful market analysis and trading platform, has just raised the bar with its latest feature: custom backend integration. This new capability allows traders and developers to seamlessly incorporate their proprietary data, algorithms, and analysis into the Terminal Pro environment. Additionally, OpenBB Terminal Pro’s custom backend integration opens up new possibilities for creating an agentic stock analysis tool. Traders can now harness their own unique insights and models to make informed trading decisions within the platform. This level of customization and control sets the Terminal Pro apart as a versatile and powerful tool for today’s traders.

The Power of Customization in Trading

In the world of trading, one size rarely fits all. Every trader has unique strategies, data sources, and analytical methods. Integrating these custom elements into a comprehensive platform like OpenBB Terminal Pro can streamline workflows, enhance decision-making, and improve trading outcomes.

OpenBB’s new custom backend integration feature addresses this need for customization head-on. It lets users bring their specialized tools and data directly into the Terminal Pro interface, creating a truly personalized trading environment.

Understanding OpenBB’s Custom Backend Integration

At its core, OpenBB’s custom backend integration uses a “cookie-cutter” or templated approach. This standardized method provides a flexible yet structured way to host and integrate your data into widgets within Terminal Pro. The beauty of this approach lies in its simplicity and versatility – it works whether your data is hosted internally or externally, and it’s language-agnostic, allowing you to use the programming tools you’re most comfortable with.

The cookie-cutter approach revolves around two key elements: a widgets.json file and your custom backend endpoint. Here’s how it works:

a) The widgets.json file: This file serves as the blueprint for your custom widgets. It defines properties such as name, description, category, type, and endpoint, as well as the layout of your retrieved data. Here’s an example widgets.json file:

JSON
{
  "capital_companion_maverick_top_stocks": {
    "name": "Capital Companion Maverick Top Stocks",
    "description": "Get current Maverick Top Stocks from Capital Companion",
    "category": "stocks",
    "searchCategory": "stocks",
    "endpoint": "maverick-top-stocks",
    "gridData": {
      "w": 20,
      "h": 5
    },
    "data": {
      "table": {
        "index": "symbol",
        "showAll": false,
        "columnsDefs": [
          {
            "headerName": "Ticker",
            "field": "symbol",
            "chartDataType": "category"
          },
          {
            "headerName": "Name",
            "field": "name",
            "chartDataType": "category"
          },
          {
            "headerName": "Open",
            "field": "open",
            "chartDataType": "series"
          },
          {
            "headerName": "High",
            "field": "high",
            "chartDataType": "series"
          },
          {
            "headerName": "Low",
            "field": "low",
            "chartDataType": "series"
          },
          {
            "headerName": "Close",
            "field": "close",
            "chartDataType": "series"
          },
          {
            "headerName": "Volume",
            "field": "volume",
            "chartDataType": "series"
          },
          {
            "headerName": "Average 30-Day Volume",
            "field": "AVG_VOL_30_D",
            "chartDataType": "series"
          },
          {
            "headerName": "Average Daily Range Percentage",
            "field": "ADR_PCT",
            "chartDataType": "series"
          },
          {
            "headerName": "Average True Range",
            "field": "ATR",
            "chartDataType": "series"
          }
        ]
      }
    }
  }
}

This file defines a widget, specifies the endpoint to call for data retrieval, and outlines the structure of the data it will display.

b) Your Custom Backend API: You’ll need to create an API that can serve the data defined in your widgets.json file. This API should be capable of returning data in JSON format.

Implementing Your Custom API

Let’s walk through an example of implementing a custom API using Python and FastAPI. The GitHub repo is here.

Python
from pathlib import Path
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse, RedirectResponse

import requests
import json

app = FastAPI()

origins = [
    "http://localhost",
    "http://localhost:1420",
    "http://localhost:5050",
    "https://pro.openbb.dev",
    "https://pro.openbb.co",
    "https://excel.openbb.co",
    "https://excel.openbb.dev",
]

app.add_middleware(
    CORSMiddleware,
    allow_origins=origins,
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)


@app.get("/", include_in_schema=False)
def docs_redirect():
    return RedirectResponse(url="/docs")


@app.get("/health", include_in_schema=False)
def health_check():
    return {"status": "ok"}


@app.get("/widgets.json")
def get_widgets():
    """Widgets configuration file for the OpenBB Terminal Pro"""
    return JSONResponse(content=json.load((Path(__file__).parent.resolve() / "widgets.json").open()))


@app.get("/maverick-top-stocks")
def get_maverick_top_stocks():
    """Get the Maverick Top Stocks Report from the Capital Companion API"""
    response = requests.get("https://capitalcompanion.io/maverick-top-stocks")

    if response.status_code == 200:
        return response.json()["maverick_stocks"]

    print(f"Request error {response.status_code}: {response.text}")
    return JSONResponse(content={"error": response.text}, status_code=response.status_code)


if __name__ == "__main__":
    import uvicorn

    uvicorn.run(app, host="0.0.0.0", port=5050)

This example sets up a FastAPI application with two key endpoints:

  1. /widgets.json: Serves the widget configuration file.
  2. /maverick-top-stocks: Fetches data from an external API and returns it in the format the widget expects. In this case, I’m fetching the current Maverick Top Stocks report from the Capital Companion API. This is a proprietary report anyone can access for free from Capital Companion. It contains the current top bullish stock swing setups for trend-following traders.

Connecting Your API to OpenBB Terminal Pro

Once your API is up and running, users can add the custom widgets to their Terminal Pro interface. They simply need to provide the base URL of your API, and Terminal Pro will use the /widgets.json endpoint to discover available widgets and their configurations.

Real-World Applications

The possibilities opened up by this feature are vast. OpenBB has provided a GitHub repo with examples I suggest you look at. Here are a few potential applications:

  • Proprietary Stock Screeners: Integrate your custom stock screening algorithms directly into Terminal Pro.
  • Alternative Data Sources: Bring in unique datasets that give you an edge in your analysis.
  • Custom Risk Models: Implement your proprietary risk assessment tools as widgets.
  • Automated Trading Signals: Display real-time signals from your automated trading systems within Terminal Pro.

Conclusion

OpenBB Terminal Pro’s new custom backend integration feature represents a significant step forward in the customization and extensibility of trading platforms. By allowing traders and developers to integrate their proprietary tools and data seamlessly, OpenBB is fostering innovation and empowering its users to create truly personalized trading environments.

Whether you’re a quantitative trader looking to integrate complex algorithms, a fundamental analyst with access to unique data sources, or an engineer building cutting-edge fintech tools, this feature opens up new possibilities for enhancing your trading workflow.

I encourage you to explore this feature, create some widgets, and push the boundaries of what’s possible in your trading analysis while I continue swapping symbols.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top