First cut: it may work, with errors
For full flow see README
export RPC_URL=http://127.0.0.1:8545
export SUBGRAPH_URL="http://172.15.0.15:8000/subgraphs/name/oceanprotocol/ocean-subgraph"
export PRIVATE_KEY="xxx"
export STAKE_AMOUNT=1
where:
Install requirements if needed
pip install -r requirements.txt
Start the predictoor:
python3 main.py
The actual prediction code is in predict.py.
We call predict_function with 2 args:
estimated_time: estimated timestamp of block that we are going to predict. This is informal, blockchain mining time is not accurate
Function returns two variables:
predicted_confidence: int, 1 -> 100%. This sets the stake (STAKE_AMOUNT * predicted_confidence/100) that you are willing to put in your prediction.
You need to change the function code and do some of your stuff. Now, it's just doing some random predictions. For an examplem of a model that predicts the price dircetion of an asset every m
minutes see this link
If we want to predict the value for epoch E, we need to do it in epoch E - 2 (latest. Of course, we could predictor values for a distant epoch in the future if we want to) And to do so, our tx needs to be confirmed in the last block of epoch (otherwise, it's going to be part of next epoch and our prediction tx will revert)
But, for every prediction, there are some steps involved, each one taking it's toll on duration:
time until your tx is confirmed in a block
You can control how early to predict, taking the above in consideration, using env BLOCKS_TILL_EPOCH_END. It's translation is: With how many blocks in advanced untill epoch end do we start the prediction process. The default value is 5, which leaves us enough time. (Ie: if block generation duration is 12 sec, we have 60 seconds to do our job)