Move json to persistence
This commit is contained in:
parent
1e056ee415
commit
31d271084f
@ -214,11 +214,15 @@ class Trade(_DECL_BASE):
|
|||||||
f'open_rate={self.open_rate:.8f}, open_since={open_since})')
|
f'open_rate={self.open_rate:.8f}, open_since={open_since})')
|
||||||
|
|
||||||
def to_json(self) -> Dict[str, Any]:
|
def to_json(self) -> Dict[str, Any]:
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'trade_id': self.id,
|
'trade_id': self.id,
|
||||||
'pair': self.pair,
|
'pair': self.pair,
|
||||||
'date': arrow.get(self.open_date),
|
'open_date_hum': arrow.get(self.open_date).humanize(),
|
||||||
|
'open_date': self.open_date.strftime("%Y-%m-%d %H:%M:%S"),
|
||||||
|
'close_date_hum': (arrow.get(self.close_date).humanize()
|
||||||
|
if self.close_date else None),
|
||||||
|
'close_date': (self.close_date.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
if self.close_date else None),
|
||||||
'open_rate': self.open_rate,
|
'open_rate': self.open_rate,
|
||||||
'close_rate': self.close_rate,
|
'close_rate': self.close_rate,
|
||||||
'amount': round(self.amount, 8),
|
'amount': round(self.amount, 8),
|
||||||
@ -226,8 +230,8 @@ class Trade(_DECL_BASE):
|
|||||||
'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),
|
||||||
}
|
}
|
||||||
|
|
||||||
def adjust_min_max_rates(self, current_price: float):
|
def adjust_min_max_rates(self, current_price: float):
|
||||||
|
@ -193,14 +193,11 @@ 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 = []
|
||||||
for r in results:
|
for r in results:
|
||||||
lines = [
|
lines = [
|
||||||
"*Trade ID:* `{trade_id}` `(since {date})`",
|
"*Trade ID:* `{trade_id}` `(since {open_date_hum})`",
|
||||||
"*Current Pair:* {pair}",
|
"*Current Pair:* {pair}",
|
||||||
"*Amount:* `{amount} ({stake_amount} {base_currency})`",
|
"*Amount:* `{amount} ({stake_amount} {base_currency})`",
|
||||||
"*Open Rate:* `{open_rate:.8f}`",
|
"*Open Rate:* `{open_rate:.8f}`",
|
||||||
|
Loading…
Reference in New Issue
Block a user