This README shows how to earn $ by running a predictoor bot on mainnet.
- Install
- Simulate modeling & trading
- Run bot on testnet
- Run bot on mainnet
- Claim payout
- Check performance
Then, you can go beyond: optimize model, run >1 bots, and more.
In a new console:
# clone the repo and enter into it
git clone https://github.com/oceanprotocol/pdr-backend
cd pdr-backend
# Create & activate virtualenv
python -m venv venv
source venv/bin/activate
# Install modules in the environment
pip install -r requirements.txt
#add pwd to bash path
export PATH=$PATH:.
If you're running MacOS, then in console:
codesign --force --deep --sign - venv/sapphirepy_bin/sapphirewrapper-arm64.dylib
Simulation allows us to quickly build intuition, and assess the performance of the data / predicting / trading strategy (backtest).
Copy ppss.yaml
into your own file my_ppss.yaml
and change parameters as you see fit.
Let's simulate! In console:
pdr sim my_ppss.yaml
What it does:
- Set simulation parameters.
- Grab historical price data from exchanges and stores in
parquet_data/
dir. It re-uses any previously saved data. - Run through many 5min epochs. At each epoch:
- Build a model
- Predict up/down
- Trade.
- Plot total profit versus time, and more.
- (It logs this all to screen, and to
out*.txt
.)
The baseline settings use a linear model inputting prices of the previous 10 epochs as inputs, a simulated 0% trading fee, and a trading strategy of "buy if predict up; sell 5min later". You can play with different values in runsim.py.
Profit isn't guaranteed: fees, slippage and more eats into them. Model accuracy makes a huge difference too.
Predictoor contracts run on Oasis Sapphire testnet and mainnet. Sapphire is a privacy-preserving EVM-compatible L1 chain.
Let's get our bot running on testnet first.
First, tokens! You need (fake) ROSE to pay for gas, and (fake) OCEAN to stake and earn. Get them here.
Then, copy & paste your private key as an envvar. In console:
export PRIVATE_KEY=<YOUR_PRIVATE_KEY>
Update my_ppss.yaml
as desired.
Then, run a bot with modeling-on-the fly (approach 3). In console:
pdr predictoor 3 my_ppss.yaml sapphire-testnet
Your bot is running, congrats! Sit back and watch it in action. It will loop continuously.
At every 5m/1h epoch, it builds & submits >1 times, to maximize accuracy without missing submission deadlines. Specifically: 60 s before predictions are due, it builds a model then submits a prediction. It repeats this until the deadline.
The CLI has a tool to track performance. Type pdr get_predictoor_info -h
for details.
You can track behavior at finer resolution by writing more logs to the code, or querying Predictoor subgraph.
Time to make it real: let's get our bot running on Sapphire mainnet.
First, real tokens! Get ROSE via this guide and OCEAN via this guide.
Then, copy & paste your private key as an envvar. (You can skip this if it's same as testnet.) In console:
export PRIVATE_KEY=<YOUR_PRIVATE_KEY>
Update my_ppss.yaml
as desired.
Then, run the bot. In console:
pdr predictoor 3 my_ppss.yaml sapphire-mainnet
This is where there's real $ at stake. Good luck!
Track performance, as in testnet.
When running predictoors on mainnet, you have the potential to earn $.
Here are instructions to claim your earnings.
You've gone through all the essential steps to earn $ by running a predictoor bot on mainnet.
The next sections describe how to go beyond, by optimizing the model and more.
Once you're familiar with the above, you can make your own model and optimize it for $. Here's how:
- Fork
pdr-backend
repo. - Change predictoor approach3 modeling code as you wish, while iterating with simulation.
- Bring your model as a Predictoor bot to testnet then mainnet.
PM2 is "a daemon process manager that will help you manage and keep your application online."
This section shows first how to use PM2 to run one bot on testnet. It then shows how to extend this to mainnet, and many bots at once.
First, install PM2: npm install pm2 -g
Then, prepare the PM2 config file:
- Skim over
pm2-testnet-predictoor.config.js
. It names the script, and sets envvars like we did above, but automatically. - Open the local version of this file. It's in the root of your
pdr-backend/
directory. In the file, setYOUR_PRIVATE_KEY
.
Now, run the bot with PM2. In console:
pm2 start pm2-testnet-predictoor.config.js
Your bot's running on testnet again! This time with the help of PM2.
Next, monitor the logs: pm2 logs pm2-testnet-predictoor
(ctrl-c to stop)
Finally, stop the bot: pm2 stop pm2-testnet-predictoor
Congrats! You've used PM2 to start, monitor, and stop a bot on testnet.
To run on mainnet: it's a mainnet config file pm2-mainnet-predictoor.config.js
. It's like testnet, with different envvars. Work with the local version of this file.
To run 20 bots: alter the config file as needed. Or, have 20 config files.
Other interesting PM2 commands:
- List all running processes:
pm2 ls
- Stop process with id=0:
pm2 stop 0 # (similar for other cmds)
- Stop all processes:
pm2 stop all
- Top-level help:
pm2 help
- Help for "start" command:
pm2 help start # (similar for other cmds)
- More yet: PM2 docs
To scale up compute or run without tying up your local machine, you can run bots remotely. Get started here.
To get extra-fast block iterations, you can run a local test network (with local bots). It does take a bit more up-front setup. Get started here.
You will lose money as a predictoor if your $ out exceeds your $ in. If you have low accuracy you’ll have your stake slashed a lot. Do account for gas fees, compute costs, and more. Everything you do is your responsibility, at your discretion. None of this repo is financial advice.