Env variable name | Is required | Default value | Description |
---|---|---|---|
PRIVATE_KEY | true | - | Private key for the bot account, needed to sign transactions. Use comma separated values to trade from multiple accounts: 0x123,0x456,0x789. |
NETWORK_TYPE | false | testnet | mainnet / testnet |
FUTURES | true | - | Future aliases, separated by comma. Example: "BINANCE-ETHUSDT-SEP24,BINANCE-ETHUSDT-JUL24" |
TRADE_AVERAGE_INTERVAL | false | 3000 | [seconds] Average interval between trades |
TRADE_MAX_SIZE | false | 100000 | [notional] Max notional amount |
TRADE_MAX_RISK | false | 200000 | [notional] Used in trading rules to compare against dv01. Set in notional, converted to dv01. |
RPC_URL | false | - | custom RPC URL |
MAX_GAS_LIMIT | false | 5,000,000 | Max gas limit |
MAX_GAS_PRICE_GWEI | false | 10 | Max gas price (Gwei) |
- Prepare .env config.
.env.example
can be used as reference.
touch .env
NOTE: Bot trading account (env: PRIVATE_KEY
) should have underlying tokens on balance to execute trades.
- Install dependencies and run the bot
npm i
npm run start
- Pull docker image from the public registry
docker pull rholabs/trading-bot:1.8.2
- Create .env file with list or environment variables.
.env.testnet.example
can be used as reference.
PRIVATE_KEY=<PRIVATE_KEY_ARBITRUM_SEPOLIA>
NETWORK_TYPE=testnet
FUTURES=BINANCE-ETHUSDT-JUN24,BINANCE-ETHUSDT-JUL24
TRADE_MAX_SIZE=100000
TRADE_MAX_RISK=200000
TRADE_AVERAGE_INTERVAL=3000
MAX_GAS_LIMIT=5000000
MAX_GAS_PRICE_GWEI=0.2
NOTE: Bot trading account (env: PRIVATE_KEY
) should have underlying tokens on balance to execute trades.
- Run bot in docker container:
docker run --env-file .env rholabs/trading-bot:1.8.2
Basic logic:
- Trades at random intervals selected from the range +-50%, averaging TRADE_AVERAGE_INTERVAL (Default: averaging a trade every 3000 seconds (50 minutes))
- Trades random notional between 0 and TRADE_MAX_SIZE (Default: 100,000 USDT)
- Side is chosen randomly, unless the resulting absolute exposure exceeds TRADE_MAX_RISK (Default: 200,000 USDT)
- If the exposure is >TRADE_MAX_RISK on either side (payer OR receiver), the bot selects the opposite side to reduce the exposure.
Learn more about services on NestJS website.
- Generate new service
advanced-strategy
:
nest generate service trading/advanced-strategy
NestJS will generate new service and add it to Trading module.
- Go to
src/trading/advanced-strategy/advanced-strategy.service.ts
and implement custom strategy. You can usesrc/trading/base-strategy/base-strategy.service.ts
as an example. - Add specific code for launching new strategy in AppService (
src/app.service.ts
)
Use comma separated values to trade from multiple accounts.
PRIVATE_KEY=0x123,0x456,0x789
docker buildx build -t rholabs/trading-bot:1.8.2 --platform linux/amd64 .
docker push rholabs/trading-bot:1.8.2