Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#692 - Implement cutoff seconds to stop predictions #696

Merged
merged 6 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pdr_backend/ppss/predictoor_ss.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ def revenue(self) -> Eth:
def s_until_epoch_end(self) -> int:
return self.d["bot_only"]["s_until_epoch_end"]

@property
def s_cutoff(self) -> int:
if "s_cutoff" not in self.d["bot_only"]:
return 10
return self.d["bot_only"]["s_cutoff"]

# --------------------------------
# setters (add as needed)
@enforce_types
Expand Down
8 changes: 8 additions & 0 deletions pdr_backend/predictoor/predictoor_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ def take_step(self):
# within the time window to predict?
if self.cur_epoch_s_left > self.epoch_s_thr:
return
if self.cur_epoch_s_left < self.s_cutoff:
return

logger.info(self.status_str())

Expand Down Expand Up @@ -168,6 +170,11 @@ def epoch_s_thr(self):
"""Start predicting if there's > this time left"""
return self.ppss.predictoor_ss.s_until_epoch_end

@property
def s_cutoff(self):
"""Stop predicting if there's < this time left"""
return self.ppss.predictoor_ss.s_cutoff

@property
def s_per_epoch(self) -> int:
return self.feed.seconds_per_epoch
Expand All @@ -193,6 +200,7 @@ def status_str(self) -> str:
s += f", target_slot={self.target_slot}"
s += f". {self.cur_epoch_s_left} s left in epoch"
s += f" (predict if <= {self.epoch_s_thr} s left)"
s += f" (stop predictions if <= {self.s_cutoff} s left)"
s += f". s_per_epoch={self.s_per_epoch}"
return s

Expand Down
33 changes: 16 additions & 17 deletions ppss.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,30 @@ lake_ss:
parquet_dir: parquet_data
feeds:
- binance BTC/USDT ETH/USDT 5m
# - binance BTC/USDT ETH/USDT BNB/USDT XRP/USDT ADA/USDT DOGE/USDT SOL/USDT LTC/USDT TRX/USDT DOT/USDT 5m
# - kraken BTC/USDT 5m
# - binance BTC/USDT ETH/USDT BNB/USDT XRP/USDT ADA/USDT DOGE/USDT SOL/USDT LTC/USDT TRX/USDT DOT/USDT 5m
# - kraken BTC/USDT 5m
st_timestr: 2023-06-01_00:00 # starting date for data
fin_timestr: now # ending date for data

predictoor_ss:
predict_feed: binance BTC/USDT c 5m
approach: 2 # 1->50/50; 2->model-based
stake_amount: 100 # How much your bot stakes. In OCEAN per epoch, per feed

sim_only:
others_stake: 10000 # How much all others' bots stake. In OCEAN per epoch, per feed. Calcs: stake volume = 10e6 $/day/20_feeds = 34700 $/epoch/20_feeds (bc 288 5m epochs/day) = 1735 $/epoch/feed = 2313 OCEAN/epoch/feed (at 1 OCEAN=$0.75)
others_accuracy: 0.50001 # What percent of others' bots stake is correct. Value in range 0.0-1.0. 0.50001 means mostly 50-50 stake and some small fry predicting a bit accurately
revenue: 0.93006 # Sales revenue going towards predictoors. In OCEAN per epoch, per feed. Calcs: 37500 OCEAN/week/20_feeds (Predictoor DF rewards) = 18.6012 OCEAN/epoch/20_feeds (bc 2016 5m epochs/week) = 0.93006 OCEAN/epoch/feed

bot_only:
s_until_epoch_end: 60 # in s. Start predicting if there's > this time left

s_cutoff: 20 # in s. Stop predicting if there's < this time left

aimodel_ss:
input_feeds:
- binance BTC/USDT ETH/USDT c 5m
max_n_train: 5000 # no. epochs to train model on
autoregressive_n : 1 # no. epochs that model looks back, to predict next
autoregressive_n: 1 # no. epochs that model looks back, to predict next
approach: LinearLogistic

trader_ss:
Expand All @@ -49,7 +50,7 @@ trader_ss:
sim_ss: # sim only
do_plot: True
log_dir: logs
test_n : 2000 # number of epochs to simulate
test_n: 2000 # number of epochs to simulate
exchange_only:
timeout: 30000
options:
Expand All @@ -76,16 +77,16 @@ publisher_ss:
trueval_ss:
feeds:
- binance BTC/USDT 5m
# - binance BTC/USDT ETH/USDT BNB/USDT XRP/USDT ADA/USDT DOGE/USDT SOL/USDT LTC/USDT TRX/USDT DOT/USDT 5m
# - kraken BTC/USDT 5m
# - binance BTC/USDT ETH/USDT BNB/USDT XRP/USDT ADA/USDT DOGE/USDT SOL/USDT LTC/USDT TRX/USDT DOT/USDT 5m
# - kraken BTC/USDT 5m
batch_size: 30
sleep_time: 30

dfbuyer_ss:
feeds:
- binance BTC/USDT 5m
# - binance BTC/USDT ETH/USDT BNB/USDT XRP/USDT ADA/USDT DOGE/USDT SOL/USDT LTC/USDT TRX/USDT DOT/USDT 5m
# - kraken BTC/USDT 5m
# - binance BTC/USDT ETH/USDT BNB/USDT XRP/USDT ADA/USDT DOGE/USDT SOL/USDT LTC/USDT TRX/USDT DOT/USDT 5m
# - kraken BTC/USDT 5m
batch_size: 20
consume_interval_seconds: 86400
weekly_spending_limit: 37000
Expand All @@ -95,17 +96,15 @@ payout_ss:

topup_ss:
addresses:
- opf_addresses
- opf_addresses
# - 0xabcd...
# min_bal: 20
# topup_bal: 30

# ------------------------------------------------------------------
# Network settings


web3_pp:

sapphire-testnet:
address_file: "~/.ocean/ocean-contracts/artifacts/address.json"
rpc_url: https://testnet.sapphire.oasis.dev
Expand Down Expand Up @@ -147,20 +146,20 @@ web3_pp:

deployment_configs:
testnet_predictoor_deployment:
cpu: '1'
memory: '512Mi'
cpu: "1"
memory: "512Mi"
source: "binance"
type: "predictoor"
approach: 3
network: "sapphire-testnet"
s_until_epoch_end: 20
pdr_backend_image_source: "oceanprotocol/pdr-backend:latest"
agents:
- pair: 'BTC/USDT'
- pair: "BTC/USDT"
stake_amt: 0.1
timeframe: 5m
approach: 1
- pair: 'ETH/USDT'
- pair: "ETH/USDT"
stake_amt: 1
timeframe: 1h
s_until_epoch_end: 100
Loading