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
instrument: str
units: str
timeInForce: str
positionFill: str
timeInForce: str | None
positionFill: str | None
reason: str
longPositionCloseout: LongPositionCloseout
longOrderFillTransaction: dict
class PositionClose(BaseModel):
longOrderCreateTransaction: OrderTransaction
longOrderFillTransaction: OrderTransaction
longOrderCancelTransaction: OrderTransaction
shortOrderCreateTransaction: OrderTransaction
shortOrderFillTransaction: OrderTransaction
shortOrderCancelTransaction: OrderTransaction
longOrderCreateTransaction: OrderTransaction | None
longOrderFillTransaction: OrderTransaction | None
longOrderCancelTransaction: OrderTransaction | None
shortOrderCreateTransaction: OrderTransaction | None
shortOrderFillTransaction: OrderTransaction | None
shortOrderCancelTransaction: OrderTransaction | None
relatedTransactionIDs: list[str]
lastTransactionID: str

View File

@ -89,8 +89,11 @@ class HookAPI(APIView):
return HttpResponseBadRequest("Hook does not exist.")
# 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:
signal = Signal.objects.get(signal=hook_resp.title)
signal = Signal.objects.get(signal=signal_name)
except Signal.DoesNotExist:
return HttpResponseBadRequest("Signal does not exist.")