Add monte-carlo scenario generator to simulator.#154
Add monte-carlo scenario generator to simulator.#154mikewcasale wants to merge 18 commits intomainfrom
Conversation
- Creates a new `MonteCarloGenerator` class in `monte_carlo_generator.py` to replace the prior code in the `scenario_generator/` directory.
✅ Deploy Preview for incandescent-kelpie-250f0e canceled.
|
| @@ -0,0 +1,616 @@ | |||
| from decimal import Decimal | |||
There was a problem hiding this comment.
You can import it directly from bancor_research (as done elsewhere in the code).
It is where the Decimal class is properly configured.
| import pandas as pd | ||
| from bancor_simulator.v3.spec import get_vault_balance | ||
|
|
||
| from bancor_research.bancor_simulator.v3.spec import * |
There was a problem hiding this comment.
Ideally, we can/should import only BancorDapp here, which would allow us to:
from bancor_research.bancor_simulator.v3.spec import BancorDapp as sBancorDapp
from bancor_research.bancor_emulator.v3.spec import BancorDapp as eBancorDapp
...
dapps = [
BancorDapp(
cooldown_time=cooldown_time,
whitelisted_tokens=whitelisted_tokens,
bnt_min_liquidity=bnt_min_liquidity,
price_feeds=price_feed,
)
for BancorDapp in [sBancorDapp, eBancorDapp]
Then later run everything for each element in dapps.
Or something similar to that, anyway...
But generally speaking, relying only on the BancorDapp class as interface to the layer below (i.e., as "entry point" to the entire 'spec' module), would allow us to easily swap between the simulator and the emulator.
There was a problem hiding this comment.
Same for file simulation-example.ipynb, which I cannot view here, but from my experience with the other notebooks, the scheme suggested above is probably relevant also for that one.
| pool_freq_dist: dict, | ||
| action_freq_dist: dict, | ||
| slippage_profile: dict, | ||
| deposit_mean: float, |
There was a problem hiding this comment.
Perhaps we should use Decimal instead of float everywhere?
- fixed and issue which caused negative trade fees to get logged prior to an action failing
- during monte-carlo simulations we need to not have an uncaught exception here
- fixed an import error
- removed unused args in the `MonteCarloGenerator` class - fixed a naming typo
- Added assertion to enforce non-negative balances
Replaces previous simulator scenario generation logic with a new class
MonteCarloGenerator. Example usage of this class is provided in updated notebookexamples/simulation-example.ipynb