Don't export "hum" date versions for trade objects.
They are not used and have a rather high performance penalty due to using arrow.get
This commit is contained in:
parent
b60c2bc9b6
commit
9a58a85347
@ -294,15 +294,12 @@ class LocalTrade():
|
|||||||
'fee_close_cost': self.fee_close_cost,
|
'fee_close_cost': self.fee_close_cost,
|
||||||
'fee_close_currency': self.fee_close_currency,
|
'fee_close_currency': self.fee_close_currency,
|
||||||
|
|
||||||
'open_date_hum': arrow.get(self.open_date).humanize(),
|
|
||||||
'open_date': self.open_date.strftime(DATETIME_PRINT_FORMAT),
|
'open_date': self.open_date.strftime(DATETIME_PRINT_FORMAT),
|
||||||
'open_timestamp': int(self.open_date.replace(tzinfo=timezone.utc).timestamp() * 1000),
|
'open_timestamp': int(self.open_date.replace(tzinfo=timezone.utc).timestamp() * 1000),
|
||||||
'open_rate': self.open_rate,
|
'open_rate': self.open_rate,
|
||||||
'open_rate_requested': self.open_rate_requested,
|
'open_rate_requested': self.open_rate_requested,
|
||||||
'open_trade_value': round(self.open_trade_value, 8),
|
'open_trade_value': round(self.open_trade_value, 8),
|
||||||
|
|
||||||
'close_date_hum': (arrow.get(self.close_date).humanize()
|
|
||||||
if self.close_date else None),
|
|
||||||
'close_date': (self.close_date.strftime(DATETIME_PRINT_FORMAT)
|
'close_date': (self.close_date.strftime(DATETIME_PRINT_FORMAT)
|
||||||
if self.close_date else None),
|
if self.close_date else None),
|
||||||
'close_timestamp': int(self.close_date.replace(
|
'close_timestamp': int(self.close_date.replace(
|
||||||
|
@ -151,13 +151,11 @@ class TradeSchema(BaseModel):
|
|||||||
fee_close: Optional[float]
|
fee_close: Optional[float]
|
||||||
fee_close_cost: Optional[float]
|
fee_close_cost: Optional[float]
|
||||||
fee_close_currency: Optional[str]
|
fee_close_currency: Optional[str]
|
||||||
open_date_hum: str
|
|
||||||
open_date: str
|
open_date: str
|
||||||
open_timestamp: int
|
open_timestamp: int
|
||||||
open_rate: float
|
open_rate: float
|
||||||
open_rate_requested: Optional[float]
|
open_rate_requested: Optional[float]
|
||||||
open_trade_value: float
|
open_trade_value: float
|
||||||
close_date_hum: Optional[str]
|
|
||||||
close_date: Optional[str]
|
close_date: Optional[str]
|
||||||
close_timestamp: Optional[int]
|
close_timestamp: Optional[int]
|
||||||
close_rate: Optional[float]
|
close_rate: Optional[float]
|
||||||
|
@ -294,6 +294,7 @@ class Telegram(RPCHandler):
|
|||||||
|
|
||||||
messages = []
|
messages = []
|
||||||
for r in results:
|
for r in results:
|
||||||
|
r['open_date_hum'] = arrow.get(r['open_date']).humanize()
|
||||||
lines = [
|
lines = [
|
||||||
"*Trade ID:* `{trade_id}` `(since {open_date_hum})`",
|
"*Trade ID:* `{trade_id}` `(since {open_date_hum})`",
|
||||||
"*Current Pair:* {pair}",
|
"*Current Pair:* {pair}",
|
||||||
|
@ -53,7 +53,6 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
|
|||||||
'pair': 'ETH/BTC',
|
'pair': 'ETH/BTC',
|
||||||
'base_currency': 'BTC',
|
'base_currency': 'BTC',
|
||||||
'open_date': ANY,
|
'open_date': ANY,
|
||||||
'open_date_hum': ANY,
|
|
||||||
'open_timestamp': ANY,
|
'open_timestamp': ANY,
|
||||||
'is_open': ANY,
|
'is_open': ANY,
|
||||||
'fee_open': ANY,
|
'fee_open': ANY,
|
||||||
@ -73,7 +72,6 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
|
|||||||
'timeframe': 5,
|
'timeframe': 5,
|
||||||
'open_order_id': ANY,
|
'open_order_id': ANY,
|
||||||
'close_date': None,
|
'close_date': None,
|
||||||
'close_date_hum': None,
|
|
||||||
'close_timestamp': None,
|
'close_timestamp': None,
|
||||||
'open_rate': 1.098e-05,
|
'open_rate': 1.098e-05,
|
||||||
'close_rate': None,
|
'close_rate': None,
|
||||||
@ -121,7 +119,6 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
|
|||||||
'pair': 'ETH/BTC',
|
'pair': 'ETH/BTC',
|
||||||
'base_currency': 'BTC',
|
'base_currency': 'BTC',
|
||||||
'open_date': ANY,
|
'open_date': ANY,
|
||||||
'open_date_hum': ANY,
|
|
||||||
'open_timestamp': ANY,
|
'open_timestamp': ANY,
|
||||||
'is_open': ANY,
|
'is_open': ANY,
|
||||||
'fee_open': ANY,
|
'fee_open': ANY,
|
||||||
@ -141,7 +138,6 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
|
|||||||
'timeframe': ANY,
|
'timeframe': ANY,
|
||||||
'open_order_id': ANY,
|
'open_order_id': ANY,
|
||||||
'close_date': None,
|
'close_date': None,
|
||||||
'close_date_hum': None,
|
|
||||||
'close_timestamp': None,
|
'close_timestamp': None,
|
||||||
'open_rate': 1.098e-05,
|
'open_rate': 1.098e-05,
|
||||||
'close_rate': None,
|
'close_rate': None,
|
||||||
|
@ -755,7 +755,6 @@ def test_api_status(botclient, mocker, ticker, fee, markets):
|
|||||||
'amount_requested': 123.0,
|
'amount_requested': 123.0,
|
||||||
'base_currency': 'BTC',
|
'base_currency': 'BTC',
|
||||||
'close_date': None,
|
'close_date': None,
|
||||||
'close_date_hum': None,
|
|
||||||
'close_timestamp': None,
|
'close_timestamp': None,
|
||||||
'close_profit': None,
|
'close_profit': None,
|
||||||
'close_profit_pct': None,
|
'close_profit_pct': None,
|
||||||
@ -770,7 +769,6 @@ def test_api_status(botclient, mocker, ticker, fee, markets):
|
|||||||
'profit_fiat': ANY,
|
'profit_fiat': ANY,
|
||||||
'current_rate': 1.099e-05,
|
'current_rate': 1.099e-05,
|
||||||
'open_date': ANY,
|
'open_date': ANY,
|
||||||
'open_date_hum': ANY,
|
|
||||||
'open_timestamp': ANY,
|
'open_timestamp': ANY,
|
||||||
'open_order': None,
|
'open_order': None,
|
||||||
'open_rate': 0.123,
|
'open_rate': 0.123,
|
||||||
@ -922,11 +920,9 @@ def test_api_forcebuy(botclient, mocker, fee):
|
|||||||
'amount_requested': 1,
|
'amount_requested': 1,
|
||||||
'trade_id': 22,
|
'trade_id': 22,
|
||||||
'close_date': None,
|
'close_date': None,
|
||||||
'close_date_hum': None,
|
|
||||||
'close_timestamp': None,
|
'close_timestamp': None,
|
||||||
'close_rate': 0.265441,
|
'close_rate': 0.265441,
|
||||||
'open_date': ANY,
|
'open_date': ANY,
|
||||||
'open_date_hum': 'just now',
|
|
||||||
'open_timestamp': ANY,
|
'open_timestamp': ANY,
|
||||||
'open_rate': 0.245441,
|
'open_rate': 0.245441,
|
||||||
'pair': 'ETH/ETH',
|
'pair': 'ETH/ETH',
|
||||||
|
@ -177,9 +177,7 @@ def test_telegram_status(default_conf, update, mocker) -> None:
|
|||||||
'pair': 'ETH/BTC',
|
'pair': 'ETH/BTC',
|
||||||
'base_currency': 'BTC',
|
'base_currency': 'BTC',
|
||||||
'open_date': arrow.utcnow(),
|
'open_date': arrow.utcnow(),
|
||||||
'open_date_hum': arrow.utcnow().humanize,
|
|
||||||
'close_date': None,
|
'close_date': None,
|
||||||
'close_date_hum': None,
|
|
||||||
'open_rate': 1.099e-05,
|
'open_rate': 1.099e-05,
|
||||||
'close_rate': None,
|
'close_rate': None,
|
||||||
'current_rate': 1.098e-05,
|
'current_rate': 1.098e-05,
|
||||||
|
@ -799,11 +799,9 @@ def test_to_json(default_conf, fee):
|
|||||||
assert result == {'trade_id': None,
|
assert result == {'trade_id': None,
|
||||||
'pair': 'ETH/BTC',
|
'pair': 'ETH/BTC',
|
||||||
'is_open': None,
|
'is_open': None,
|
||||||
'open_date_hum': '2 hours ago',
|
|
||||||
'open_date': trade.open_date.strftime("%Y-%m-%d %H:%M:%S"),
|
'open_date': trade.open_date.strftime("%Y-%m-%d %H:%M:%S"),
|
||||||
'open_timestamp': int(trade.open_date.timestamp() * 1000),
|
'open_timestamp': int(trade.open_date.timestamp() * 1000),
|
||||||
'open_order_id': 'dry_run_buy_12345',
|
'open_order_id': 'dry_run_buy_12345',
|
||||||
'close_date_hum': None,
|
|
||||||
'close_date': None,
|
'close_date': None,
|
||||||
'close_timestamp': None,
|
'close_timestamp': None,
|
||||||
'open_rate': 0.123,
|
'open_rate': 0.123,
|
||||||
@ -865,10 +863,8 @@ def test_to_json(default_conf, fee):
|
|||||||
|
|
||||||
assert result == {'trade_id': None,
|
assert result == {'trade_id': None,
|
||||||
'pair': 'XRP/BTC',
|
'pair': 'XRP/BTC',
|
||||||
'open_date_hum': '2 hours ago',
|
|
||||||
'open_date': trade.open_date.strftime("%Y-%m-%d %H:%M:%S"),
|
'open_date': trade.open_date.strftime("%Y-%m-%d %H:%M:%S"),
|
||||||
'open_timestamp': int(trade.open_date.timestamp() * 1000),
|
'open_timestamp': int(trade.open_date.timestamp() * 1000),
|
||||||
'close_date_hum': 'an hour ago',
|
|
||||||
'close_date': trade.close_date.strftime("%Y-%m-%d %H:%M:%S"),
|
'close_date': trade.close_date.strftime("%Y-%m-%d %H:%M:%S"),
|
||||||
'close_timestamp': int(trade.close_date.timestamp() * 1000),
|
'close_timestamp': int(trade.close_date.timestamp() * 1000),
|
||||||
'open_rate': 0.123,
|
'open_rate': 0.123,
|
||||||
|
Loading…
Reference in New Issue
Block a user