mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-14 12:13:57 +00:00
fb2c8f7621
This closes the transaction and avoids "sticking" transactions.
31 lines
696 B
Python
31 lines
696 B
Python
from typing import Any, Dict, Iterator, Optional
|
|
|
|
from freqtrade.persistence import Trade
|
|
from freqtrade.rpc.rpc import RPC, RPCException
|
|
|
|
from .webserver import ApiServer
|
|
|
|
|
|
def get_rpc_optional() -> Optional[RPC]:
|
|
if ApiServer._has_rpc:
|
|
return ApiServer._rpc
|
|
return None
|
|
|
|
|
|
def get_rpc() -> Optional[Iterator[RPC]]:
|
|
_rpc = get_rpc_optional()
|
|
if _rpc:
|
|
Trade.query.session.rollback()
|
|
yield _rpc
|
|
Trade.query.session.rollback()
|
|
else:
|
|
raise RPCException('Bot is not in the correct state')
|
|
|
|
|
|
def get_config() -> Dict[str, Any]:
|
|
return ApiServer._config
|
|
|
|
|
|
def get_api_config() -> Dict[str, Any]:
|
|
return ApiServer._config['api_server']
|