This script connects to the Gexbot real-time data API. It negotiates a connection, joins specified data groups, and decompresses/parses incoming Zstandard-compressed Protobuf messages.
.
├── proto/ # Source .proto definitions (e.g., gex.proto)
├── generated_proto/ # (Ignored by git) Compiled _pb2.py files
├── main.py # The main client script
├── decompression_utils.py # Decompression helper functions
├── requirements.txt # Python dependencies
├── .gitignore
└── README.md
-
Clone Repository Clone this repository to your local machine.
-
Create Virtual Environment It's highly recommended to use a virtual environment.
python3 -m venv venv source venv/bin/activate -
Install Dependencies Install all required Python packages.
pip install -r requirements.txt
This client reads data from Protobuf messages. You must compile the source .proto files (located in the proto/ directory) into Python modules.
-
Ensure
generated_protoExists Create the output directory.mkdir -p generated_proto
-
Create Python Package The directory must be a Python package to be importable.
touch generated_proto/__init__.py
-
Run
protocCompiler Usegrpc_tools.protoc(installed fromrequirements.txt) to generate the Python files. This command finds all.protofiles in theproto/directory and outputs the compiled_pb2.pyand_pb2.pyifiles intogenerated_proto/.python3 -m grpc_tools.protoc -I=proto --python_out=generated_proto --pyi_out=generated_proto proto/*.proto-I=proto: Specifies theprotodirectory as the import path.--python_out=generated_proto: Outputs_pb2.pyfiles to this directory.--pyi_out=generated_proto: Outputs_pb2.pyitype-hinting files to this directory.proto/*.proto: Compiles all.protofiles in theprotodirectory.
-
Set API Key The script requires your
GEXBOT_API_KEYto be set as an environment variable.export GEXBOT_API_KEY="your_api_key_here"
-
Configure Subscriptions Open
main.pyand edit the "USER SELECTION" section (lines 70-137) to subscribe to your desired tickers and data feeds. Uncomment or add items to:ACTIVE_TICKERSACTIVE_CLASSIC_CATEGORIESACTIVE_STATE_GEX_CATEGORIESACTIVE_STATE_GREEKS_ZERO_CATEGORIESACTIVE_STATE_GREEKS_ONE_CATEGORIESACTIVE_ORDERFLOW_CATEGORIES
After setting your API key and configuring subscriptions, run the script:
python main.py