Export amount/price precisions per trade
This commit is contained in:
parent
4053ee4581
commit
9c6a49436b
@ -560,6 +560,9 @@ class LocalTrade():
|
|||||||
'trading_mode': self.trading_mode,
|
'trading_mode': self.trading_mode,
|
||||||
'funding_fees': self.funding_fees,
|
'funding_fees': self.funding_fees,
|
||||||
'open_order_id': self.open_order_id,
|
'open_order_id': self.open_order_id,
|
||||||
|
'amount_precision': self.amount_precision,
|
||||||
|
'price_precision': self.price_precision,
|
||||||
|
'precision_mode': self.precision_mode,
|
||||||
'orders': orders,
|
'orders': orders,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1330,71 +1330,78 @@ def test_to_json(fee):
|
|||||||
open_rate=0.123,
|
open_rate=0.123,
|
||||||
exchange='binance',
|
exchange='binance',
|
||||||
enter_tag=None,
|
enter_tag=None,
|
||||||
open_order_id='dry_run_buy_12345'
|
open_order_id='dry_run_buy_12345',
|
||||||
|
precision_mode=1,
|
||||||
|
amount_precision=8.0,
|
||||||
|
price_precision=7.0,
|
||||||
)
|
)
|
||||||
result = trade.to_json()
|
result = trade.to_json()
|
||||||
assert isinstance(result, dict)
|
assert isinstance(result, dict)
|
||||||
|
|
||||||
assert result == {'trade_id': None,
|
assert result == {
|
||||||
'pair': 'ADA/USDT',
|
'trade_id': None,
|
||||||
'base_currency': 'ADA',
|
'pair': 'ADA/USDT',
|
||||||
'quote_currency': 'USDT',
|
'base_currency': 'ADA',
|
||||||
'is_open': None,
|
'quote_currency': 'USDT',
|
||||||
'open_date': trade.open_date.strftime(DATETIME_PRINT_FORMAT),
|
'is_open': None,
|
||||||
'open_timestamp': int(trade.open_date.timestamp() * 1000),
|
'open_date': trade.open_date.strftime(DATETIME_PRINT_FORMAT),
|
||||||
'open_order_id': 'dry_run_buy_12345',
|
'open_timestamp': int(trade.open_date.timestamp() * 1000),
|
||||||
'close_date': None,
|
'open_order_id': 'dry_run_buy_12345',
|
||||||
'close_timestamp': None,
|
'close_date': None,
|
||||||
'open_rate': 0.123,
|
'close_timestamp': None,
|
||||||
'open_rate_requested': None,
|
'open_rate': 0.123,
|
||||||
'open_trade_value': 15.1668225,
|
'open_rate_requested': None,
|
||||||
'fee_close': 0.0025,
|
'open_trade_value': 15.1668225,
|
||||||
'fee_close_cost': None,
|
'fee_close': 0.0025,
|
||||||
'fee_close_currency': None,
|
'fee_close_cost': None,
|
||||||
'fee_open': 0.0025,
|
'fee_close_currency': None,
|
||||||
'fee_open_cost': None,
|
'fee_open': 0.0025,
|
||||||
'fee_open_currency': None,
|
'fee_open_cost': None,
|
||||||
'close_rate': None,
|
'fee_open_currency': None,
|
||||||
'close_rate_requested': None,
|
'close_rate': None,
|
||||||
'amount': 123.0,
|
'close_rate_requested': None,
|
||||||
'amount_requested': 123.0,
|
'amount': 123.0,
|
||||||
'stake_amount': 0.001,
|
'amount_requested': 123.0,
|
||||||
'max_stake_amount': None,
|
'stake_amount': 0.001,
|
||||||
'trade_duration': None,
|
'max_stake_amount': None,
|
||||||
'trade_duration_s': None,
|
'trade_duration': None,
|
||||||
'realized_profit': 0.0,
|
'trade_duration_s': None,
|
||||||
'realized_profit_ratio': None,
|
'realized_profit': 0.0,
|
||||||
'close_profit': None,
|
'realized_profit_ratio': None,
|
||||||
'close_profit_pct': None,
|
'close_profit': None,
|
||||||
'close_profit_abs': None,
|
'close_profit_pct': None,
|
||||||
'profit_ratio': None,
|
'close_profit_abs': None,
|
||||||
'profit_pct': None,
|
'profit_ratio': None,
|
||||||
'profit_abs': None,
|
'profit_pct': None,
|
||||||
'exit_reason': None,
|
'profit_abs': None,
|
||||||
'exit_order_status': None,
|
'exit_reason': None,
|
||||||
'stop_loss_abs': None,
|
'exit_order_status': None,
|
||||||
'stop_loss_ratio': None,
|
'stop_loss_abs': None,
|
||||||
'stop_loss_pct': None,
|
'stop_loss_ratio': None,
|
||||||
'stoploss_order_id': None,
|
'stop_loss_pct': None,
|
||||||
'stoploss_last_update': None,
|
'stoploss_order_id': None,
|
||||||
'stoploss_last_update_timestamp': None,
|
'stoploss_last_update': None,
|
||||||
'initial_stop_loss_abs': None,
|
'stoploss_last_update_timestamp': None,
|
||||||
'initial_stop_loss_pct': None,
|
'initial_stop_loss_abs': None,
|
||||||
'initial_stop_loss_ratio': None,
|
'initial_stop_loss_pct': None,
|
||||||
'min_rate': None,
|
'initial_stop_loss_ratio': None,
|
||||||
'max_rate': None,
|
'min_rate': None,
|
||||||
'strategy': None,
|
'max_rate': None,
|
||||||
'enter_tag': None,
|
'strategy': None,
|
||||||
'timeframe': None,
|
'enter_tag': None,
|
||||||
'exchange': 'binance',
|
'timeframe': None,
|
||||||
'leverage': None,
|
'exchange': 'binance',
|
||||||
'interest_rate': None,
|
'leverage': None,
|
||||||
'liquidation_price': None,
|
'interest_rate': None,
|
||||||
'is_short': None,
|
'liquidation_price': None,
|
||||||
'trading_mode': None,
|
'is_short': None,
|
||||||
'funding_fees': None,
|
'trading_mode': None,
|
||||||
'orders': [],
|
'funding_fees': None,
|
||||||
}
|
'amount_precision': 8.0,
|
||||||
|
'price_precision': 7.0,
|
||||||
|
'precision_mode': 1,
|
||||||
|
'orders': [],
|
||||||
|
}
|
||||||
|
|
||||||
# Simulate dry_run entries
|
# Simulate dry_run entries
|
||||||
trade = Trade(
|
trade = Trade(
|
||||||
@ -1410,70 +1417,77 @@ def test_to_json(fee):
|
|||||||
close_rate=0.125,
|
close_rate=0.125,
|
||||||
enter_tag='buys_signal_001',
|
enter_tag='buys_signal_001',
|
||||||
exchange='binance',
|
exchange='binance',
|
||||||
|
precision_mode=2,
|
||||||
|
amount_precision=7.0,
|
||||||
|
price_precision=8.0,
|
||||||
)
|
)
|
||||||
result = trade.to_json()
|
result = trade.to_json()
|
||||||
assert isinstance(result, dict)
|
assert isinstance(result, dict)
|
||||||
|
|
||||||
assert result == {'trade_id': None,
|
assert result == {
|
||||||
'pair': 'XRP/BTC',
|
'trade_id': None,
|
||||||
'base_currency': 'XRP',
|
'pair': 'XRP/BTC',
|
||||||
'quote_currency': 'BTC',
|
'base_currency': 'XRP',
|
||||||
'open_date': trade.open_date.strftime(DATETIME_PRINT_FORMAT),
|
'quote_currency': 'BTC',
|
||||||
'open_timestamp': int(trade.open_date.timestamp() * 1000),
|
'open_date': trade.open_date.strftime(DATETIME_PRINT_FORMAT),
|
||||||
'close_date': trade.close_date.strftime(DATETIME_PRINT_FORMAT),
|
'open_timestamp': int(trade.open_date.timestamp() * 1000),
|
||||||
'close_timestamp': int(trade.close_date.timestamp() * 1000),
|
'close_date': trade.close_date.strftime(DATETIME_PRINT_FORMAT),
|
||||||
'open_rate': 0.123,
|
'close_timestamp': int(trade.close_date.timestamp() * 1000),
|
||||||
'close_rate': 0.125,
|
'open_rate': 0.123,
|
||||||
'amount': 100.0,
|
'close_rate': 0.125,
|
||||||
'amount_requested': 101.0,
|
'amount': 100.0,
|
||||||
'stake_amount': 0.001,
|
'amount_requested': 101.0,
|
||||||
'max_stake_amount': None,
|
'stake_amount': 0.001,
|
||||||
'trade_duration': 60,
|
'max_stake_amount': None,
|
||||||
'trade_duration_s': 3600,
|
'trade_duration': 60,
|
||||||
'stop_loss_abs': None,
|
'trade_duration_s': 3600,
|
||||||
'stop_loss_pct': None,
|
'stop_loss_abs': None,
|
||||||
'stop_loss_ratio': None,
|
'stop_loss_pct': None,
|
||||||
'stoploss_order_id': None,
|
'stop_loss_ratio': None,
|
||||||
'stoploss_last_update': None,
|
'stoploss_order_id': None,
|
||||||
'stoploss_last_update_timestamp': None,
|
'stoploss_last_update': None,
|
||||||
'initial_stop_loss_abs': None,
|
'stoploss_last_update_timestamp': None,
|
||||||
'initial_stop_loss_pct': None,
|
'initial_stop_loss_abs': None,
|
||||||
'initial_stop_loss_ratio': None,
|
'initial_stop_loss_pct': None,
|
||||||
'realized_profit': 0.0,
|
'initial_stop_loss_ratio': None,
|
||||||
'realized_profit_ratio': None,
|
'realized_profit': 0.0,
|
||||||
'close_profit': None,
|
'realized_profit_ratio': None,
|
||||||
'close_profit_pct': None,
|
'close_profit': None,
|
||||||
'close_profit_abs': None,
|
'close_profit_pct': None,
|
||||||
'profit_ratio': None,
|
'close_profit_abs': None,
|
||||||
'profit_pct': None,
|
'profit_ratio': None,
|
||||||
'profit_abs': None,
|
'profit_pct': None,
|
||||||
'close_rate_requested': None,
|
'profit_abs': None,
|
||||||
'fee_close': 0.0025,
|
'close_rate_requested': None,
|
||||||
'fee_close_cost': None,
|
'fee_close': 0.0025,
|
||||||
'fee_close_currency': None,
|
'fee_close_cost': None,
|
||||||
'fee_open': 0.0025,
|
'fee_close_currency': None,
|
||||||
'fee_open_cost': None,
|
'fee_open': 0.0025,
|
||||||
'fee_open_currency': None,
|
'fee_open_cost': None,
|
||||||
'is_open': None,
|
'fee_open_currency': None,
|
||||||
'max_rate': None,
|
'is_open': None,
|
||||||
'min_rate': None,
|
'max_rate': None,
|
||||||
'open_order_id': None,
|
'min_rate': None,
|
||||||
'open_rate_requested': None,
|
'open_order_id': None,
|
||||||
'open_trade_value': 12.33075,
|
'open_rate_requested': None,
|
||||||
'exit_reason': None,
|
'open_trade_value': 12.33075,
|
||||||
'exit_order_status': None,
|
'exit_reason': None,
|
||||||
'strategy': None,
|
'exit_order_status': None,
|
||||||
'enter_tag': 'buys_signal_001',
|
'strategy': None,
|
||||||
'timeframe': None,
|
'enter_tag': 'buys_signal_001',
|
||||||
'exchange': 'binance',
|
'timeframe': None,
|
||||||
'leverage': None,
|
'exchange': 'binance',
|
||||||
'interest_rate': None,
|
'leverage': None,
|
||||||
'liquidation_price': None,
|
'interest_rate': None,
|
||||||
'is_short': None,
|
'liquidation_price': None,
|
||||||
'trading_mode': None,
|
'is_short': None,
|
||||||
'funding_fees': None,
|
'trading_mode': None,
|
||||||
'orders': [],
|
'funding_fees': None,
|
||||||
}
|
'amount_precision': 7.0,
|
||||||
|
'price_precision': 8.0,
|
||||||
|
'precision_mode': 2,
|
||||||
|
'orders': [],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def test_stoploss_reinitialization(default_conf, fee):
|
def test_stoploss_reinitialization(default_conf, fee):
|
||||||
|
@ -88,6 +88,9 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
|
|||||||
'is_short': False,
|
'is_short': False,
|
||||||
'funding_fees': 0.0,
|
'funding_fees': 0.0,
|
||||||
'trading_mode': TradingMode.SPOT,
|
'trading_mode': TradingMode.SPOT,
|
||||||
|
'amount_precision': 8.0,
|
||||||
|
'price_precision': 8.0,
|
||||||
|
'precision_mode': 2,
|
||||||
'orders': [{
|
'orders': [{
|
||||||
'amount': 91.07468123, 'average': 1.098e-05, 'safe_price': 1.098e-05,
|
'amount': 91.07468123, 'average': 1.098e-05, 'safe_price': 1.098e-05,
|
||||||
'cost': 0.0009999999999054, 'filled': 91.07468123, 'ft_order_side': 'buy',
|
'cost': 0.0009999999999054, 'filled': 91.07468123, 'ft_order_side': 'buy',
|
||||||
|
Loading…
Reference in New Issue
Block a user