Add api_version to botresponse

This commit is contained in:
Matthias 2021-11-23 07:06:53 +01:00
parent 0d082f7b17
commit b8cefd687e
3 changed files with 11 additions and 1 deletions

View File

@ -144,6 +144,7 @@ class OrderTypes(BaseModel):
class ShowConfig(BaseModel): class ShowConfig(BaseModel):
version: str version: str
api_version: float
dry_run: bool dry_run: bool
stake_currency: str stake_currency: str
stake_amount: Union[float, str] stake_amount: Union[float, str]

View File

@ -26,6 +26,11 @@ from freqtrade.rpc.rpc import RPCException
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
# API version
# Pre-1.1, no version was provided
# Version increments should happen in "small" steps (1.1, 1.12, ...) unless big changes happen.
API_VERSION = 1.1
# Public API, requires no auth. # Public API, requires no auth.
router_public = APIRouter() router_public = APIRouter()
# Private API, protected by authentication # Private API, protected by authentication
@ -117,7 +122,9 @@ def show_config(rpc: Optional[RPC] = Depends(get_rpc_optional), config=Depends(g
state = '' state = ''
if rpc: if rpc:
state = rpc._freqtrade.state state = rpc._freqtrade.state
return RPC._rpc_show_config(config, state) resp = RPC._rpc_show_config(config, state)
resp['api_version'] = API_VERSION
return resp
@router.post('/forcebuy', response_model=ForceBuyResponse, tags=['trading']) @router.post('/forcebuy', response_model=ForceBuyResponse, tags=['trading'])

View File

@ -538,6 +538,8 @@ def test_api_show_config(botclient):
assert 'ask_strategy' in rc.json() assert 'ask_strategy' in rc.json()
assert 'unfilledtimeout' in rc.json() assert 'unfilledtimeout' in rc.json()
assert 'version' in rc.json() assert 'version' in rc.json()
assert 'api_version' in rc.json()
assert 1.1 <= rc.json()['api_version'] <= 1.2
def test_api_daily(botclient, mocker, ticker, fee, markets): def test_api_daily(botclient, mocker, ticker, fee, markets):