Skip to content

Commit

Permalink
Using bots python script to generate default config (#638)
Browse files Browse the repository at this point in the history
* Using bots python script to generate default config
* Moving bots_default_config, and updating readme
  • Loading branch information
Sheng Lundquist authored Jul 6, 2023
1 parent 516e140 commit 1616454
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

# for create configuration jsons to run bot scripts
.configs
bots_config.default.json

# default logging directory
.logging
Expand Down
25 changes: 7 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,14 @@ To understand more, we recommend that you study the fixed point tests and source
## Modifying configuration for bot deployment
Bots can be deployed using the `evm_bots.py` script in the examples folder.
If you wish to run it with non-default parameters, then you must specify them as a JSON file.
We recommend using Python to modify the config, and then write it to JSON to ensure type safety.
To do this, first make the file. For example, by entering `touch config_json_generator.py` into a terminal window.
Then, copy the following contents into the file:
To generate a default configuration file, from the base directory, run:

```python
"""Example script for writing a custom bot config to json"""
from elfpy.bots import BotConfig

if __name__ == "__main__":
# load the config file
config = BotConfig()
```bash
python elfpy/bots/bots_default_config.py
```

# modify params as needed
config.random_seed = 1234
config.log_filename = "my_experiment.log"
# ... etc
This will generate `bots_config.default.json`, which you can feed into `evm_bots.py`:

# Write config to json
config.save_as_json("my_config.json")
```bash
evm_bots.py bots_config.default.json
```

Finally, you can execute the file and pass the location of `my_config.json` as an argument. e.g.: `evm_bots.py my_config.json`.
9 changes: 9 additions & 0 deletions elfpy/bots/bots_default_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""Example script for writing a custom bot config to json"""
from elfpy.bots import BotConfig

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

# Write config to json
config.save_as_json("bots_config.default.json")

0 comments on commit 1616454

Please sign in to comment.