Running a Strategy Locally
In order for you to run a Strategy locally, there are a few things you have to have.
- Cybotrade API-key and API-secret
- Exchange API-key and API-secret
Cybotrade API-key and API-secret is required for running any type of strategy, be it Live, LiveTestnet, Backtest and etc.. The exchange API-key and API-secret is required only for Live, LiveTestnet, Backtest and etc..
You can retrieve the Cybotrade API-key and API-secret from here (opens in a new tab).
As for exchange API-key and API-secret, refer to the exchange documentation of your prefered exchange.
Setup
This guide only covers requirements to run strategies locally, for an example on how to write a Strategy refer to the overview guide.
exchange-keys.json
This is a required file that should be placed in the directory where you run the strategy.
The exchange-keys.json schema can be seen with the example below:
[
{
"exchange": "{EXCHANGE}",
"api_key": "{YOUR_EXCHANGE_API_KEY}",
"api_secret": "{YOUR_EXCHANGE_API_SECRET}",
"api_passphrase": "{YOUR_EXCHANGE_API_PASSPHRASE}",
"environment": "{EXCHANGE_ENVIRONMENT}"
}
]
As of right now the only supported exchange value is bybit_linear
.
The table below shows the current supported exchanges.
Exchange | Supported |
---|---|
bitget_linear | ✅ |
bitget_spot | ❌ |
bybit_linear | ✅ |
bybit_spot | ❌ |
binance_linear | ✅ |
binance_spot | ❌ |
okx_linear | ✅ |
okx_spot | ❌ |
The exchange environment denoted here refers to the either mainnet
or testnet
.
An example of this exchange-keys.json would be
[
{
"exchange": "bybit_linear",
"api_key": "my_bybit_api_key",
"api_secret": "my_bybit_api_secret",
"environment": "testnet"
}
]
Do note that some exchanges (such as OKX and Bitget that are currently supported) has a 'Passphrase' for their api-keys, this api_passphrase is optional and is only required when passing credentials for exchanges mentioned prior.
[
{
"exchange": "bitget_linear",
"api_key": "my_bitget_api_key",
"api_secret": "my_bitget_api_secret",
"api_passphrase": "my_bitget_api_passphrase"
"environment": "mainnet"
}
]
For an example if your current working directory is strategies_directory
the file should be placed as such:
- exchange-keys.json
- my_strategy.py
if your current working directory is before strategies_directory
then place the exchange-keys.json as such:
- exchange-keys.json
RuntimeConfig
When setting up the RuntimeConfig make sure to include your cybotrade API-key and API-secret as well as the path to your exchange-keys.json.
For an example:
...
permutation = Permutation(RuntimeConfig(
...
mode=RuntimeMode.Live,
api_key="YOUR_CYBOTRADE_API_KEY",
api_secret="YOUR_CYBOTRADE_API_SECRET",
exchange_keys="path/to/your/exchange-keys.json",
...
))
hyper_parameters = {}
async def start_backtest():
await permutation.run(hyper_parameters, Strategy)
asyncio.run(start_backtest())
Note that the path to the exchange-keys.json is based off your current working directory when you run the
my_strategy.py
script.