2020-12-25 19:07:12 +00:00
|
|
|
from freqtrade.rpc import RPC
|
2020-12-25 12:08:25 +00:00
|
|
|
from fastapi import APIRouter, Depends
|
2020-12-24 05:55:19 +00:00
|
|
|
|
2020-12-25 12:11:01 +00:00
|
|
|
from freqtrade import __version__
|
|
|
|
|
2020-12-25 19:07:12 +00:00
|
|
|
from .api_models import Balances, Ping, StatusMsg, Version
|
2020-12-25 12:11:01 +00:00
|
|
|
from .deps import get_config, get_rpc
|
|
|
|
|
2020-12-24 05:55:19 +00:00
|
|
|
|
2020-12-25 12:08:25 +00:00
|
|
|
# Public API, requires no auth.
|
|
|
|
router_public = APIRouter()
|
2020-12-25 12:11:01 +00:00
|
|
|
# Private API, protected by authentication
|
2020-12-24 05:55:19 +00:00
|
|
|
router = APIRouter()
|
|
|
|
|
|
|
|
|
2020-12-25 12:08:25 +00:00
|
|
|
@router_public.get('/ping', response_model=Ping)
|
|
|
|
def ping():
|
2020-12-24 05:55:19 +00:00
|
|
|
"""simple ping version"""
|
|
|
|
return {"status": "pong"}
|
|
|
|
|
|
|
|
|
2020-12-25 19:07:12 +00:00
|
|
|
@router.get('/version', response_model=Version, tags=['info'])
|
2020-12-25 14:57:05 +00:00
|
|
|
def version():
|
|
|
|
return {"version": __version__}
|
|
|
|
|
|
|
|
|
2020-12-25 19:07:12 +00:00
|
|
|
@router.get('/balance', response_model=Balances, tags=['info'])
|
|
|
|
def balance(rpc: RPC = Depends(get_rpc), config=Depends(get_config)):
|
2020-12-25 12:08:25 +00:00
|
|
|
return rpc._rpc_balance(config['stake_currency'], config.get('fiat_display_currency', ''),)
|
2020-12-25 12:11:01 +00:00
|
|
|
|
|
|
|
|
2020-12-25 19:07:12 +00:00
|
|
|
@router.post('/start', response_model=StatusMsg, tags=['botcontrol'])
|
|
|
|
def start(rpc: RPC = Depends(get_rpc)):
|
|
|
|
return rpc._rpc_start()
|
|
|
|
|
|
|
|
|
|
|
|
@router.post('/stop', response_model=StatusMsg, tags=['botcontrol'])
|
|
|
|
def stop(rpc: RPC = Depends(get_rpc)):
|
|
|
|
return rpc._rpc_stop()
|