Spaces:
Sleeping
Sleeping
Download core.py from janggi3/agent_system: direct link, hf CLI and curl.
- Browser
- Download file 699 Bytes
-
https://huggingface.co/spaces/janggi3/agent_system/resolve/main/core.py
- Command line
-
hf download hf://spaces/janggi3/agent_system/core.py
-
curl -L -o core.py https://huggingface.co/spaces/janggi3/agent_system/resolve/main/core.py
699 Bytes
| # file: agent_system/core.py | |
| from dataclasses import dataclass | |
| from typing import Dict, Set | |
| import numpy as np | |
| class AssetAllocation: | |
| weights: Dict[str, float] | |
| class Force: | |
| id: str | |
| name: str | |
| tags: Set[str] | |
| allocation: AssetAllocation | |
| returns_history: np.ndarray | |
| class Portfolio: | |
| def __init__(self, cash: float): | |
| self.cash = cash # This is the USDT balance | |
| self.positions = {} # {Symbol: Quantity} | |
| self.total_value = cash | |
| def update(self, prices: Dict[str, float]): | |
| pos_val = sum(qty * prices.get(sym, 0) for sym, qty in self.positions.items()) | |
| self.total_value = self.cash + pos_val | |