Interactive DCA script which uses a telegram frontend to pass commands.
-
Make a Telegram bot:
- Visit @BotFather on Telegram
- Send
/newbot
and follow the prompts to create your bot - Save the API token that BotFather gives you - this will be your
telegram_token
in config.yaml - Add your bot to a private Telegram channel/group with just you.
- Send a test message to your bot
- Visit https://api.telegram.org/bot<your_token>/getUpdates to get your chat_id.
- Copy the "id" field from the JSON response - this will be your
telegram_chat_id
in config.yaml - Disable privacy mode by sending
/setprivacy
to BotFather and selecting your bot - Send another test message to verify everything is working
-
Fill in config:
Create a
config.yaml
file in the project root. Below is an example configuration:wallet: "<your wallet name>" stake_amount: 0.01 # Base TAO amount to stake per block. validator: "5F4tQyWrhfGVcNhoqeiNsR6KjD4wMZ2kfhLj4oHYuyHbZAc3" # OTF exclude_list: [..] # Subnets to always exclude (never buy) base_alpha: 0.0003 # EMA smoothing factor. preferences: # Preference multipliers per subnet. "4": 1.5 "9": 2.0 # (2 here means this subnet gets a score multiple of 2x when choosing the best subnet to DCA into. telegram_token: "YOUR_TELEGRAM_BOT_TOKEN" # ( see step 1.) telegram_chat_id: "-123456789" # Your Telegram channel/group chat ID ( see step 1.) telegram_update_interval: 10 # Send periodic updates every 10 blocks.
Note:
- The
preferences
keys must be strings. - Update
telegram_token
andtelegram_chat_id
with your actual Telegram bot token and channel/group ID.
- The
-
Clone the Repository:
git clone https://github.com/unconst/DynamicBot.git cd DynamicBot
-
Install Dependencies:
Use pip to install required packages:
python3 -m venv venv source venv/bin/activate python3 -m pip install -r requirements.txt
-
Install PM2:
For Ubuntu/Debian:
apt update apt install -y nodejs npm npm install -g pm2
For MacOS:
# Install Homebrew if not already installed /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" # Install Node.js and npm brew install node # Install PM2 globally npm install -g pm2
-
Run
Run the bot.
export WALLET_PASSWORD='<YOUR WALLET PASSWORD HERE>'; pm2 delete autobot; pm2 start autobot.py --interpreter python3 --name autobot --cron-restart="0 * * * *"; pm2 logs autobot
-
Use Telegram to interact
Interact with the bot using Telegram. Below are the supported commands:
-
/pause
Description: Stops the bot staking into subnets. Response: Confirms the bot has been paused. -
/start
Description: Starts the bot staking into subnets Response: Confirms the bot has been started. -
/info
<netuid>
Description: Returns information about the specified subnet, including:- Current price.
- Your current stake.
- Current preference multiplier.
- Current block number.
-
/boost
<netuid>
Description: Increases the preference multiplier for the specified subnet by 0.1.
Response: New preference value. -
/slash
<netuid>
Description: Decreases the preference multiplier for the specified subnet by 0.1 (minimum 0.1).
Response: New preference value. -
/exclude
<netuid>
Description: Adds the specified subnet to the exclude list (i.e., the bot will not stake in this subnet).
Response: Confirmation message. -
/unstake
<netuid>
<amount>
Description: Sells (unstakes) the specified amount of TAO from the given subnet.
Response: Confirmation of the unstake action. -
/stake
<netuid>
<amount>
Description: Buys (stakes) the specified amount of TAO into the given subnet.
Response: Confirmation of the stake action. -
/amount
<value>
Description: Sets the base stake amount used per block to the specified value.
Response: New stake amount. -
/balance
Description: Returns a summary of your current portfolio, including:- Wallet balance.
- Current block.
- Staked amounts per subnet.
-
/history
Description: Returns a detailed history summary since the last/history
command. The summary includes:- Time elapsed and number of blocks since the last history snapshot.
- Total amount staked during this period.
- The difference in total stake.
- PNL (difference between the previous and current combined wallet + stake value).
- A per‑subnet breakdown of the increase in stake. Response: A formatted message with all the details.
-
Telegram Updates Not Received:
- Ensure that your Telegram bot is added to your group or channel and that privacy mode is disabled if necessary.
- Verify that your
telegram_token
andtelegram_chat_id
are correct.
-
Wallet Connection Issues:
- Check that the
WALLET_PASSWORD
environment variable is set. - Verify the wallet name and file permissions.
- Check that the
-
Bittensor Connectivity:
- Confirm that the endpoint in your configuration is correct and that you have a stable network connection.
DYOR. NFA.