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

Interactive Agent0 #1101

Merged
merged 62 commits into from
Nov 21, 2023
Merged

Interactive Agent0 #1101

merged 62 commits into from
Nov 21, 2023

Conversation

slundqui
Copy link
Contributor

@slundqui slundqui commented Nov 17, 2023

This PR introduces interactive hyperdrive that is tailored to an end user running experiments in hyperdrive. To this end, we focus on syntax and usability for interacting with hyperdrive. Below is a code snippet that showcases how to use the interactive hyperdrive.

# Assumes anvil and docker is installed in your environment
from fixedpointmath import FixedPoint
from agent0.hyperdrive.interactive import InteractiveHyperdrive, LocalChain
from datetime import timedelta

# Launches a local anvil chain in a subprocess
chain = LocalChain()

# Initializes hyperdrive on the chain
interactive_hyperdrive = InteractiveHyperdrive(chain)

# Initializes a funded agent
hyperdrive_agent = interactive_hyperdrive.init_agent(base=FixedPoint(100000), eth=FixedPoint(100), name="alice")

# Make trades, returning the emitted event
open_long_event = hyperdrive_agent.open_long(base=FixedPoint(11111))

# Advance time
chain.advance_time(timedelta(weeks=52))

# Close the long
close_long_event = hyperdrive_agent.close_long(open_long_event.maturity_time, bonds=open_long_event.bond_amount)

# View all past trades from the database
print(interactive_hyperdrive.get_ticker())

Major changes:

  • Implemented interactive hyperdrive and associated classes and tests in agent0/hyperdrive/interactive/

Minor changes:

  • Exposing set_max_approval for usage within interactive hyperdrive
  • Moving known error checking functions to be within crash reporting directory
  • Moving known error checks one level in to async_execute_agent_trades
  • Expanding receipt breakdown to include all possible fields events emit
  • async_match_contract_call_to_trade now also returns the receipt breakdown (i.e., the events)
  • Adding maturity_time to the Long and Short dataclasses
  • Flag to make the database within postgres if it doesn't exist
  • Removing extra sleeps in data pipeline

Bug fixes:

  • set_max_approval now properly throws an error if it errors out
  • Surrounding script files in lib/agent0/examples with if __name__ == "__main__"

Copy link

vercel bot commented Nov 17, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
elf-simulations ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 21, 2023 5:38pm

lib/agent0/agent0/utils.py Outdated Show resolved Hide resolved
Copy link
Member

@dpaiton dpaiton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! I left a bunch of comments; I'm happy if you want to convert them into issues instead of resolving.

@slundqui slundqui merged commit 83f40eb into delvtech:main Nov 21, 2023
5 checks passed
@slundqui slundqui deleted the interactive_agent0 branch November 21, 2023 18:07
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