Data Models API Reference¶
financelib.database.models.NewsModel(title: str = '', content: str = '', published_at: str = '', author: str = '', category: str = 'news', source: str = '', article_url: str = '', article_thumbnail_url: str = '')
dataclass
¶
Data model for news articles stored in the database.
Attributes:
| Name | Type | Description |
|---|---|---|
title |
str
|
Article title. |
content |
str
|
Article body text. |
published_at |
str
|
Publication date/time string. |
author |
str
|
Author name(s). |
category |
str
|
Article category. |
source |
str
|
Source name. |
article_url |
str
|
URL to the full article. |
article_thumbnail_url |
str
|
URL to the article thumbnail. |
financelib.database.models.StockDataModel(symbol: str = '', price: float = 0.0, open_price: float = 0.0, high: float = 0.0, low: float = 0.0, volume: int = 0, change: float = 0.0, change_percent: float = 0.0, currency: str = 'TRY', timestamp: str = '')
dataclass
¶
Data model for stock data stored in the database.
Attributes:
| Name | Type | Description |
|---|---|---|
symbol |
str
|
Stock ticker symbol. |
price |
float
|
Current/closing price (must be >= 0). |
open_price |
float
|
Opening price (must be >= 0). |
high |
float
|
High price (must be >= 0). |
low |
float
|
Low price (must be >= 0). |
volume |
int
|
Trading volume (must be >= 0). |
change |
float
|
Price change. |
change_percent |
float
|
Price change percentage. |
currency |
str
|
Currency code (3 letters). |
timestamp |
str
|
Data timestamp string. |
financelib.database.models.TradeRecord(symbol: str = '', side: str = '', price: float = 0.0, amount: float = 0.0, market: str = 'spot', leverage: int = 1, pnl: float = 0.0, paper: bool = True, timestamp: str = '')
dataclass
¶
Data model for trade records.
Attributes:
| Name | Type | Description |
|---|---|---|
symbol |
str
|
Trading pair symbol. |
side |
str
|
Trade side ('buy' or 'sell'). |
price |
float
|
Execution price. |
amount |
float
|
Trade amount. |
market |
str
|
Market type ('spot', 'futures', 'option'). |
leverage |
int
|
Leverage used. |
pnl |
float
|
Profit/loss. |
paper |
bool
|
Whether this was a paper trade. |
timestamp |
str
|
Execution timestamp. |
financelib.database.models.ModelValidationError
¶
Bases: FinanceLibError
Raised when model data fails validation.