Don't use separate position field in /currency endpoint
This commit is contained in:
parent
4b27bd9838
commit
a2b17882e6
@ -39,6 +39,11 @@ class Balance(BaseModel):
|
|||||||
used: float
|
used: float
|
||||||
est_stake: float
|
est_stake: float
|
||||||
stake: str
|
stake: str
|
||||||
|
# Starting with 2.x
|
||||||
|
side: str
|
||||||
|
leverage: float
|
||||||
|
is_position: bool
|
||||||
|
position: float
|
||||||
|
|
||||||
|
|
||||||
class Balances(BaseModel):
|
class Balances(BaseModel):
|
||||||
|
@ -609,6 +609,10 @@ class RPC:
|
|||||||
'used': balance.used if balance.used is not None else 0,
|
'used': balance.used if balance.used is not None else 0,
|
||||||
'est_stake': est_stake or 0,
|
'est_stake': est_stake or 0,
|
||||||
'stake': stake_currency,
|
'stake': stake_currency,
|
||||||
|
'side': 'long',
|
||||||
|
'leverage': 1,
|
||||||
|
'position': 0,
|
||||||
|
'is_position': False,
|
||||||
})
|
})
|
||||||
symbol: str
|
symbol: str
|
||||||
position: PositionWallet
|
position: PositionWallet
|
||||||
@ -617,22 +621,14 @@ class RPC:
|
|||||||
currencies.append({
|
currencies.append({
|
||||||
'currency': symbol,
|
'currency': symbol,
|
||||||
'free': 0,
|
'free': 0,
|
||||||
'balance': position.position,
|
'balance': 0,
|
||||||
'used': 0,
|
'used': 0,
|
||||||
'est_stake': position.collateral,
|
|
||||||
'stake': stake_currency,
|
|
||||||
})
|
|
||||||
|
|
||||||
positions.append({
|
|
||||||
'currency': symbol,
|
|
||||||
# 'free': balance.free if balance.free is not None else 0,
|
|
||||||
# 'balance': balance.total if balance.total is not None else 0,
|
|
||||||
# 'used': balance.used if balance.used is not None else 0,
|
|
||||||
'position': position.position,
|
'position': position.position,
|
||||||
'side': position.side,
|
|
||||||
'est_stake': position.collateral,
|
'est_stake': position.collateral,
|
||||||
'leverage': position.leverage,
|
|
||||||
'stake': stake_currency,
|
'stake': stake_currency,
|
||||||
|
'leverage': position.leverage,
|
||||||
|
'side': position.side,
|
||||||
|
'is_position': True
|
||||||
})
|
})
|
||||||
|
|
||||||
value = self._fiat_converter.convert_amount(
|
value = self._fiat_converter.convert_amount(
|
||||||
@ -645,7 +641,6 @@ class RPC:
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
'currencies': currencies,
|
'currencies': currencies,
|
||||||
'positions': positions,
|
|
||||||
'total': total,
|
'total': total,
|
||||||
'symbol': fiat_display_currency,
|
'symbol': fiat_display_currency,
|
||||||
'value': value,
|
'value': value,
|
||||||
|
@ -827,13 +827,21 @@ class Telegram(RPCHandler):
|
|||||||
for curr in result['currencies']:
|
for curr in result['currencies']:
|
||||||
curr_output = ''
|
curr_output = ''
|
||||||
if curr['est_stake'] > balance_dust_level:
|
if curr['est_stake'] > balance_dust_level:
|
||||||
curr_output = (
|
if curr['is_position']:
|
||||||
f"*{curr['currency']}:*\n"
|
curr_output = (
|
||||||
f"\t`Available: {curr['free']:.8f}`\n"
|
f"*{curr['currency']}:*\n"
|
||||||
f"\t`Balance: {curr['balance']:.8f}`\n"
|
f"\t`{curr['side']}: {curr['position']:.8f}`\n"
|
||||||
f"\t`Pending: {curr['used']:.8f}`\n"
|
f"\t`Leverage: {curr['leverage']:.1f}`\n"
|
||||||
f"\t`Est. {curr['stake']}: "
|
f"\t`Est. {curr['stake']}: "
|
||||||
f"{round_coin_value(curr['est_stake'], curr['stake'], False)}`\n")
|
f"{round_coin_value(curr['est_stake'], curr['stake'], False)}`\n")
|
||||||
|
else:
|
||||||
|
curr_output = (
|
||||||
|
f"*{curr['currency']}:*\n"
|
||||||
|
f"\t`Available: {curr['free']:.8f}`\n"
|
||||||
|
f"\t`Balance: {curr['balance']:.8f}`\n"
|
||||||
|
f"\t`Pending: {curr['used']:.8f}`\n"
|
||||||
|
f"\t`Est. {curr['stake']}: "
|
||||||
|
f"{round_coin_value(curr['est_stake'], curr['stake'], False)}`\n")
|
||||||
elif curr['est_stake'] <= balance_dust_level:
|
elif curr['est_stake'] <= balance_dust_level:
|
||||||
total_dust_balance += curr['est_stake']
|
total_dust_balance += curr['est_stake']
|
||||||
total_dust_currencies += 1
|
total_dust_currencies += 1
|
||||||
|
@ -118,8 +118,10 @@ class Wallets:
|
|||||||
for currency in deepcopy(self._wallets):
|
for currency in deepcopy(self._wallets):
|
||||||
if currency not in balances:
|
if currency not in balances:
|
||||||
del self._wallets[currency]
|
del self._wallets[currency]
|
||||||
|
|
||||||
# TODO-lev: Implement dry-run/backtest counterpart
|
# TODO-lev: Implement dry-run/backtest counterpart
|
||||||
positions = self._exchange.get_positions()
|
positions = self._exchange.get_positions()
|
||||||
|
self._positions = []
|
||||||
for position in positions:
|
for position in positions:
|
||||||
symbol = position['symbol']
|
symbol = position['symbol']
|
||||||
if position['side'] is None or position['collateral'] == 0.0:
|
if position['side'] is None or position['collateral'] == 0.0:
|
||||||
|
Loading…
Reference in New Issue
Block a user