챠트 데이터 웹소켓으로 연결

This commit is contained in:
2026-02-26 13:51:12 +09:00
parent 82346fcc46
commit 77e7464884
4 changed files with 82 additions and 5 deletions

View File

@@ -0,0 +1,52 @@
#!/usr/bin/env python3
"""
Verify that StockAnalysis and MarketData volume columns can handle values larger
than 2**31-1. This script will fail prior to applying the bigint migration.
"""
import asyncio
from datetime import date
from app.core.database import AsyncSessionLocal
from app.models.models import StockAnalysis, MarketData
async def test_big_volume():
async with AsyncSessionLocal() as session:
# create and commit a record with a large volume value
huge_vol = 2962426126 # value that previously triggered overflow
sa = StockAnalysis(
stock_code="TEST",
stock_name="Test Corp",
analysis_date=date.today(),
current_price=100,
change_rate=0,
volume=huge_vol,
)
session.add(sa)
# also test MarketData
md = MarketData(
stock_code="TEST",
price=100,
change_rate=0,
volume=huge_vol,
)
session.add(md)
await session.commit()
print("Inserted records with large volume successfully")
# fetch back and verify
fetched_sa = await session.get(StockAnalysis, sa.id)
fetched_md = await session.get(MarketData, md.id)
print("StockAnalysis volume type:", type(fetched_sa.volume), fetched_sa.volume)
print("MarketData volume type:", type(fetched_md.volume), fetched_md.volume)
assert fetched_sa.volume == huge_vol
assert fetched_md.volume == huge_vol
if __name__ == "__main__":
asyncio.run(test_big_volume())