This a proof of concept trading bot/interface for the Buffer Finance protocol that takes Trading View alerts and submits 5 minute option trades on the price of ETH provided by the alert in the direction included in the alert.
The bot assumes you will use a remote RPC provider (like Infura or Alchemy) where you will submit your trades. I use Alchemy (though others may work). You need to create an account and create "apps" (one for Arbitrum Goerli and one for Arbitrum Mainnet).
- Clone this repo
- Install dependencies using
npm i
- Create a
.env
in the directory root following .env.example - Put your Alchemy API keys in each of the named fields in
.env
- Set the
DEV
value to true to trade on the Buffer testnet - Install ngrok
- Run
npm run dev
to start the bot - Run
path/to/ngrok http 3000
You should see something like:
Session Status online
Account yourSecretNgrokUserName (Plan: Free)
Version 3.1.1
Region United States (us)
Latency 47ms
Web Interface http://127.0.0.1:4040
Forwarding https://b0cf-71-69-227-154.ngrok.io -> http://localhost:3000
Copy the forwarding address that ends in .ngrok.io
If you go this route, once you've gone through the deployment flow and populate your environmental variables, copy the deployment URL that Vercel gives you.
- Create a new TradingView alert on an ETHUSD chart.
- Click on the
Notifications
tab - Paste the address from above (either
ngrok
orvercel
deployment link into theWebhook URL
field, append/api/trade
to the end of it, and make sure it has a checkmark next to it. Should like something likehttps://ngrok.io/my-api-link/api/trade
orhttps://my.verceltradingbot.app/api/trade
- Select
Settings
- Paste
{"pair":"{{ticker}}", "price": "{{close}}", "direction": "above", "accessToken": "mySuperSecretAccessToken", "duration": "5", "size": "1"}
in the alert message box. This will trigger a "long" option trade with a duration of 5 minutes and a size of $1.- You can change the following options to customize your trade:
- Size can be any whole number (so changing to 10 will give you a $10 option)
- Duration can be any whole number (so changing to 10 will give you a 10 minute option)
- Replace the access token string with the one from your
config.json
above
- You can change the following options to customize your trade:
- Set your trigger condition and start the alert.
If all goes well, you should see a transction logged to the console indicating a trade was submitted.
- This bot assumes you have alread approved the Buffer contract to use USDC on the wallet you provide to it. Make sure you go to Buffer Finance and approve USDC before trying to use this bot.
- The access token is not required but will help secure your bot from random griefers testing out their trading strategies
- There is a hardcoded 5 second cool down period between trades. So, if your TradingView alert gets triggered more than once per 5 seconds, every alert after the first will be ignored until the cooldown period passes