Allow forcebuy to specify order_type

This commit is contained in:
Matthias
2021-11-24 20:11:04 +01:00
parent 65906d330f
commit 338fe333a9
5 changed files with 30 additions and 17 deletions

View File

@@ -1,4 +1,5 @@
from datetime import date, datetime
from enum import Enum
from typing import Any, Dict, List, Optional, Union
from pydantic import BaseModel
@@ -131,13 +132,21 @@ class UnfilledTimeout(BaseModel):
exit_timeout_count: Optional[int]
class OrderTypeValues(Enum):
limit = 'limit'
market = 'market'
class Config:
use_enum_values = True
class OrderTypes(BaseModel):
buy: str
sell: str
emergencysell: Optional[str]
forcesell: Optional[str]
forcebuy: Optional[str]
stoploss: str
buy: OrderTypeValues
sell: OrderTypeValues
emergencysell: Optional[OrderTypeValues]
forcesell: Optional[OrderTypeValues]
forcebuy: Optional[OrderTypeValues]
stoploss: OrderTypeValues
stoploss_on_exchange: bool
stoploss_on_exchange_interval: Optional[int]
@@ -274,6 +283,7 @@ class Logs(BaseModel):
class ForceBuyPayload(BaseModel):
pair: str
price: Optional[float]
ordertype: Optional[OrderTypeValues]
class ForceSellPayload(BaseModel):

View File

@@ -29,7 +29,8 @@ 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
# 1.11: forcebuy accepts new option with ordertype
API_VERSION = 1.11
# Public API, requires no auth.
router_public = APIRouter()
@@ -129,7 +130,7 @@ def show_config(rpc: Optional[RPC] = Depends(get_rpc_optional), config=Depends(g
@router.post('/forcebuy', response_model=ForceBuyResponse, tags=['trading'])
def forcebuy(payload: ForceBuyPayload, rpc: RPC = Depends(get_rpc)):
trade = rpc._rpc_forcebuy(payload.pair, payload.price)
trade = rpc._rpc_forcebuy(payload.pair, payload.price, payload.ordertype)
if trade:
return ForceBuyResponse.parse_obj(trade.to_json())