Initial v1 autonomous alpaca llm trading bot with dark dashboard
This commit is contained in:
35
db.py
Normal file
35
db.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from sqlalchemy import create_engine, Column, Integer, String, Float, DateTime, Text
|
||||
from sqlalchemy.orm import declarative_base, sessionmaker
|
||||
from datetime import datetime
|
||||
from config import settings
|
||||
|
||||
Base = declarative_base()
|
||||
engine = create_engine(settings.db_path, echo=False)
|
||||
SessionLocal = sessionmaker(bind=engine)
|
||||
|
||||
class BotDecision(Base):
|
||||
__tablename__ = "decisions"
|
||||
id = Column(Integer, primary_key=True)
|
||||
ts = Column(DateTime, default=datetime.utcnow)
|
||||
symbol = Column(String(16), index=True)
|
||||
action = Column(String(16)) # buy/sell/hold
|
||||
confidence = Column(Float)
|
||||
reason = Column(Text)
|
||||
market_context = Column(Text)
|
||||
order_usd = Column(Float)
|
||||
status = Column(String(32), default="planned")
|
||||
|
||||
class TradeExecution(Base):
|
||||
__tablename__ = "trades"
|
||||
id = Column(Integer, primary_key=True)
|
||||
ts = Column(DateTime, default=datetime.utcnow)
|
||||
symbol = Column(String(16), index=True)
|
||||
side = Column(String(8))
|
||||
qty = Column(Float)
|
||||
notional = Column(Float)
|
||||
alpaca_order_id = Column(String(128))
|
||||
raw = Column(Text)
|
||||
|
||||
|
||||
def init_db():
|
||||
Base.metadata.create_all(bind=engine)
|
||||
Reference in New Issue
Block a user