feat(V2): migrazione alpaca completa
Task 6.7: porting alpaca da services/mcp-alpaca a src/cerbero_mcp. client.py + leverage_cap.py copiati 1:1 (default cap 1 cash). tools.py: 17 tool senza ACL/Principal/audit. Router /mcp-alpaca con 18 route (env_info + 17 tool). Builder branch alpaca: paper=(env=="testnet"), api_key viene da settings.alpaca.api_key_id. Test client + leverage_cap migrati (15 test alpaca pass). Test builder con stub SDK alpaca-py. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -71,6 +71,37 @@ async def test_build_client_hyperliquid_returns_correct_env(monkeypatch):
|
||||
assert "test" not in c_live.base_url.lower()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_build_client_alpaca_returns_correct_env(monkeypatch):
|
||||
from tests.unit.test_settings import _minimal_env
|
||||
|
||||
for k, v in _minimal_env().items():
|
||||
monkeypatch.setenv(k, v)
|
||||
|
||||
# Stub alpaca SDK clients per evitare connessioni reali in __init__
|
||||
from cerbero_mcp.exchanges.alpaca import client as alpaca_client
|
||||
|
||||
class _FakeSdk:
|
||||
def __init__(self, **kwargs):
|
||||
self.kwargs = kwargs
|
||||
|
||||
monkeypatch.setattr(alpaca_client, "TradingClient", _FakeSdk)
|
||||
monkeypatch.setattr(alpaca_client, "StockHistoricalDataClient", _FakeSdk)
|
||||
monkeypatch.setattr(alpaca_client, "CryptoHistoricalDataClient", _FakeSdk)
|
||||
monkeypatch.setattr(alpaca_client, "OptionHistoricalDataClient", _FakeSdk)
|
||||
|
||||
from cerbero_mcp.settings import Settings
|
||||
from cerbero_mcp.exchanges import build_client
|
||||
|
||||
s = Settings()
|
||||
c_test = await build_client(s, "alpaca", "testnet")
|
||||
c_live = await build_client(s, "alpaca", "mainnet")
|
||||
|
||||
assert c_test is not c_live
|
||||
assert c_test.paper is True
|
||||
assert c_live.paper is False
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_build_client_unknown_exchange_raises(monkeypatch):
|
||||
from tests.unit.test_settings import _minimal_env
|
||||
|
||||
Reference in New Issue
Block a user