-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add monte-carlo scenario generator to simulator. #154
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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