Fix changed OANDA API

This commit is contained in:
Mark Veidemanis 2024-06-10 06:42:46 +01:00
parent a788a65ba6
commit 95a4a6930c
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 42 additions and 42 deletions

View File

@ -1,29 +1,29 @@
from decimal import Decimal as D
from pydantic import BaseModel
from typing import Optional
class PositionLong(BaseModel):
units: str
averagePrice: str | None
averagePrice: Optional[str] = None
pl: str
resettablePL: str
financing: str
dividendAdjustment: str
guaranteedExecutionFees: str
tradeIDs: list[str] | None
tradeIDs: Optional[list[str]] = []
unrealizedPL: str
class PositionShort(BaseModel):
units: str
averagePrice: str | None
averagePrice: Optional[str] = None
pl: str
resettablePL: str
financing: str
dividendAdjustment: str
guaranteedExecutionFees: str
tradeIDs: list[str] | None
tradeIDs: Optional[list[str]] = []
unrealizedPL: str
@ -306,7 +306,7 @@ class PositionDetailsNested(BaseModel):
dividendAdjustment: str
guaranteedExecutionFees: str
unrealizedPL: str
marginUsed: str | None
marginUsed: Optional[str] = None
class PositionDetails(BaseModel):
@ -373,7 +373,7 @@ class Instrument(BaseModel):
guaranteedStopLossOrderMode: str
tags: list[InstrumentTag]
financing: InstrumentFinancing
guaranteedStopLossOrderLevelRestriction: InstrumentGuaranteedRestriction | None
guaranteedStopLossOrderLevelRestriction: Optional[InstrumentGuaranteedRestriction] = None
class AccountInstruments(BaseModel):
@ -474,33 +474,33 @@ class Trade(BaseModel):
quoteGuaranteedExecutionFee: str
halfSpreadCost: str
# takeProfitOrder: TakeProfitOrder | None
takeProfitOrder: dict | None
stopLossOrder: dict | None
trailingStopLossOrder: dict | None
takeProfitOrder: Optional[dict] = None
stopLossOrder: Optional[dict] = None
trailingStopLossOrder: Optional[dict] = None
class SideCarOrder(BaseModel):
id: str
createTime: str
state: str
price: str | None
price: Optional[str] = None
timeInForce: str
gtdTime: str | None
clientExtensions: dict | None
gtdTime: Optional[str] = None
clientExtensions: Optional[dict] = None
tradeID: str
clientTradeID: str | None
clientTradeID: Optional[str] = None
type: str
time: str | None
priceBound: str | None
positionFill: str | None
reason: str | None
orderFillTransactionID: str | None
tradeOpenedID: str | None
tradeReducedID: str | None
tradeClosedIDs: list[str] | None
cancellingTransactionID: str | None
replacesOrderID: str | None
replacedByOrderID: str | None
time: Optional[str] = None
priceBound: Optional[str] = None
positionFill: Optional[str] = None
reason: Optional[str] = None
orderFillTransactionID: Optional[str] = None
tradeOpenedID: Optional[str] = None
tradeReducedID: Optional[str] = None
tradeClosedIDs: Optional[list[str]] = []
cancellingTransactionID: Optional[str] = None
replacesOrderID: Optional[str] = None
replacedByOrderID: Optional[str] = None
class OpenTradesTrade(BaseModel):
@ -517,10 +517,10 @@ class OpenTradesTrade(BaseModel):
dividendAdjustment: str
unrealizedPL: str
marginUsed: str
takeProfitOrder: SideCarOrder | None
stopLossOrder: SideCarOrder | None
trailingStopLossOrder: SideCarOrder | None
trailingStopValue: dict | None
takeProfitOrder: Optional[SideCarOrder] = None
stopLossOrder: Optional[SideCarOrder] = None
trailingStopLossOrder: Optional[SideCarOrder] = None
trailingStopValue: Optional[dict] = None
class OpenTrades(BaseModel):
@ -578,13 +578,13 @@ class OrderTransaction(BaseModel):
requestID: str
time: str
type: str
instrument: str | None
units: str | None
timeInForce: str | None
positionFill: str | None
instrument: Optional[str] = None
units: Optional[str] = None
timeInForce: Optional[str] = None
positionFill: Optional[str] = None
reason: str
longPositionCloseout: LongPositionCloseout | None
longOrderFillTransaction: dict | None
longOrderFillTransaction: Optional[dict] = None
class OrderCreate(BaseModel):
@ -677,12 +677,12 @@ class TradeDetailsTrade(BaseModel):
state: str
currentUnits: str
realizedPL: str
closingTransactionIDs: list[str] | None
closingTransactionIDs: Optional[list[str]] = []
financing: str
dividendAdjustment: str
closeTime: str | None
averageClosePrice: str | None
clientExtensions: ClientExtensions | None
closeTime: Optional[str] = None
averageClosePrice: Optional[str] = None
clientExtensions: Optional[ClientExtensions] = None
class TradeDetails(BaseModel):
@ -733,10 +733,10 @@ TradeCloseSchema = {
class TradeCRCDO(BaseModel):
takeProfitOrderCancelTransaction: OrderTransaction
takeProfitOrderTransaction: OrderTransaction
stopLossOrderCancelTransaction: OrderTransaction
stopLossOrderTransaction: OrderTransaction
takeProfitOrderCancelTransaction: Optional[OrderTransaction]
takeProfitOrderTransaction: Optional[OrderTransaction]
stopLossOrderCancelTransaction: Optional[OrderTransaction]
stopLossOrderTransaction: Optional[OrderTransaction]
relatedTransactionIDs: list[str]
lastTransactionID: str