various adjustement from PR discussion
This commit is contained in:
parent
8555c5b211
commit
6256025c73
@ -188,7 +188,7 @@ class Trade(_DECL_BASE):
|
|||||||
fee_close = Column(Float, nullable=False, default=0.0)
|
fee_close = Column(Float, nullable=False, default=0.0)
|
||||||
open_rate = Column(Float)
|
open_rate = Column(Float)
|
||||||
open_rate_requested = Column(Float)
|
open_rate_requested = Column(Float)
|
||||||
# open_trade_price - calcuated via _calc_open_trade_price
|
# open_trade_price - calculated via _calc_open_trade_price
|
||||||
open_trade_price = Column(Float)
|
open_trade_price = Column(Float)
|
||||||
close_rate = Column(Float)
|
close_rate = Column(Float)
|
||||||
close_rate_requested = Column(Float)
|
close_rate_requested = Column(Float)
|
||||||
@ -233,6 +233,9 @@ class Trade(_DECL_BASE):
|
|||||||
return {
|
return {
|
||||||
'trade_id': self.id,
|
'trade_id': self.id,
|
||||||
'pair': self.pair,
|
'pair': self.pair,
|
||||||
|
'is_open': self.is_open,
|
||||||
|
'fee_open': self.fee_open,
|
||||||
|
'fee_close': self.fee_close,
|
||||||
'open_date_hum': arrow.get(self.open_date).humanize(),
|
'open_date_hum': arrow.get(self.open_date).humanize(),
|
||||||
'open_date': self.open_date.strftime("%Y-%m-%d %H:%M:%S"),
|
'open_date': self.open_date.strftime("%Y-%m-%d %H:%M:%S"),
|
||||||
'close_date_hum': (arrow.get(self.close_date).humanize()
|
'close_date_hum': (arrow.get(self.close_date).humanize()
|
||||||
@ -240,14 +243,24 @@ class Trade(_DECL_BASE):
|
|||||||
'close_date': (self.close_date.strftime("%Y-%m-%d %H:%M:%S")
|
'close_date': (self.close_date.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
if self.close_date else None),
|
if self.close_date else None),
|
||||||
'open_rate': self.open_rate,
|
'open_rate': self.open_rate,
|
||||||
|
'open_rate_requested': self.open_rate_requested,
|
||||||
|
'open_trade_price': self.open_trade_price,
|
||||||
'close_rate': self.close_rate,
|
'close_rate': self.close_rate,
|
||||||
|
'close_rate_requested': self.close_rate_requested,
|
||||||
'amount': round(self.amount, 8),
|
'amount': round(self.amount, 8),
|
||||||
'stake_amount': round(self.stake_amount, 8),
|
'stake_amount': round(self.stake_amount, 8),
|
||||||
|
'close_profit': self.close_profit,
|
||||||
|
'sell_reason': self.sell_reason,
|
||||||
'stop_loss': self.stop_loss,
|
'stop_loss': self.stop_loss,
|
||||||
'stop_loss_pct': (self.stop_loss_pct * 100) if self.stop_loss_pct else None,
|
'stop_loss_pct': (self.stop_loss_pct * 100) if self.stop_loss_pct else None,
|
||||||
'initial_stop_loss': self.initial_stop_loss,
|
'initial_stop_loss': self.initial_stop_loss,
|
||||||
'initial_stop_loss_pct': (self.initial_stop_loss_pct * 100
|
'initial_stop_loss_pct': (self.initial_stop_loss_pct * 100
|
||||||
if self.initial_stop_loss_pct else None),
|
if self.initial_stop_loss_pct else None),
|
||||||
|
'min_rate': self.min_rate,
|
||||||
|
'max_rate': self.max_rate,
|
||||||
|
'strategy': self.strategy,
|
||||||
|
'ticker_interval': self.ticker_interval,
|
||||||
|
'open_order_id': self.open_order_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
def adjust_min_max_rates(self, current_price: float) -> None:
|
def adjust_min_max_rates(self, current_price: float) -> None:
|
||||||
|
@ -367,9 +367,8 @@ class ApiServer(RPC):
|
|||||||
|
|
||||||
Returns the X last trades in json format
|
Returns the X last trades in json format
|
||||||
"""
|
"""
|
||||||
last_trades_number = request.args.get('last_trades_number', 0)
|
limit = int(request.args.get('limit', 0))
|
||||||
last_trades_number = int(last_trades_number)
|
results = self._rpc_trade_history(limit)
|
||||||
results = self._rpc_trade_history(last_trades_number)
|
|
||||||
return self.rest_dump(results)
|
return self.rest_dump(results)
|
||||||
|
|
||||||
@require_login
|
@require_login
|
||||||
|
@ -227,50 +227,21 @@ class RPC:
|
|||||||
]
|
]
|
||||||
|
|
||||||
def _rpc_trade_history(
|
def _rpc_trade_history(
|
||||||
self, last_trades_number: int) -> Dict[str, List[Dict[str, Any]]]:
|
self, limit: int) -> Dict[str, List[Dict[str, Any]]]:
|
||||||
""" Returns the X last trades """
|
""" Returns the X last trades """
|
||||||
if last_trades_number > 0:
|
if limit > 0:
|
||||||
trades = Trade.get_trades().order_by(Trade.id.desc()).limit(last_trades_number)
|
trades = Trade.get_trades().order_by(Trade.id.desc()).limit(limit)
|
||||||
else:
|
else:
|
||||||
trades = Trade.get_trades().order_by(Trade.id.desc()).all()
|
trades = Trade.get_trades().order_by(Trade.id.desc()).all()
|
||||||
|
|
||||||
output = []
|
output = []
|
||||||
|
|
||||||
for trade in trades:
|
for trade in trades:
|
||||||
output.append({
|
output.append(trade.to_json())
|
||||||
'id': trade.id,
|
|
||||||
'pair': trade.pair,
|
|
||||||
'exchange': trade.exchange,
|
|
||||||
'is_open': trade.is_open if trade.is_open is not None else 0,
|
|
||||||
'open_rate': trade.open_rate,
|
|
||||||
'close_rate': trade.close_rate,
|
|
||||||
'fee_open': trade.fee_open,
|
|
||||||
'fee_close': trade.fee_close,
|
|
||||||
'open_rate_requested': trade.open_rate_requested,
|
|
||||||
'open_trade_price': trade.open_trade_price,
|
|
||||||
'close_rate_requested': trade.close_rate_requested,
|
|
||||||
'close_profit': trade.close_profit,
|
|
||||||
'close_profit_abs': trade.close_profit_abs,
|
|
||||||
'stake_amount': trade.stake_amount,
|
|
||||||
'amount': trade.amount,
|
|
||||||
'open_date': trade.open_date,
|
|
||||||
'close_date': trade.close_date,
|
|
||||||
'open_order_id': trade.open_order_id,
|
|
||||||
'stop_loss': trade.stop_loss,
|
|
||||||
'stop_loss_pct': trade.stop_loss_pct,
|
|
||||||
'initial_stop_loss': trade.initial_stop_loss,
|
|
||||||
'initial_stop_loss_pct': trade.initial_stop_loss_pct,
|
|
||||||
'stoploss_order_id': trade.stoploss_order_id,
|
|
||||||
'stoploss_last_update': trade.stoploss_last_update,
|
|
||||||
'max_rate': trade.max_rate,
|
|
||||||
'min_rate': trade.min_rate,
|
|
||||||
'sell_reason': trade.sell_reason,
|
|
||||||
'strategy': trade.strategy,
|
|
||||||
'ticker_interval': trade.ticker_interval,
|
|
||||||
})
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"trades": output
|
"trades": output,
|
||||||
|
"trades_count": len(output)
|
||||||
}
|
}
|
||||||
|
|
||||||
def _rpc_trade_statistics(
|
def _rpc_trade_statistics(
|
||||||
|
@ -156,12 +156,13 @@ class FtRestClient():
|
|||||||
"""
|
"""
|
||||||
return self._get("show_config")
|
return self._get("show_config")
|
||||||
|
|
||||||
def history(self, number=None):
|
def history(self, limit=None):
|
||||||
"""Return the amount of open trades.
|
"""Return trades history.
|
||||||
|
|
||||||
|
:param limit: Limits trades to the X last trades . No limit to get all the trades.
|
||||||
:return: json object
|
:return: json object
|
||||||
"""
|
"""
|
||||||
return self._get("trades", params={"last_trades_number": number} if number else 0)
|
return self._get("trades", params={"limit": limit} if limit else 0)
|
||||||
|
|
||||||
def whitelist(self):
|
def whitelist(self):
|
||||||
"""Show the current whitelist.
|
"""Show the current whitelist.
|
||||||
|
Loading…
Reference in New Issue
Block a user