()
| 43 | from src.environment.database.types import QueryRequest, SelectRequest |
| 44 | |
| 45 | async def test_online_hyperliquid(): |
| 46 | |
| 47 | def parse_args(): |
| 48 | parser = argparse.ArgumentParser(description='Online Trading Agent Example') |
| 49 | parser.add_argument("--config", default=os.path.join(root, "configs", "online_trading_agent.py"), help="config file path") |
| 50 | |
| 51 | parser.add_argument( |
| 52 | '--cfg-options', |
| 53 | nargs='+', |
| 54 | action=DictAction, |
| 55 | help='override some settings in the used config, the key-value pair ' |
| 56 | 'in xxx=yyy format will be merged into config file. If the value to ' |
| 57 | 'be overwritten is a list, it should be like key="[a,b]" or key=a,b ' |
| 58 | 'It also allows nested list/tuple values, e.g. key="[(a,b),(c,d)]" ' |
| 59 | 'Note that the quotation marks are necessary and that no white space ' |
| 60 | 'is allowed.') |
| 61 | args = parser.parse_args() |
| 62 | return args |
| 63 | |
| 64 | args = parse_args() |
| 65 | |
| 66 | # Initialize configuration |
| 67 | config.init_config(args.config, args) |
| 68 | logger.init_logger(config) |
| 69 | logger.info(f"| Config: {config.pretty_text}") |
| 70 | |
| 71 | # Initialize Hyperliquid service |
| 72 | logger.info("| 🔧 Initializing Hyperliquid service...") |
| 73 | accounts = get_env("HYPERLIQUID_ACCOUNTS").get_secret_value() |
| 74 | if accounts: |
| 75 | accounts = json.loads(accounts) |
| 76 | config.hyperliquid_service.update(dict(accounts=accounts)) |
| 77 | hyperliquid_service = OnlineHyperliquidService(**config.hyperliquid_service) |
| 78 | await hyperliquid_service.initialize() |
| 79 | for env_name in config.env_names: |
| 80 | env_config = config.get(f"{env_name}_environment", None) |
| 81 | env_config.update(dict(hyperliquid_service=hyperliquid_service)) |
| 82 | logger.info(f"| ✅ Hyperliquid service initialized.") |
| 83 | |
| 84 | # Initialize environments |
| 85 | logger.info("| 🎮 Initializing environments...") |
| 86 | await ecp.initialize(config.env_names) |
| 87 | logger.info(f"| ✅ Environments initialized: {ecp.list()}") |
| 88 | |
| 89 | |
| 90 | def _safe_float_format(value: Any, default: float = 0.0) -> str: |
nothing calls this directly
no test coverage detected