The official reference for the Bot Assistant Query Language (BAQL)
BAQL (Bot Assistant Query Language) is a domain specific language used for expressing declarative requirements for Bot Assistant engines used in automated trading systems.
Its goal is to provide a flexible and ergonomic semantic to users and a machine parseable set of instructions that can be used to query for the requested data.
It’s designed to be platform agnostic, albeit some expressions might not be available in all dialects.
The syntax of the language is currently maintained by The Trading Parrot community and it’s subject to evolution over time. It follows the rules of semantic versioning.
Queries are implicit assumed as part of the language, therefore it’s not required to have explicit imperative clauses.
500
characters, including the ignored ones100000
Each action contains an operator and a predicate. Each operator comes with its own rules (criteria) but all of them should complain about the restrictions of BAQL grammar and syntax. The operators should be extensible and independent one each other.
Operator to command changes to the pairs settings of a bot.
PS
Operator name
Operator to specify the bot wants to receive a specified custom signal.
SIG
Operator name
Operator to complement the lifecycle of the bot and its deals.
ORC
Operator name
Here is the EBNF-like grammar of the BAQL. The spaces in the grammar definition are for human readability. The grammar described here isn’t meant to be 100% accurate. Here are some missing details:
sentence: prefix actions ((action_separator)* suffix)?
actions: action ((action_separator)+ action)*
prefix: 'BAQL:'
suffix: '!@'
action_separator: ' '
action: operator
| operator operator_separator predicate
operator: 'PS'
| 'SIG'
| 'ORC'
operator_separator: ':'
list_start: '['
list_end: ']'
list_separator: ' '
predicate: categories criteria_separator sort
categories: 'ALL'
| category_list
category_list: category (category_separator category)*
category: 'DEFI'
| 'ERC'
| 'NFT'
| 'DOT'
| 'BSC'
| 'ZIL'
| 'MEME'
| 'SC'
category_separator: '&'
criteria_separator: '_'
sort: sort_number criteria_separator sort_keyword reverse_keyword
sort_number: [0-9]+
sort_keyword: 'LCGS'
| 'LCAR'
| 'DUSD'
| 'DBTC'
| 'HUSD'
| 'SV'
| 'BES'
| 'BUS'
| 'MC'
| 'MV'
reverse_keyword: '.r'
| ''
Sort keywords:
Sort Name | Description | Default Sort Order |
---|---|---|
LCGS | LunarCrush Galaxy Scoretm | descending |
LCAR | LunarCrush AltRanktm | ascending |
DUSD | 24h % change (USD) | descending |
DBTC | 24h % change (BTC) | descending |
HUSD | 1h % Change (USD) | descending |
SV | Social Volume | descending |
BUS | Bullish Sentiment | descending |
BES | Bearish Sentiment | descending |
MC | Market cap | descending |
MV | Market volume | descending |
Supported categories:
Category | Description |
---|---|
DEFI | DeFi |
ERC | ERC-20 |
NFT | NFT |
DOT | DOT ecosystem |
BSC | BSC ecosystem |
ZIL | ZIL ecosystem |
SC | Stable coins |
MEME | Meme coins |
predicate: signal_name
| signal_list
signal_name: [a-zA-Z0-9]+
signal_list: list_start signal_name ((list_separator)+ signal_name)* list_end
predicate: orchestrator
| orchestrator_list
orchestrator_list: list_start orchestrator ((list_separator)+ orchestrator)* list_end
orchestrator: orchestrator_provider operator_separator orchestration_command_list
orchestrator_provider: [a-zA-Z0-9]+
orchestration_command_list: orchestration_command (command_separator orchestration_command)?
orchestration_command: orchestration_action orchestration_separator orchestration_reaction
orchestration_separator: '_'
command_separator: '&'
orchestration_action: [a-zA-Z0-9]+
orchestration_reaction: [a-zA-Z0-9]+
❌ ALL_50_BUS
INVALID:
Missing starting BAQL tag
❌ BAQL:ALL_50BUS
INVALID:
No available actions
❌ BAQL:XXX:ALL_50BUS
INVALID:
No available actions
✅ BAQL:PS:ALL_50_BUS
✅ BAQL:PS:MEME_25_DUSD
✅ BAQL:PS:ALL_200_MC.r
✅ BAQL:PS:DEFI&NFT_25_DBTC
✅ BAQL:PS:ALL_10_LCAR
❌ BAQL:PS:ALL_10_ZZ
INVALID:
PS: Invalid sorting order keyword
❌ BAQL:PS:ALL_LCAR
INVALID:
PS: Action malformed
✅ BAQL:SIG:PETRO
✅ BAQL:SIG:[MCC]
✅ BAQL:SIG:[PETRO LAMBO]
❌ BAQL:SIG:[MCC_MCB]
INVALID:
SIG: Invalid signal name format❌ BAQL:SIG:[MCC LAMBO MCC]
INVALID:
SIG: Multiple occurrences of the same signal❌ BAQL:SIG:[MCC
INVALID:
Predicate list malformed❌ BAQL:SIG:[[MCC] [LAMBO]]
INVALID:
Nested predicate lists are not supported❌ BAQL:SIG:__[MCC LAMBO]
INVALID:
Composite predicate malformed✅ BAQL:ORC:[ORIG:SELL_STPCL]
✅ BAQL:ORC:ORIG:SELL_STPCL
✅ BAQL:ORC:[ORIG:SELL_STP&BUY_STT]
✅ BAQL:ORC:[ORIG:SELL_STP&BUY_STT ST:SELL_STPCL&BUY_STT]
❌ BAQL:ORC:]ORIG:BUY_STT]
INVALID:
Predicate list malformed❌ BAQL:ORC:[ORIG:SELL_STP&&SELL_STPCL]
INVALID:
ORC: Action malformed❌ BAQL:ORC:[ORIG:SELL_STP&SELL_STP]
INVALID:
ORC: Multiple occurrences of the same command action❌ BAQL:ORC:[ORIG:SELL_STP ORIG:SELL_STPCL]
INVALID:
ORC: Multiple occurrences of the same orchestrator provider✅ BAQL:PS:ALL_3_LCAR SIG:SERPIL
✅ BAQL:PS:ALL_3_LCAR SIG:SERPIL!@
✅ BAQL:PS:ALL_3_LCAR SIG:SERPIL !@
✅ BAQL:PS:ALL_3_LCAR SIG:SERPIL !@ - further text
✅ BAQL:PS:ALL_10_LCGS SIG:LAMBO ORC:[ORIG:SELL_STP&BUY_STT ST:SELL_STPCL&BUY_STT]
✅ BAQL:PS:MEME&DEFI_50_LCGS ORC:ORIG:BUY_STT
❌ BAQL:PS:ALL_3_LCAR_SIG:SERPIL
INVALID:
PS: Action malformedComments are not allowed in BAQL.
Code | Meaning |
---|---|
1001 |
String too long: Max 500 chars |
1002 |
Missing starting BAQL tag |
1003 |
Additional start tags |
2001 |
No available actions |
2002 |
Unsupported action |
2003 |
Multiple occurences of the same action |
2004 |
Nested predicate lists are not supported |
2005 |
Predicate list malformed |
2006 |
Composite predicate malformed |
3001 |
PS: Action malformed |
3002 |
PS: Unsupported categories |
3003 |
PS: Invalid n. of tokens [1,99999] |
3004 |
PS: Invalid sorting criteria |
3005 |
PS: Invalid sorting order keyword |
4001 |
SIG: Invalid signal name format |
4002 |
SIG: Multiple occurrences of the same signal |
5001 |
ORC: Action malformed |
5002 |
ORC: Multiple occurrences of the same orchestrator provider |
5003 |
ORC: Multiple occurrences of the same command action |
Signal Name | Description |
---|---|
SERPIL | Serpil signal |
MCC | Market Cipher Conservative signal |
MCR | Market Cipher Risky signal |
MCB | Market Cipher Bear (short) signal |
BIANCA | Bianca signal |
LAMBO | Lambo signal |
POISON | Parrot Poison signal |
PETRO | Petro signal |
Provider | Description |
---|---|
ORIG | Original TTP Orchestrator |
ST | SuperTrend 1H EMA Orchestrator |
STHA2H | SuperTrend HA 2H EMA Orchestrator |
HIVE1H | Hive 1H bull:60C4MinDiv, bear:7C2MinDiv |
RSIRALS | RSI ratio LS 1H |
TEST | Fast shooting ORC for testing purposes |
Action | Description |
---|---|
SELL | Signal when the market is rather overbought |
BUY | Signal when the market is rather oversold |
Reaction | Description |
---|---|
STP | Stop the bot |
STPCL | Stop the bot and close bot deals at market price |
CL | Close bot deals at market price |
STPCA | Stop the bot and cancel all bot deals |
CA | Cancel all bot deals |
STT | Start the bot |
STTDL | Start the bot and start new deal (single-pair bot) |