From c0c1ccde8b67b1148074f7038981fbf5bb7e99dd Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Thu, 1 Dec 2022 20:36:09 +0000 Subject: [PATCH] Add schemas for more commands --- core/lib/schemas/oanda_s.py | 133 +++++++++++++++++++++++++++++++++++- 1 file changed, 132 insertions(+), 1 deletion(-) diff --git a/core/lib/schemas/oanda_s.py b/core/lib/schemas/oanda_s.py index 9005b21..3dd9763 100644 --- a/core/lib/schemas/oanda_s.py +++ b/core/lib/schemas/oanda_s.py @@ -270,7 +270,7 @@ class PositionDetailsNested(BaseModel): dividendAdjustment: str guaranteedExecutionFees: str unrealizedPL: str - marginUsed: str + marginUsed: str | None class PositionDetails(BaseModel): @@ -459,3 +459,134 @@ PricingInfoSchema = { ], ), } + + +class LongPositionCloseout(BaseModel): + instrument: str + units: str + + +class Trade(BaseModel): + tradeID: str + clientTradeID: str + units: str + realizedPL: str + financing: str + baseFinancing: str + price: str + guaranteedExecutionFee: str + quoteGuaranteedExecutionFee: str + halfSpreadCost: str + + +class HomeConversionFactors(BaseModel): + gainQuoteHome: str + lossQuoteHome: str + gainBaseHome: str + lossBaseHome: str + + +class LongOrderFillTransaction(BaseModel): + id: str + accountID: str + userID: int + batchID: str + requestID: str + time: str + type: str + orderID: str + instrument: str + units: str + requestedUnits: str + price: str + pl: str + quotePL: str + financing: str + baseFinancing: str + commission: str + accountBalance: str + gainQuoteHomeConversionFactor: str + lossQuoteHomeConversionFactor: str + guaranteedExecutionFee: str + quoteGuaranteedExecutionFee: str + halfSpreadCost: str + fullVWAP: str + reason: str + tradesClosed: list[Trade] + fullPrice: Price + homeConversionFactors: HomeConversionFactors + longPositionCloseout: LongPositionCloseout + + +class OrderTransation(BaseModel): + id: str + accountID: str + userID: int + batchID: str + requestID: str + time: str + type: str + instrument: str + units: str + timeInForce: str + positionFill: str + reason: str + longPositionCloseout: LongPositionCloseout + longOrderFillTransaction: dict + + +class PositionClose(BaseModel): + longOrderCreateTransaction: OrderTransaction + longOrderFillTransaction: OrderTransaction + longOrderCancelTransaction: OrderTransaction + shortOrderCreateTransaction: OrderTransaction + shortOrderFillTransaction: OrderTransaction + shortOrderCancelTransaction: OrderTransaction + relatedTransactionIDs: list[str] + lastTransactionID: str + + +PositionCloseSchema = { + "longOrderCreateTransaction": "longOrderCreateTransaction", + "longOrderFillTransaction": "longOrderFillTransaction", + "longOrderCancelTransaction": "longOrderCancelTransaction", + "shortOrderCreateTransaction": "shortOrderCreateTransaction", + "shortOrderFillTransaction": "shortOrderFillTransaction", + "shortOrderCancelTransaction": "shortOrderCancelTransaction", + "relatedTransactionIDs": "relatedTransactionIDs", + "lastTransactionID": "lastTransactionID", +} + + +class ClientExtensions(BaseModel): + id: str + tag: str + + +class TradeDetailsTrade(BaseModel): + id: str + instrument: str + price: str + openTime: str + initialUnits: str + initialMarginRequired: str + state: str + currentUnits: str + realizedPL: str + closingTransactionIDs: list[str] + financing: str + dividendAdjustment: str + closeTime: str + averageClosePrice: str + clientExtensions: ClientExtensions + + +class TradeDetails(BaseModel): + trade: TradeDetailsTrade + lastTransactionID: str + + +TradeDetailsSchema = { + "trade": "trade", + "lastTransactionID": "lastTransactionID", +}