42 lines
1.6 KiB
Python
42 lines
1.6 KiB
Python
import os
|
|
import time
|
|
import sys
|
|
|
|
# 수동으로 .env 파일 파싱
|
|
env_path = "/home/hoon/kis_bot/.env"
|
|
if os.path.exists(env_path):
|
|
with open(env_path, "r") as f:
|
|
for line in f:
|
|
line = line.strip()
|
|
if line and not line.startswith('#') and '=' in line:
|
|
k, v = line.split('=', 1)
|
|
os.environ[k.strip()] = v.strip().strip("'\"")
|
|
|
|
user = os.environ.get("DB_USER", "root")
|
|
password = os.environ.get("DB_PASSWORD", "password")
|
|
host = os.environ.get("DB_HOST", "localhost")
|
|
port = os.environ.get("DB_PORT", "3306")
|
|
dbname = os.environ.get("DB_NAME", "TradeDB")
|
|
|
|
# sqlx 에서는 URL-encoded 패스워드가 필요할 수 있으나, 특수문자가 심하지 않으면 바로 사용
|
|
dsn = f"mysql://{user}:{password}@{host}:{port}/{dbname}"
|
|
print(f"DSN Ready: mysql://{user}:***@{host}:{port}/{dbname}")
|
|
|
|
import kis_rust_core
|
|
|
|
start = time.time()
|
|
try:
|
|
print("Requesting 10,000 candles from MariaDB directly via Rust...")
|
|
# 삼성전자(005930) 테스트
|
|
candles = kis_rust_core.load_candles_from_db(dsn, "005930", 10000)
|
|
elapsed = time.time() - start
|
|
print(f"=====================================")
|
|
print(f"🦀 RUST DB LOADER RESULT:")
|
|
print(f"Loaded {len(candles)} candles directly in {elapsed:.4f}s")
|
|
if candles:
|
|
print(f"First candle (Oldest): {candles[0].time_str} | Open: {candles[0].open}")
|
|
print(f"Last candle (Newest): {candles[-1].time_str} | Open: {candles[-1].open}")
|
|
print(f"=====================================")
|
|
except Exception as e:
|
|
print(f"Error: {e}")
|