stable/freqtrade/rpc/api_server/api_schemas.py

311 lines
6.4 KiB
Python
Raw Normal View History

2020-12-27 08:02:35 +00:00
from datetime import date, datetime
from typing import Any, Dict, List, Optional, Union
2020-12-27 08:02:35 +00:00
from pydantic import BaseModel
2020-12-27 08:02:35 +00:00
from freqtrade.constants import DATETIME_PRINT_FORMAT
class Ping(BaseModel):
status: str
2020-12-25 12:11:01 +00:00
2020-12-25 14:50:19 +00:00
class AccessToken(BaseModel):
access_token: str
class AccessAndRefreshToken(AccessToken):
refresh_token: str
2020-12-25 12:11:01 +00:00
class Version(BaseModel):
version: str
2020-12-25 19:07:12 +00:00
class StatusMsg(BaseModel):
status: str
2020-12-26 16:33:27 +00:00
class ResultMsg(BaseModel):
result: str
class Balance(BaseModel):
currency: str
free: float
balance: float
used: float
est_stake: float
stake: str
class Balances(BaseModel):
currencies: List[Balance]
total: float
symbol: str
value: float
stake: str
note: str
2020-12-26 14:54:22 +00:00
class Count(BaseModel):
current: int
max: int
total_stake: float
2020-12-26 15:43:15 +00:00
class PerformanceEntry(BaseModel):
pair: str
profit: float
count: int
class Profit(BaseModel):
profit_closed_coin: float
profit_closed_percent: float
profit_closed_percent_mean: float
profit_closed_ratio_mean: float
profit_closed_percent_sum: float
profit_closed_ratio_sum: float
profit_closed_fiat: float
profit_all_coin: float
profit_all_percent: float
profit_all_percent_mean: float
profit_all_ratio_mean: float
profit_all_percent_sum: float
profit_all_ratio_sum: float
profit_all_fiat: float
trade_count: int
closed_trade_count: int
first_trade_date: str
first_trade_timestamp: int
latest_trade_date: str
latest_trade_timestamp: int
avg_duration: str
best_pair: str
best_rate: float
winning_trades: int
losing_trades: int
class SellReason(BaseModel):
wins: int
losses: int
draws: int
class Stats(BaseModel):
sell_reasons: Dict[str, SellReason]
durations: Dict[str, Union[str, float]]
2020-12-26 16:33:27 +00:00
class DailyRecord(BaseModel):
date: date
abs_profit: float
fiat_value: float
trade_count: int
class Daily(BaseModel):
data: List[DailyRecord]
fiat_display_currency: str
stake_currency: str
2021-01-02 14:48:33 +00:00
class ShowConfig(BaseModel):
2021-02-20 18:17:10 +00:00
dry_run: bool
2021-01-02 14:48:33 +00:00
stake_currency: str
2021-01-03 05:46:06 +00:00
stake_amount: Union[float, str]
2021-01-02 14:48:33 +00:00
max_open_trades: int
minimal_roi: Dict[str, Any]
stoploss: float
trailing_stop: bool
trailing_stop_positive: Optional[float]
trailing_stop_positive_offset: Optional[float]
trailing_only_offset_is_reached: Optional[bool]
use_custom_stoploss: Optional[bool]
2021-01-02 14:48:33 +00:00
timeframe: str
timeframe_ms: int
timeframe_min: int
exchange: str
strategy: str
forcebuy_enabled: bool
ask_strategy: Dict[str, Any]
bid_strategy: Dict[str, Any]
bot_name: str
2021-01-02 14:48:33 +00:00
state: str
runmode: str
2021-01-01 18:36:03 +00:00
class TradeSchema(BaseModel):
2021-01-01 18:38:28 +00:00
trade_id: int
2021-01-01 18:36:03 +00:00
pair: str
is_open: bool
exchange: str
amount: float
amount_requested: float
stake_amount: float
strategy: str
2021-01-01 18:38:28 +00:00
timeframe: int
2021-01-01 18:36:03 +00:00
fee_open: Optional[float]
fee_open_cost: Optional[float]
fee_open_currency: Optional[str]
fee_close: Optional[float]
fee_close_cost: Optional[float]
fee_close_currency: Optional[str]
open_date_hum: str
open_date: str
open_timestamp: int
open_rate: float
open_rate_requested: Optional[float]
open_trade_value: float
close_date_hum: Optional[str]
close_date: Optional[str]
close_timestamp: Optional[int]
close_rate: Optional[float]
close_rate_requested: Optional[float]
close_profit: Optional[float]
close_profit_pct: Optional[float]
close_profit_abs: Optional[float]
profit_ratio: Optional[float]
profit_pct: Optional[float]
profit_abs: Optional[float]
sell_reason: Optional[str]
sell_order_status: Optional[str]
stop_loss_abs: Optional[float]
stop_loss_ratio: Optional[float]
stop_loss_pct: Optional[float]
stoploss_order_id: Optional[str]
stoploss_last_update: Optional[str]
stoploss_last_update_timestamp: Optional[int]
initial_stop_loss_abs: Optional[float]
initial_stop_loss_ratio: Optional[float]
initial_stop_loss_pct: Optional[float]
min_rate: Optional[float]
max_rate: Optional[float]
open_order_id: Optional[str]
2021-01-01 18:38:28 +00:00
class OpenTradeSchema(TradeSchema):
stoploss_current_dist: Optional[float]
stoploss_current_dist_pct: Optional[float]
stoploss_current_dist_ratio: Optional[float]
stoploss_entry_dist: Optional[float]
stoploss_entry_dist_ratio: Optional[float]
base_currency: str
current_profit: float
current_profit_abs: float
current_profit_pct: float
current_rate: float
open_order: Optional[str]
2021-01-01 18:36:03 +00:00
class TradeResponse(BaseModel):
trades: List[TradeSchema]
trades_count: int
class ForceBuyResponse(BaseModel):
__root__: Union[TradeSchema, StatusMsg]
2021-01-02 14:11:40 +00:00
2020-12-26 16:33:27 +00:00
class LockModel(BaseModel):
active: bool
lock_end_time: str
lock_end_timestamp: int
lock_time: str
lock_timestamp: int
pair: str
reason: str
class Locks(BaseModel):
lock_count: int
locks: List[LockModel]
class Logs(BaseModel):
log_count: int
logs: List[List]
class ForceBuyPayload(BaseModel):
pair: str
price: Optional[float]
class ForceSellPayload(BaseModel):
tradeid: str
2020-12-26 16:33:27 +00:00
class BlacklistPayload(BaseModel):
blacklist: List[str]
class BlacklistResponse(BaseModel):
blacklist: List[str]
blacklist_expanded: List[str]
errors: Dict
length: int
method: List[str]
class WhitelistResponse(BaseModel):
whitelist: List[str]
length: int
method: List[str]
class DeleteTrade(BaseModel):
cancel_order_count: int
result: str
result_msg: str
trade_id: int
2020-12-26 19:05:27 +00:00
2021-01-02 14:11:40 +00:00
class PlotConfig_(BaseModel):
2020-12-31 10:01:50 +00:00
main_plot: Dict[str, Any]
2020-12-26 19:05:27 +00:00
subplots: Optional[Dict[str, Any]]
class PlotConfig(BaseModel):
__root__: Union[PlotConfig_, Dict]
2021-01-02 14:11:40 +00:00
2020-12-26 19:05:27 +00:00
class StrategyListResponse(BaseModel):
strategies: List[str]
class StrategyResponse(BaseModel):
strategy: str
code: str
class AvailablePairs(BaseModel):
length: int
pairs: List[str]
pair_interval: List[List[str]]
2020-12-27 08:02:35 +00:00
class PairHistory(BaseModel):
strategy: str
pair: str
timeframe: str
timeframe_ms: int
columns: List[str]
data: List[Any]
length: int
buy_signals: int
sell_signals: int
last_analyzed: datetime
last_analyzed_ts: int
data_start_ts: int
data_start: str
data_stop: str
data_stop_ts: int
class Config:
json_encoders = {
datetime: lambda v: v.strftime(DATETIME_PRINT_FORMAT),
}