Spaces:
Sleeping
Sleeping
File size: 2,549 Bytes
d96a847 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | # file: agent_system/factory.py
"""import numpy as np
from core import Force, AssetAllocation
def generate_synthetic_forces(num=10, days=365):
forces = []
t = np.linspace(0, 20, days) # Timeline for signal generation
for i in range(num):
# Determine the "Personality" of the Force
# Even indices are Momentum, Odd are Mean Reversion
if i % 2 == 0:
name = f"Trend_Follower_{i}"
tags = {"momentum", "aggressive", "long"}
# Signal: Follows a smoothed version of a sine wave (Trend)
ret_signal = np.sin(t * 0.5) + np.random.normal(0, 0.2, days)
# Allocation: Pure BTC Long
alloc = AssetAllocation({"BTC": 1.0, "ETH": 0.0, "USDT": 0.0})
else:
name = f"Contrarian_Hedge_{i}"
tags = {"mean_reversion", "defensive", "short"}
# Signal: Random noise that reverts to zero
ret_signal = np.random.normal(0, 0.5, days)
# Allocation: ETH Short vs USDT
alloc = AssetAllocation({"BTC": 0.0, "ETH": -0.5, "USDT": 1.5})
forces.append(Force(
id=f"f_{i}",
name=name,
tags=tags,
allocation=alloc,
returns_history=ret_signal
))
return forces"""
# file: agent_system/factory.py
import numpy as np
from core import Force, AssetAllocation
def generate_synthetic_forces(n=10):
"""
Generates a set of diverse strategies (Forces).
Including the new 'Short Seller' force for bear market survival.
"""
forces = []
# 1. THE SHORT SELLER (New: Profits from 2022-style crashes)
forces.append(Force(
id="f_short_btc",
name="Inverse BTC",
tags={"defensive", "short", "bear_trend"},
allocation=AssetAllocation({"BTC": -1.0}), # -100% exposure
returns_history=np.zeros(10)
))
# 2. THE MOMENTUM LONG (Profits from 2021/2024 bulls)
forces.append(Force(
id="f_long_btc",
name="Aggressive Long BTC",
tags={"momentum", "aggressive", "bull_trend"},
allocation=AssetAllocation({"BTC": 1.0}),
returns_history=np.zeros(10)
))
# 3. THE CASH RESERVE (Neutral)
forces.append(Force(
id="f_cash",
name="USDT Reserve",
tags={"safe", "stable"},
allocation=AssetAllocation({}), # 0% exposure to volatile assets
returns_history=np.zeros(10)
))
# ... Add more synthetic or specialized forces as needed ...
return forces
|