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

Add monte-carlo scenario generator to simulator. #154

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

mikewcasale
Copy link
Contributor

Replaces previous simulator scenario generation logic with a new class MonteCarloGenerator. Example usage of this class is provided in updated notebook examples/simulation-example.ipynb

- Creates a new `MonteCarloGenerator` class in `monte_carlo_generator.py` to replace the prior code in the `scenario_generator/` directory.
@netlify
Copy link

netlify bot commented Aug 31, 2022

Deploy Preview for incandescent-kelpie-250f0e canceled.

Name Link
🔨 Latest commit 9fc596d
🔍 Latest deploy log https://app.netlify.com/sites/incandescent-kelpie-250f0e/deploys/631074f323fe680008ea9027

@@ -0,0 +1,616 @@
from decimal import Decimal
Copy link
Collaborator

@barakman barakman Aug 31, 2022

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 *
Copy link
Collaborator

@barakman barakman Aug 31, 2022

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.

Copy link
Collaborator

@barakman barakman Aug 31, 2022

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,
Copy link
Collaborator

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?

mikewcasale and others added 14 commits August 31, 2022 14:48
- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants