Fix mock-tests missing some fields
This commit is contained in:
parent
29f4dd1dcd
commit
84ced92002
@ -113,7 +113,7 @@ class Daily(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class TradeSchema(BaseModel):
|
class TradeSchema(BaseModel):
|
||||||
trade_id: str
|
trade_id: int
|
||||||
pair: str
|
pair: str
|
||||||
is_open: bool
|
is_open: bool
|
||||||
exchange: str
|
exchange: str
|
||||||
@ -121,7 +121,7 @@ class TradeSchema(BaseModel):
|
|||||||
amount_requested: float
|
amount_requested: float
|
||||||
stake_amount: float
|
stake_amount: float
|
||||||
strategy: str
|
strategy: str
|
||||||
timeframe: str
|
timeframe: int
|
||||||
fee_open: Optional[float]
|
fee_open: Optional[float]
|
||||||
fee_open_cost: Optional[float]
|
fee_open_cost: Optional[float]
|
||||||
fee_open_currency: Optional[str]
|
fee_open_currency: Optional[str]
|
||||||
@ -161,6 +161,20 @@ class TradeSchema(BaseModel):
|
|||||||
open_order_id: Optional[str]
|
open_order_id: Optional[str]
|
||||||
|
|
||||||
|
|
||||||
|
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]
|
||||||
|
|
||||||
|
|
||||||
class TradeResponse(BaseModel):
|
class TradeResponse(BaseModel):
|
||||||
trades: List[TradeSchema]
|
trades: List[TradeSchema]
|
||||||
trades_count: int
|
trades_count: int
|
||||||
|
@ -13,9 +13,10 @@ from freqtrade.rpc import RPC
|
|||||||
from freqtrade.rpc.api_server.api_models import (AvailablePairs, Balances, BlacklistPayload,
|
from freqtrade.rpc.api_server.api_models import (AvailablePairs, Balances, BlacklistPayload,
|
||||||
BlacklistResponse, Count, Daily, DeleteTrade,
|
BlacklistResponse, Count, Daily, DeleteTrade,
|
||||||
ForceBuyPayload, ForceSellPayload, Locks, Logs,
|
ForceBuyPayload, ForceSellPayload, Locks, Logs,
|
||||||
PairHistory, PerformanceEntry, Ping, PlotConfig,
|
OpenTradeSchema, PairHistory, PerformanceEntry,
|
||||||
Profit, ResultMsg, Stats, StatusMsg,
|
Ping, PlotConfig, Profit, ResultMsg, Stats,
|
||||||
StrategyListResponse, StrategyResponse, TradeResponse, TradeSchema, Version,
|
StatusMsg, StrategyListResponse, StrategyResponse,
|
||||||
|
TradeResponse, TradeSchema, Version,
|
||||||
WhitelistResponse)
|
WhitelistResponse)
|
||||||
from freqtrade.rpc.api_server.deps import get_config, get_rpc
|
from freqtrade.rpc.api_server.deps import get_config, get_rpc
|
||||||
from freqtrade.rpc.rpc import RPCException
|
from freqtrade.rpc.rpc import RPCException
|
||||||
@ -73,8 +74,7 @@ def daily(timescale: int = 7, rpc: RPC = Depends(get_rpc), config=Depends(get_co
|
|||||||
config.get('fiat_display_currency', ''))
|
config.get('fiat_display_currency', ''))
|
||||||
|
|
||||||
|
|
||||||
# TODO: Missing response model
|
@router.get('/status', response_model=List[OpenTradeSchema], tags=['info'])
|
||||||
@router.get('/status', response_model=List[TradeSchema], tags=['info'])
|
|
||||||
def status(rpc: RPC = Depends(get_rpc)):
|
def status(rpc: RPC = Depends(get_rpc)):
|
||||||
try:
|
try:
|
||||||
return rpc._rpc_trade_status()
|
return rpc._rpc_trade_status()
|
||||||
|
@ -32,6 +32,7 @@ def mock_trade_1(fee):
|
|||||||
exchange='bittrex',
|
exchange='bittrex',
|
||||||
open_order_id='dry_run_buy_12345',
|
open_order_id='dry_run_buy_12345',
|
||||||
strategy='DefaultStrategy',
|
strategy='DefaultStrategy',
|
||||||
|
timeframe=5,
|
||||||
)
|
)
|
||||||
o = Order.parse_from_ccxt_object(mock_order_1(), 'ETH/BTC', 'buy')
|
o = Order.parse_from_ccxt_object(mock_order_1(), 'ETH/BTC', 'buy')
|
||||||
trade.orders.append(o)
|
trade.orders.append(o)
|
||||||
@ -84,6 +85,7 @@ def mock_trade_2(fee):
|
|||||||
is_open=False,
|
is_open=False,
|
||||||
open_order_id='dry_run_sell_12345',
|
open_order_id='dry_run_sell_12345',
|
||||||
strategy='DefaultStrategy',
|
strategy='DefaultStrategy',
|
||||||
|
timeframe=5,
|
||||||
sell_reason='sell_signal',
|
sell_reason='sell_signal',
|
||||||
open_date=datetime.now(tz=timezone.utc) - timedelta(minutes=20),
|
open_date=datetime.now(tz=timezone.utc) - timedelta(minutes=20),
|
||||||
close_date=datetime.now(tz=timezone.utc),
|
close_date=datetime.now(tz=timezone.utc),
|
||||||
@ -132,6 +134,7 @@ def mock_trade_3(fee):
|
|||||||
pair='XRP/BTC',
|
pair='XRP/BTC',
|
||||||
stake_amount=0.001,
|
stake_amount=0.001,
|
||||||
amount=123.0,
|
amount=123.0,
|
||||||
|
amount_requested=123.0,
|
||||||
fee_open=fee.return_value,
|
fee_open=fee.return_value,
|
||||||
fee_close=fee.return_value,
|
fee_close=fee.return_value,
|
||||||
open_rate=0.05,
|
open_rate=0.05,
|
||||||
@ -139,6 +142,8 @@ def mock_trade_3(fee):
|
|||||||
close_profit=0.01,
|
close_profit=0.01,
|
||||||
exchange='bittrex',
|
exchange='bittrex',
|
||||||
is_open=False,
|
is_open=False,
|
||||||
|
strategy='DefaultStrategy',
|
||||||
|
timeframe=5,
|
||||||
sell_reason='roi',
|
sell_reason='roi',
|
||||||
open_date=datetime.now(tz=timezone.utc) - timedelta(minutes=20),
|
open_date=datetime.now(tz=timezone.utc) - timedelta(minutes=20),
|
||||||
close_date=datetime.now(tz=timezone.utc),
|
close_date=datetime.now(tz=timezone.utc),
|
||||||
@ -179,6 +184,7 @@ def mock_trade_4(fee):
|
|||||||
exchange='bittrex',
|
exchange='bittrex',
|
||||||
open_order_id='prod_buy_12345',
|
open_order_id='prod_buy_12345',
|
||||||
strategy='DefaultStrategy',
|
strategy='DefaultStrategy',
|
||||||
|
timeframe=5,
|
||||||
)
|
)
|
||||||
o = Order.parse_from_ccxt_object(mock_order_4(), 'ETC/BTC', 'buy')
|
o = Order.parse_from_ccxt_object(mock_order_4(), 'ETC/BTC', 'buy')
|
||||||
trade.orders.append(o)
|
trade.orders.append(o)
|
||||||
|
@ -128,7 +128,7 @@ def test_load_trades_from_db(default_conf, fee, mocker):
|
|||||||
if col not in ['index', 'open_at_end']:
|
if col not in ['index', 'open_at_end']:
|
||||||
assert col in trades.columns
|
assert col in trades.columns
|
||||||
trades = load_trades_from_db(db_url=default_conf['db_url'], strategy='DefaultStrategy')
|
trades = load_trades_from_db(db_url=default_conf['db_url'], strategy='DefaultStrategy')
|
||||||
assert len(trades) == 3
|
assert len(trades) == 4
|
||||||
trades = load_trades_from_db(db_url=default_conf['db_url'], strategy='NoneStrategy')
|
trades = load_trades_from_db(db_url=default_conf['db_url'], strategy='NoneStrategy')
|
||||||
assert len(trades) == 0
|
assert len(trades) == 0
|
||||||
|
|
||||||
|
@ -853,8 +853,8 @@ def test_api_forcebuy(botclient, mocker, fee):
|
|||||||
fee_close=fee.return_value,
|
fee_close=fee.return_value,
|
||||||
fee_open=fee.return_value,
|
fee_open=fee.return_value,
|
||||||
close_rate=0.265441,
|
close_rate=0.265441,
|
||||||
id='22',
|
id=22,
|
||||||
timeframe="5m",
|
timeframe=5,
|
||||||
strategy="DefaultStrategy"
|
strategy="DefaultStrategy"
|
||||||
))
|
))
|
||||||
mocker.patch("freqtrade.rpc.RPC._rpc_forcebuy", fbuy_mock)
|
mocker.patch("freqtrade.rpc.RPC._rpc_forcebuy", fbuy_mock)
|
||||||
@ -865,7 +865,7 @@ def test_api_forcebuy(botclient, mocker, fee):
|
|||||||
assert rc.json() == {
|
assert rc.json() == {
|
||||||
'amount': 1,
|
'amount': 1,
|
||||||
'amount_requested': 1,
|
'amount_requested': 1,
|
||||||
'trade_id': '22',
|
'trade_id': 22,
|
||||||
'close_date': None,
|
'close_date': None,
|
||||||
'close_date_hum': None,
|
'close_date_hum': None,
|
||||||
'close_timestamp': None,
|
'close_timestamp': None,
|
||||||
@ -907,7 +907,7 @@ def test_api_forcebuy(botclient, mocker, fee):
|
|||||||
'sell_reason': None,
|
'sell_reason': None,
|
||||||
'sell_order_status': None,
|
'sell_order_status': None,
|
||||||
'strategy': 'DefaultStrategy',
|
'strategy': 'DefaultStrategy',
|
||||||
'timeframe': '5m',
|
'timeframe': 5,
|
||||||
'exchange': 'bittrex',
|
'exchange': 'bittrex',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user