Skip to content

Commit

Permalink
added a bit to test the timing parameter of invest_all
Browse files Browse the repository at this point in the history
  • Loading branch information
jepidoptera committed Jun 19, 2023
1 parent 0cfe888 commit 10611d8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion hydradx/tests/test_omnipool_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from hydradx.model.amm.global_state import GlobalState
from hydradx.model.amm.trade_strategies import omnipool_arbitrage, back_and_forth, invest_all
from hydradx.tests.strategies_omnipool import omnipool_reasonable_config, reasonable_market
from hydradx.model.run import run

asset_price_strategy = st.floats(min_value=0.0001, max_value=100000)
asset_price_bounded_strategy = st.floats(min_value=0.1, max_value=10)
Expand Down Expand Up @@ -137,7 +138,7 @@ def test_omnipool_arbitrager(omnipool: oamm.OmnipoolState, market: list, arb_pre
@given(omnipool_reasonable_config(token_count=3))
def test_omnipool_LP(omnipool: oamm.OmnipoolState):
holdings = {asset: 10000 for asset in omnipool.asset_list}
initial_agent = Agent(holdings=holdings, trade_strategy=omnipool_arbitrage)
initial_agent = Agent(holdings=holdings, trade_strategy=invest_all('omnipool', when=3))
initial_state = GlobalState(pools={'omnipool': omnipool}, agents={'agent': initial_agent})

new_state = invest_all('omnipool').execute(initial_state, 'agent')
Expand All @@ -162,3 +163,8 @@ def test_omnipool_LP(omnipool: oamm.OmnipoolState):
if ('omnipool', tkn) in hdx_state.agents['agent'].holdings \
and hdx_state.agents['agent'].holdings[('omnipool', tkn)] != 0:
raise AssertionError(f'Agent has shares of {tkn}, but should not.')

events = run(initial_state, time_steps=4)
final_state = events[-1]
if final_state.agents['agent'].holdings['HDX'] != 0:
raise AssertionError('HDX not invested at the right time.')

0 comments on commit 10611d8

Please sign in to comment.