status: return arrow object instead humanized str
This commit is contained in:
parent
0920fb6120
commit
7eaeb8d146
@ -69,7 +69,7 @@ class RPC(object):
|
|||||||
def send_msg(self, msg: Dict[str, str]) -> None:
|
def send_msg(self, msg: Dict[str, str]) -> None:
|
||||||
""" Sends a message to all registered rpc modules """
|
""" Sends a message to all registered rpc modules """
|
||||||
|
|
||||||
def _rpc_trade_status(self) -> List[Dict]:
|
def _rpc_trade_status(self) -> List[Dict[str, Any]]:
|
||||||
"""
|
"""
|
||||||
Below follows the RPC backend it is prefixed with rpc_ to raise awareness that it is
|
Below follows the RPC backend it is prefixed with rpc_ to raise awareness that it is
|
||||||
a remotely exposed function
|
a remotely exposed function
|
||||||
@ -95,7 +95,7 @@ class RPC(object):
|
|||||||
trade_id=trade.id,
|
trade_id=trade.id,
|
||||||
pair=trade.pair,
|
pair=trade.pair,
|
||||||
market_url=self._freqtrade.exchange.get_pair_detail_url(trade.pair),
|
market_url=self._freqtrade.exchange.get_pair_detail_url(trade.pair),
|
||||||
date=arrow.get(trade.open_date).humanize(),
|
date=arrow.get(trade.open_date),
|
||||||
open_rate=trade.open_rate,
|
open_rate=trade.open_rate,
|
||||||
close_rate=trade.close_rate,
|
close_rate=trade.close_rate,
|
||||||
current_rate=current_rate,
|
current_rate=current_rate,
|
||||||
|
@ -166,6 +166,10 @@ class Telegram(RPC):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
results = self._rpc_trade_status()
|
results = self._rpc_trade_status()
|
||||||
|
# pre format data
|
||||||
|
for result in results:
|
||||||
|
result['date'] = result['date'].humanize()
|
||||||
|
|
||||||
messages = [
|
messages = [
|
||||||
"*Trade ID:* `{trade_id}`\n"
|
"*Trade ID:* `{trade_id}`\n"
|
||||||
"*Current Pair:* [{pair}]({market_url})\n"
|
"*Current Pair:* [{pair}]({market_url})\n"
|
||||||
|
@ -5,7 +5,7 @@ Unit test file for rpc/rpc.py
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock, ANY
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, markets, mocker) -> None:
|
|||||||
'trade_id': 1,
|
'trade_id': 1,
|
||||||
'pair': 'ETH/BTC',
|
'pair': 'ETH/BTC',
|
||||||
'market_url': 'https://bittrex.com/Market/Index?MarketName=BTC-ETH',
|
'market_url': 'https://bittrex.com/Market/Index?MarketName=BTC-ETH',
|
||||||
'date': 'just now',
|
'date': ANY,
|
||||||
'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,
|
||||||
|
@ -11,6 +11,7 @@ from datetime import datetime
|
|||||||
from random import randint
|
from random import randint
|
||||||
from unittest.mock import MagicMock, ANY
|
from unittest.mock import MagicMock, ANY
|
||||||
|
|
||||||
|
import arrow
|
||||||
from telegram import Chat, Message, Update
|
from telegram import Chat, Message, Update
|
||||||
from telegram.error import NetworkError
|
from telegram.error import NetworkError
|
||||||
|
|
||||||
@ -198,6 +199,7 @@ def test_status(default_conf, update, mocker, fee, ticker, markets) -> None:
|
|||||||
|
|
||||||
patch_get_signal(mocker, (True, False))
|
patch_get_signal(mocker, (True, False))
|
||||||
patch_coinmarketcap(mocker)
|
patch_coinmarketcap(mocker)
|
||||||
|
|
||||||
mocker.patch.multiple(
|
mocker.patch.multiple(
|
||||||
'freqtrade.exchange.Exchange',
|
'freqtrade.exchange.Exchange',
|
||||||
validate_pairs=MagicMock(),
|
validate_pairs=MagicMock(),
|
||||||
@ -215,7 +217,7 @@ def test_status(default_conf, update, mocker, fee, ticker, markets) -> None:
|
|||||||
'trade_id': 1,
|
'trade_id': 1,
|
||||||
'pair': 'ETH/BTC',
|
'pair': 'ETH/BTC',
|
||||||
'market_url': 'https://bittrex.com/Market/Index?MarketName=BTC-ETH',
|
'market_url': 'https://bittrex.com/Market/Index?MarketName=BTC-ETH',
|
||||||
'date': 'just now',
|
'date': arrow.utcnow(),
|
||||||
'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,
|
||||||
|
Loading…
Reference in New Issue
Block a user