Getting started with Symphony BDK for Python#

This guide provides detailed information for beginners who want to bootstrap their first Symphony BDK project in Python. The Symphony BDK requires Python 3.8 or higher.

Starting with Symphony Generator#

This section requires npm (Node Package Manager) to be installed on your local machine as a prerequisite

For all Symphony BDK applications, you should start with the Symphony Generator. The Symphony Generator offers a fast way to bootstrap your Symphony BDK project in several languages, including Python:

npm i -g @finos/generator-symphony
yo @finos/symphony

After entering pod and bot information and selecting Bot Application as application type, you should be able to select Python as programming language. This will generated a configuration file, a requirements.txt and a simple python script.

Creating your project from scratch#

This section will help you to understand how to create your bot application from scratch.

Setuptools based project ( + requirements.txt)#

If you want to use setuptools, please configure your as follows:

from setuptools import setup

    description='My Python bot',

and your requirements.txt like:


Poetry based project#

If you want to use poetry as a build system, please configure your pyproject.toml as follows:

name = "my_bot"
version = "0.1.0"
description = "My bot"

python = "^3.8"
symphony-bdk-python = "^2.0.0"

requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

You can then run your script by running poetry run python

Create configuration file#

Before implement any code, you need to create your ~/.symphony/config.yaml configuration file according to your Symphony environment:

host:                       # your own pod host name

    username: bot-username                    # your bot (or service account) username
      path: /path/to/bot/rsa-private-key.pem  # your bot RSA private key

Click here for more detailed documentation about BDK configuration

Create a Simple Bot Application#

Now you can create a Simple Bot Application by creating a main script:

async def run():
    config = BdkConfigLoader.load_from_symphony_dir("config.yaml")

    async with SymphonyBdk(config) as bdk:
        datafeed_loop = bdk.datafeed()
        await datafeed_loop.start()

class RealTimeEventListenerImpl(RealTimeEventListener):

    def __init__(self, message_service):
        self._message_service = message_service

    async def on_message_sent(self, initiator: V4Initiator, event: V4MessageSent):
        await self._message_service.send_message(,
                                                 f"<messageML>Hello, {initiator.user.display_name}!</messageML>")

try:"Running datafeed example...")
except KeyboardInterrupt:"Ending datafeed example")
  1. The SymphonyBdk class acts as an entry point into the library and provides an API to access to the main BDK features such as Datafeed, Datahose or message service.

  2. Subscribe to the on_message_sent Real Time Event

  3. When any message is sent into a stream where your bot is a member, it will reply with a hello message.

  4. Start the Datafeed read loop