
* Created FastAPI application structure * Added database models for assets, exchanges, markets, and rates * Integrated with CoinCap API * Implemented REST API endpoints * Setup SQLite persistence with Alembic migrations * Added comprehensive documentation Generated with BackendIM... (backend.im)
20 lines
610 B
Python
20 lines
610 B
Python
from sqlalchemy import Column, String, Float, DateTime
|
|
from datetime import datetime
|
|
|
|
from app.core.database import Base
|
|
|
|
|
|
class Rate(Base):
|
|
__tablename__ = "rates"
|
|
|
|
id = Column(String, primary_key=True, index=True) # e.g., "bitcoin" or "usd"
|
|
symbol = Column(String, index=True)
|
|
currency_symbol = Column(String, nullable=True)
|
|
type = Column(String) # "crypto" or "fiat"
|
|
rate_usd = Column(Float)
|
|
|
|
# Last updated in our database
|
|
last_updated = Column(DateTime, default=datetime.utcnow)
|
|
|
|
def __repr__(self):
|
|
return f"<Rate {self.symbol}: {self.rate_usd} USD>" |