2020-12-27 08:02:35 +00:00
|
|
|
from datetime import date, datetime
|
2021-02-28 09:56:51 +00:00
|
|
|
from typing import Any, Dict, List, Optional, Union
|
2020-12-27 08:02:35 +00:00
|
|
|
|
2020-12-25 12:08:25 +00:00
|
|
|
from pydantic import BaseModel
|
|
|
|
|
2020-12-27 08:02:35 +00:00
|
|
|
from freqtrade.constants import DATETIME_PRINT_FORMAT
|
2022-03-03 06:07:33 +00:00
|
|
|
from freqtrade.enums import OrderTypeValues, SignalDirection, TradingMode
|
2020-12-27 08:02:35 +00:00
|
|
|
|
2020-12-25 12:08:25 +00:00
|
|
|
|
|
|
|
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 12:08:25 +00:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
2020-12-25 12:08:25 +00:00
|
|
|
class Balance(BaseModel):
|
|
|
|
currency: str
|
|
|
|
free: float
|
|
|
|
balance: float
|
|
|
|
used: float
|
|
|
|
est_stake: float
|
|
|
|
stake: str
|
2022-02-19 15:28:51 +00:00
|
|
|
# Starting with 2.x
|
|
|
|
side: str
|
|
|
|
leverage: float
|
|
|
|
is_position: bool
|
|
|
|
position: float
|
2020-12-25 12:08:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Balances(BaseModel):
|
|
|
|
currencies: List[Balance]
|
|
|
|
total: float
|
|
|
|
symbol: str
|
|
|
|
value: float
|
|
|
|
stake: str
|
|
|
|
note: str
|
2021-09-19 11:16:30 +00:00
|
|
|
starting_capital: float
|
|
|
|
starting_capital_ratio: float
|
|
|
|
starting_capital_pct: float
|
|
|
|
starting_capital_fiat: float
|
|
|
|
starting_capital_fiat_ratio: float
|
|
|
|
starting_capital_fiat_pct: float
|
|
|
|
|
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
|
2021-10-31 09:42:42 +00:00
|
|
|
profit_ratio: float
|
|
|
|
profit_pct: float
|
2021-05-15 17:39:46 +00:00
|
|
|
profit_abs: float
|
2020-12-26 15:43:15 +00:00
|
|
|
count: int
|
|
|
|
|
|
|
|
|
|
|
|
class Profit(BaseModel):
|
|
|
|
profit_closed_coin: float
|
|
|
|
profit_closed_percent_mean: float
|
|
|
|
profit_closed_ratio_mean: float
|
|
|
|
profit_closed_percent_sum: float
|
|
|
|
profit_closed_ratio_sum: float
|
2021-07-14 18:55:11 +00:00
|
|
|
profit_closed_percent: float
|
|
|
|
profit_closed_ratio: float
|
2020-12-26 15:43:15 +00:00
|
|
|
profit_closed_fiat: float
|
|
|
|
profit_all_coin: float
|
|
|
|
profit_all_percent_mean: float
|
|
|
|
profit_all_ratio_mean: float
|
|
|
|
profit_all_percent_sum: float
|
|
|
|
profit_all_ratio_sum: float
|
2021-07-14 18:55:11 +00:00
|
|
|
profit_all_percent: float
|
|
|
|
profit_all_ratio: float
|
2020-12-26 15:43:15 +00:00
|
|
|
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
|
2021-11-11 11:58:38 +00:00
|
|
|
best_pair_profit_ratio: float
|
2020-12-26 15:43:15 +00:00
|
|
|
winning_trades: int
|
|
|
|
losing_trades: int
|
|
|
|
|
|
|
|
|
|
|
|
class SellReason(BaseModel):
|
|
|
|
wins: int
|
|
|
|
losses: int
|
|
|
|
draws: int
|
|
|
|
|
|
|
|
|
|
|
|
class Stats(BaseModel):
|
2022-03-24 19:33:47 +00:00
|
|
|
exit_reasons: Dict[str, SellReason]
|
2022-02-10 06:03:19 +00:00
|
|
|
durations: Dict[str, Optional[float]]
|
2020-12-26 16:00:30 +00:00
|
|
|
|
|
|
|
|
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-11-06 15:12:25 +00:00
|
|
|
class UnfilledTimeout(BaseModel):
|
2022-03-26 10:55:11 +00:00
|
|
|
entry: Optional[int]
|
|
|
|
exit: Optional[int]
|
2021-11-30 19:46:47 +00:00
|
|
|
unit: Optional[str]
|
2021-11-06 15:12:25 +00:00
|
|
|
exit_timeout_count: Optional[int]
|
|
|
|
|
|
|
|
|
|
|
|
class OrderTypes(BaseModel):
|
2022-03-07 19:32:16 +00:00
|
|
|
entry: OrderTypeValues
|
|
|
|
exit: OrderTypeValues
|
2022-04-05 10:31:53 +00:00
|
|
|
emergency_exit: Optional[OrderTypeValues]
|
|
|
|
force_exit: Optional[OrderTypeValues]
|
|
|
|
force_entry: Optional[OrderTypeValues]
|
2021-11-24 19:11:04 +00:00
|
|
|
stoploss: OrderTypeValues
|
2021-11-06 15:12:25 +00:00
|
|
|
stoploss_on_exchange: bool
|
|
|
|
stoploss_on_exchange_interval: Optional[int]
|
|
|
|
|
|
|
|
|
2021-01-02 14:48:33 +00:00
|
|
|
class ShowConfig(BaseModel):
|
2021-11-06 15:12:25 +00:00
|
|
|
version: str
|
2021-12-04 13:49:45 +00:00
|
|
|
strategy_version: Optional[str]
|
2021-11-23 06:06:53 +00:00
|
|
|
api_version: float
|
2021-02-20 18:17:10 +00:00
|
|
|
dry_run: bool
|
2021-11-20 19:09:37 +00:00
|
|
|
trading_mode: str
|
|
|
|
short_allowed: bool
|
2021-01-02 14:48:33 +00:00
|
|
|
stake_currency: str
|
2022-02-15 19:01:35 +00:00
|
|
|
stake_amount: str
|
2021-07-14 18:51:42 +00:00
|
|
|
available_capital: Optional[float]
|
2021-06-26 18:46:54 +00:00
|
|
|
stake_currency_decimals: int
|
2021-01-02 14:48:33 +00:00
|
|
|
max_open_trades: int
|
|
|
|
minimal_roi: Dict[str, Any]
|
2021-04-02 18:00:14 +00:00
|
|
|
stoploss: Optional[float]
|
|
|
|
trailing_stop: Optional[bool]
|
2021-01-02 14:48:33 +00:00
|
|
|
trailing_stop_positive: Optional[float]
|
|
|
|
trailing_stop_positive_offset: Optional[float]
|
|
|
|
trailing_only_offset_is_reached: Optional[bool]
|
2021-11-06 15:12:25 +00:00
|
|
|
unfilledtimeout: UnfilledTimeout
|
2021-12-11 18:46:35 +00:00
|
|
|
order_types: Optional[OrderTypes]
|
2021-01-30 19:11:18 +00:00
|
|
|
use_custom_stoploss: Optional[bool]
|
2021-04-02 18:00:14 +00:00
|
|
|
timeframe: Optional[str]
|
2021-01-02 14:48:33 +00:00
|
|
|
timeframe_ms: int
|
|
|
|
timeframe_min: int
|
|
|
|
exchange: str
|
2021-04-02 18:00:14 +00:00
|
|
|
strategy: Optional[str]
|
2022-04-08 11:39:41 +00:00
|
|
|
force_entry_enable: bool
|
2022-03-27 16:03:49 +00:00
|
|
|
exit_pricing: Dict[str, Any]
|
|
|
|
entry_pricing: Dict[str, Any]
|
2021-01-16 15:19:49 +00:00
|
|
|
bot_name: str
|
2021-01-02 14:48:33 +00:00
|
|
|
state: str
|
|
|
|
runmode: str
|
2022-01-21 00:35:22 +00:00
|
|
|
position_adjustment_enable: bool
|
2022-01-27 15:57:50 +00:00
|
|
|
max_entry_position_adjustment: int
|
2021-01-02 14:48:33 +00:00
|
|
|
|
|
|
|
|
2022-02-26 15:10:54 +00:00
|
|
|
class OrderSchema(BaseModel):
|
|
|
|
pair: str
|
|
|
|
order_id: str
|
|
|
|
status: str
|
|
|
|
remaining: float
|
|
|
|
amount: float
|
|
|
|
safe_price: float
|
|
|
|
cost: float
|
|
|
|
filled: float
|
|
|
|
ft_order_side: str
|
|
|
|
order_type: str
|
|
|
|
is_open: bool
|
|
|
|
order_timestamp: Optional[int]
|
|
|
|
order_filled_timestamp: Optional[int]
|
|
|
|
|
|
|
|
|
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
|
2021-11-14 08:51:03 +00:00
|
|
|
is_short: bool
|
2021-01-01 18:36:03 +00:00
|
|
|
exchange: str
|
|
|
|
amount: float
|
|
|
|
amount_requested: float
|
|
|
|
stake_amount: float
|
|
|
|
strategy: str
|
2021-11-21 09:05:56 +00:00
|
|
|
buy_tag: Optional[str] # Deprecated
|
2021-11-21 08:24:20 +00:00
|
|
|
enter_tag: Optional[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: str
|
|
|
|
open_timestamp: int
|
|
|
|
open_rate: float
|
|
|
|
open_rate_requested: Optional[float]
|
|
|
|
open_trade_value: float
|
|
|
|
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]
|
2021-04-02 10:20:38 +00:00
|
|
|
profit_fiat: Optional[float]
|
2022-04-03 06:17:01 +00:00
|
|
|
sell_reason: Optional[str] # Deprecated
|
2022-03-24 19:33:47 +00:00
|
|
|
exit_reason: Optional[str]
|
2022-04-03 09:17:01 +00:00
|
|
|
exit_order_status: Optional[str]
|
2021-01-01 18:36:03 +00:00
|
|
|
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]
|
2022-02-27 15:54:14 +00:00
|
|
|
orders: List[OrderSchema]
|
2021-01-01 18:36:03 +00:00
|
|
|
|
2022-02-01 06:08:43 +00:00
|
|
|
leverage: Optional[float]
|
|
|
|
interest_rate: Optional[float]
|
|
|
|
funding_fees: Optional[float]
|
|
|
|
trading_mode: Optional[TradingMode]
|
|
|
|
|
2021-01-01 18:36:03 +00:00
|
|
|
|
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]
|
|
|
|
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
|
2021-04-18 14:05:28 +00:00
|
|
|
total_trades: int
|
2021-01-01 18:36:03 +00:00
|
|
|
|
|
|
|
|
2022-01-26 06:10:38 +00:00
|
|
|
class ForceEnterResponse(BaseModel):
|
2021-02-28 09:56:51 +00:00
|
|
|
__root__: Union[TradeSchema, StatusMsg]
|
2021-01-02 14:11:40 +00:00
|
|
|
|
|
|
|
|
2020-12-26 16:33:27 +00:00
|
|
|
class LockModel(BaseModel):
|
2021-03-01 18:50:39 +00:00
|
|
|
id: int
|
2020-12-26 16:33:27 +00:00
|
|
|
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]
|
|
|
|
|
|
|
|
|
2021-03-01 18:50:39 +00:00
|
|
|
class DeleteLockRequest(BaseModel):
|
|
|
|
pair: Optional[str]
|
|
|
|
lockid: Optional[int]
|
|
|
|
|
|
|
|
|
2020-12-26 16:33:27 +00:00
|
|
|
class Logs(BaseModel):
|
|
|
|
log_count: int
|
|
|
|
logs: List[List]
|
|
|
|
|
|
|
|
|
2022-01-26 06:10:38 +00:00
|
|
|
class ForceEnterPayload(BaseModel):
|
2020-12-26 16:00:30 +00:00
|
|
|
pair: str
|
2022-01-26 06:10:38 +00:00
|
|
|
side: SignalDirection = SignalDirection.LONG
|
2020-12-26 16:00:30 +00:00
|
|
|
price: Optional[float]
|
2021-11-24 19:11:04 +00:00
|
|
|
ordertype: Optional[OrderTypeValues]
|
2022-01-22 12:26:02 +00:00
|
|
|
stakeamount: Optional[float]
|
2022-02-11 14:31:15 +00:00
|
|
|
entry_tag: Optional[str]
|
2020-12-26 16:00:30 +00:00
|
|
|
|
|
|
|
|
2022-04-06 01:35:43 +00:00
|
|
|
class ForceExitPayload(BaseModel):
|
2020-12-26 16:00:30 +00:00
|
|
|
tradeid: str
|
2021-11-27 08:10:18 +00:00
|
|
|
ordertype: Optional[OrderTypeValues]
|
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]
|
2021-05-14 04:36:18 +00:00
|
|
|
subplots: Dict[str, Any]
|
2020-12-26 19:05:27 +00:00
|
|
|
|
|
|
|
|
2021-02-28 09:56:51 +00:00
|
|
|
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
|
2021-11-20 19:09:37 +00:00
|
|
|
enter_long_signals: int
|
|
|
|
exit_long_signals: int
|
|
|
|
enter_short_signals: int
|
|
|
|
exit_short_signals: int
|
2020-12-27 08:02:35 +00:00
|
|
|
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),
|
|
|
|
}
|
2021-01-02 14:13:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
class BacktestRequest(BaseModel):
|
|
|
|
strategy: str
|
|
|
|
timeframe: Optional[str]
|
2021-08-14 13:34:43 +00:00
|
|
|
timeframe_detail: Optional[str]
|
2021-01-02 14:13:32 +00:00
|
|
|
timerange: Optional[str]
|
|
|
|
max_open_trades: Optional[int]
|
2022-02-15 19:01:35 +00:00
|
|
|
stake_amount: Optional[str]
|
2021-01-06 14:05:54 +00:00
|
|
|
enable_protections: bool
|
2021-02-28 08:56:13 +00:00
|
|
|
dry_run_wallet: Optional[float]
|
2021-01-02 14:13:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
class BacktestResponse(BaseModel):
|
|
|
|
status: str
|
|
|
|
running: bool
|
|
|
|
status_msg: str
|
2021-03-11 18:16:18 +00:00
|
|
|
step: str
|
|
|
|
progress: float
|
2021-03-12 18:11:17 +00:00
|
|
|
trade_count: Optional[float]
|
2021-01-02 14:13:32 +00:00
|
|
|
# TODO: Properly type backtestresult...
|
|
|
|
backtest_result: Optional[Dict[str, Any]]
|
2021-10-04 23:10:39 +00:00
|
|
|
|
2021-10-06 17:36:28 +00:00
|
|
|
|
2021-10-04 23:10:39 +00:00
|
|
|
class SysInfo(BaseModel):
|
2021-10-07 11:04:42 +00:00
|
|
|
cpu_pct: List[float]
|
2021-10-04 23:10:39 +00:00
|
|
|
ram_pct: float
|
2022-01-23 19:58:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Health(BaseModel):
|
|
|
|
last_process: datetime
|
2022-01-28 06:57:43 +00:00
|
|
|
last_process_ts: int
|