rpc refactor 6/
This commit is contained in:
parent
3bc1b37528
commit
4af0b18af1
@ -7,7 +7,7 @@ from pandas import DataFrame
|
|||||||
import sqlalchemy as sql
|
import sqlalchemy as sql
|
||||||
|
|
||||||
from freqtrade.persistence import Trade
|
from freqtrade.persistence import Trade
|
||||||
from freqtrade.misc import State, get_state
|
from freqtrade.misc import State, get_state, update_state
|
||||||
from freqtrade import exchange
|
from freqtrade import exchange
|
||||||
from freqtrade.fiat_convert import CryptoToFiatConverter
|
from freqtrade.fiat_convert import CryptoToFiatConverter
|
||||||
from . import telegram
|
from . import telegram
|
||||||
@ -334,3 +334,24 @@ def rpc_balance(fiat_display_currency):
|
|||||||
symbol = fiat_display_currency
|
symbol = fiat_display_currency
|
||||||
value = fiat.convert_amount(total, 'BTC', symbol)
|
value = fiat.convert_amount(total, 'BTC', symbol)
|
||||||
return (False, (output, total, symbol, value))
|
return (False, (output, total, symbol, value))
|
||||||
|
|
||||||
|
|
||||||
|
def rpc_start():
|
||||||
|
"""
|
||||||
|
Handler for start.
|
||||||
|
"""
|
||||||
|
if get_state() == State.RUNNING:
|
||||||
|
return (True, '*Status:* `already running`')
|
||||||
|
else:
|
||||||
|
update_state(State.RUNNING)
|
||||||
|
|
||||||
|
|
||||||
|
def rpc_stop():
|
||||||
|
"""
|
||||||
|
Handler for stop.
|
||||||
|
"""
|
||||||
|
if get_state() == State.RUNNING:
|
||||||
|
update_state(State.STOPPED)
|
||||||
|
return (False, '`Stopping trader ...`')
|
||||||
|
else:
|
||||||
|
return (True, '*Status:* `already stopped`')
|
||||||
|
@ -11,13 +11,15 @@ from freqtrade.rpc.__init__ import (rpc_status_table,
|
|||||||
rpc_trade_status,
|
rpc_trade_status,
|
||||||
rpc_daily_profit,
|
rpc_daily_profit,
|
||||||
rpc_trade_statistics,
|
rpc_trade_statistics,
|
||||||
rpc_balance
|
rpc_balance,
|
||||||
|
rpc_start,
|
||||||
|
rpc_stop
|
||||||
)
|
)
|
||||||
|
|
||||||
from freqtrade import __version__, exchange
|
from freqtrade import __version__, exchange
|
||||||
from freqtrade.fiat_convert import CryptoToFiatConverter
|
from freqtrade.fiat_convert import CryptoToFiatConverter
|
||||||
from freqtrade.misc import State, get_state, update_state
|
|
||||||
from freqtrade.persistence import Trade
|
from freqtrade.persistence import Trade
|
||||||
|
from freqtrade.misc import State, get_state
|
||||||
|
|
||||||
|
|
||||||
# Remove noisy log messages
|
# Remove noisy log messages
|
||||||
@ -276,10 +278,9 @@ def _start(bot: Bot, update: Update) -> None:
|
|||||||
:param update: message update
|
:param update: message update
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
if get_state() == State.RUNNING:
|
(error, msg) = rpc_start()
|
||||||
send_msg('*Status:* `already running`', bot=bot)
|
if error:
|
||||||
else:
|
send_msg(msg, bot=bot)
|
||||||
update_state(State.RUNNING)
|
|
||||||
|
|
||||||
|
|
||||||
@authorized_only
|
@authorized_only
|
||||||
@ -291,11 +292,8 @@ def _stop(bot: Bot, update: Update) -> None:
|
|||||||
:param update: message update
|
:param update: message update
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
if get_state() == State.RUNNING:
|
(error, msg) = rpc_stop()
|
||||||
send_msg('`Stopping trader ...`', bot=bot)
|
send_msg(msg, bot=bot)
|
||||||
update_state(State.STOPPED)
|
|
||||||
else:
|
|
||||||
send_msg('*Status:* `already stopped`', bot=bot)
|
|
||||||
|
|
||||||
|
|
||||||
@authorized_only
|
@authorized_only
|
||||||
|
Loading…
Reference in New Issue
Block a user