|
|
|
@ -171,40 +171,35 @@ BASE = "http://localhost:18001/api/v1"
|
|
|
|
status = requests.get(f"{BASE}/alpaca/status").json()
|
|
|
|
status = requests.get(f"{BASE}/alpaca/status").json()
|
|
|
|
print(f"Alpaca configured: {status['configured']}")
|
|
|
|
print(f"Alpaca configured: {status['configured']}")
|
|
|
|
|
|
|
|
|
|
|
|
# Get daily bars with DB storage
|
|
|
|
# ── 과거 분봉 (SIP 피드, DB 저장, 어제까지) ──────────────────────────
|
|
|
|
resp = requests.get(f"{BASE}/alpaca/data/AAPL", params={
|
|
|
|
# 백테스트, 과거 OHLCV 분석용. 거래량 100% 정확.
|
|
|
|
"interval": "1d",
|
|
|
|
hist = requests.get(f"{BASE}/alpaca/intraday", params={
|
|
|
|
"start_date": "2025-01-01",
|
|
|
|
"tickers": "AAPL,MSFT,NVDA",
|
|
|
|
|
|
|
|
"interval": "5m",
|
|
|
|
|
|
|
|
"start_date": "2025-01-02",
|
|
|
|
"end_date": "2025-01-31",
|
|
|
|
"end_date": "2025-01-31",
|
|
|
|
}).json()
|
|
|
|
}).json()
|
|
|
|
print(f"Alpaca bars: {resp['metadata']['data_points']} data points")
|
|
|
|
print(f"Historical bars: {hist['count']} tickers")
|
|
|
|
|
|
|
|
for ticker, bars in hist["bars"].items():
|
|
|
|
# Get raw bars (no DB)
|
|
|
|
print(f" {ticker}: {len(bars)} bars")
|
|
|
|
bars = requests.get(f"{BASE}/alpaca/bars/TSLA", params={
|
|
|
|
|
|
|
|
"interval": "1d",
|
|
|
|
# ── 당일 실시간 분봉 (IEX 피드, 오늘만) ─────────────────────────────
|
|
|
|
"start_date": "2025-03-01",
|
|
|
|
# 당일 ORB 전략, 실시간 장 중 모니터링.
|
|
|
|
"end_date": "2025-03-10",
|
|
|
|
# 거래량은 실제의 2~5% (IEX 거래소 거래만 집계).
|
|
|
|
}).json()
|
|
|
|
today = requests.get(f"{BASE}/alpaca/intraday/today", params={
|
|
|
|
for bar in bars["bars"][:3]:
|
|
|
|
"tickers": "AAPL,MSFT,NVDA",
|
|
|
|
print(f" {bar['timestamp']}: close={bar['close']}, vwap={bar['vwap']}")
|
|
|
|
"interval": "5m",
|
|
|
|
|
|
|
|
|
|
|
|
# Intraday candles
|
|
|
|
|
|
|
|
candles = requests.get(f"{BASE}/alpaca/intraday/NVDA", params={
|
|
|
|
|
|
|
|
"interval": "1h",
|
|
|
|
|
|
|
|
"start_date": "2025-03-10",
|
|
|
|
|
|
|
|
"end_date": "2025-03-10",
|
|
|
|
|
|
|
|
}).json()
|
|
|
|
}).json()
|
|
|
|
print(f"Intraday candles: {candles['count']}")
|
|
|
|
for ticker, bars in today["bars"].items():
|
|
|
|
|
|
|
|
if bars:
|
|
|
|
# Real-time snapshot — single ticker (no cache, direct Alpaca call)
|
|
|
|
latest = bars[-1]
|
|
|
|
snap = requests.get(f"{BASE}/alpaca/snapshot/SPY").json()
|
|
|
|
print(f" {ticker}: last bar {latest['timestamp']} close={latest['close']}")
|
|
|
|
print(f"SPY price: {snap['price']}, change: {snap['change_pct']}%")
|
|
|
|
|
|
|
|
print(f" bid={snap['bid']} ask={snap['ask']}")
|
|
|
|
# ── 실시간 스냅샷 (IEX 피드, 캐시 없음) ─────────────────────────────
|
|
|
|
|
|
|
|
# 단일 종목도 tickers= 쿼리 파라미터로 조회 가능.
|
|
|
|
# Real-time snapshots — multiple tickers
|
|
|
|
snap = requests.get(f"{BASE}/alpaca/snapshot", params={"tickers": "SPY,QQQ,AAPL"}).json()
|
|
|
|
multi = requests.get(f"{BASE}/alpaca/snapshot", params={"tickers": "SPY,QQQ,AAPL"}).json()
|
|
|
|
for s in snap["snapshots"]:
|
|
|
|
for s in multi["snapshots"]:
|
|
|
|
print(f" {s['ticker']}: {s['price']} ({s['change_pct']:+.2f}%) bid={s['bid']} ask={s['ask']}")
|
|
|
|
print(f" {s['ticker']}: {s['price']} ({s['change_pct']:+.2f}%)")
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### 7. FINRA Short Volume
|
|
|
|
### 7. FINRA Short Volume
|
|
|
|
|