Skip to content
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
1 change: 0 additions & 1 deletion elfpy/bots/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Utilities and classes for Agent.0 bots"""

from .bot_config import BotConfig
from .bot_info import BotInfo
from .budget import Budget
from .environment_config import DEFAULT_USERNAME, EnvironmentConfig
81 changes: 0 additions & 81 deletions elfpy/bots/bot_config.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Example script for writing a custom bot config to json"""
from elfpy.bots import DEFAULT_USERNAME, BotConfig
from elfpy.bots import DEFAULT_USERNAME, EnvironmentConfig
Comment thread
wakamex marked this conversation as resolved.

if __name__ == "__main__":
# load the config file, which loads defaults
config = BotConfig()
config = EnvironmentConfig()

# Add username here if adjusting configurations in this script
config.username = DEFAULT_USERNAME
Expand Down
6 changes: 6 additions & 0 deletions elfpy/bots/environment_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ class EnvironmentConfig(types.FrozenClass):
max_bytes: int = DEFAULT_LOG_MAXBYTES # int(2e6) or 2MB
# location of RPC
rpc_url: str = "http://localhost:8545"
# chance for a bot to execute a trade (used if unspecified at the bot level).
default_trade_chance: float = 0.1
# risk_threshold has different interpretations for different bots (used if unspecified at the bot level).
# In general the bot will be more risk averse as it grows to infinity.
# A value of 0 will usually disable it.
default_risk_threshold: float = 0.0
# int to be used for the random seed
random_seed: int = 1
# abi filenames
Expand Down
14 changes: 10 additions & 4 deletions examples/evm_bots.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def create_agent(
# pylint: disable=too-many-arguments
assert bot.index is not None, "Bot must have an index."
assert isinstance(bot.policy, type(Agent)), "Bot must have a policy of type Agent."
params = {"trade_chance": FixedPoint(bot_config.trade_chance), "budget": bot.budget.sample_budget(rng)}
params = {"trade_chance": FixedPoint(bot.trade_chance), "budget": bot.budget.sample_budget(rng)}
params["rng"] = rng
if bot.risk_threshold and bot.name != "random": # random agent doesn't use risk threshold
params["risk_threshold"] = FixedPoint(bot.risk_threshold) # if risk threshold is manually set, we use it
Expand Down Expand Up @@ -588,13 +588,19 @@ def main(
if "num_random" not in bot_config.scratch:
bot_config.scratch["num_random"]: int = 1
bot_config.scratch["louie"] = BotInfo(
policy=LongLouie, trade_chance=bot_config.trade_chance, risk_threshold=bot_config.risk_threshold
policy=LongLouie,
trade_chance=bot_config.default_trade_chance,
risk_threshold=bot_config.default_risk_threshold,
)
bot_config.scratch["sally"] = BotInfo(
policy=ShortSally, trade_chance=bot_config.trade_chance, risk_threshold=bot_config.risk_threshold
policy=ShortSally,
trade_chance=bot_config.default_trade_chance,
risk_threshold=bot_config.default_risk_threshold,
)
bot_config.scratch["random"] = BotInfo(
policy=RandomAgent, trade_chance=bot_config.trade_chance, risk_threshold=bot_config.risk_threshold
policy=RandomAgent,
trade_chance=bot_config.default_trade_chance,
risk_threshold=bot_config.default_risk_threshold,
)
bot_config.scratch["bot_names"] = {"louie", "sally", "random"}
# hard-code goerli addresses
Expand Down