Get the right signal name from the callback and fix position close schema

This commit is contained in:
Mark Veidemanis 2022-12-02 07:20:37 +00:00
parent 848f69da5e
commit 077768975d
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
2 changed files with 12 additions and 9 deletions

View File

@ -528,20 +528,20 @@ class OrderTransation(BaseModel):
type: str type: str
instrument: str instrument: str
units: str units: str
timeInForce: str timeInForce: str | None
positionFill: str positionFill: str | None
reason: str reason: str
longPositionCloseout: LongPositionCloseout longPositionCloseout: LongPositionCloseout
longOrderFillTransaction: dict longOrderFillTransaction: dict
class PositionClose(BaseModel): class PositionClose(BaseModel):
longOrderCreateTransaction: OrderTransaction longOrderCreateTransaction: OrderTransaction | None
longOrderFillTransaction: OrderTransaction longOrderFillTransaction: OrderTransaction | None
longOrderCancelTransaction: OrderTransaction longOrderCancelTransaction: OrderTransaction | None
shortOrderCreateTransaction: OrderTransaction shortOrderCreateTransaction: OrderTransaction | None
shortOrderFillTransaction: OrderTransaction shortOrderFillTransaction: OrderTransaction | None
shortOrderCancelTransaction: OrderTransaction shortOrderCancelTransaction: OrderTransaction | None
relatedTransactionIDs: list[str] relatedTransactionIDs: list[str]
lastTransactionID: str lastTransactionID: str

View File

@ -89,8 +89,11 @@ class HookAPI(APIView):
return HttpResponseBadRequest("Hook does not exist.") return HttpResponseBadRequest("Hook does not exist.")
# Try getting the signal # Try getting the signal
# AUCAD 3M StochExit: C$2419.64 at OANDA
message_first_half = hook_resp.message.split(":")[0]
signal_name = message_first_half.split(" ")[-1]
try: try:
signal = Signal.objects.get(signal=hook_resp.title) signal = Signal.objects.get(signal=signal_name)
except Signal.DoesNotExist: except Signal.DoesNotExist:
return HttpResponseBadRequest("Signal does not exist.") return HttpResponseBadRequest("Signal does not exist.")