Begin implementing get all open trades

master
Mark Veidemanis 1 year ago
parent b818e7e3f5
commit a18c150fe2
Signed by: m
GPG Key ID: 5ACFCEED46C0904F

@ -218,6 +218,10 @@ class BaseExchange(ABC):
def get_all_positions(self):
pass
@abstractmethod
def get_all_open_trades(self):
pass
@abstractmethod
def close_position(self, side, symbol):
pass

@ -129,6 +129,10 @@ class OANDAExchange(BaseExchange):
items.append(item)
return items
def get_all_open_trades(self):
r = trades.OpenTrades(accountID=self.account_id)
return self.call(r)
def close_position(self, side, symbol):
data = {
f"{side}Units": "ALL",

@ -492,6 +492,65 @@ class Trade(BaseModel):
guaranteedExecutionFee: str
quoteGuaranteedExecutionFee: str
halfSpreadCost: str
# takeProfitOrder: TakeProfitOrder | None
takeProfitOrder: dict | None
stopLossOrder: dict | None
trailingStopLossOrder: dict | None
{
"trades": [
{
"id": "14480",
"instrument": "EUR_USD",
"price": "1.06345",
"openTime": "2022-12-22T08:57:10.459593310Z",
"initialUnits": "100",
"initialMarginRequired": "2.9226",
"state": "OPEN",
"currentUnits": "100",
"realizedPL": "0.0000",
"financing": "0.0000",
"dividendAdjustment": "0.0000",
"unrealizedPL": "-0.0158",
"marginUsed": "2.9228",
}
],
"lastTransactionID": "14480",
}
class OpenTrades(BaseModel):
trades: list[Trade]
lastTransactionID: str
OpenTradesSchema = {
"itemlist": (
"trades",
[
{
"id": "tradeID",
"instrument": "instrument",
"price": "price",
"openTime": "openTime",
"initialUnits": "initialUnits",
"initialMarginRequired": "initialMarginRequired",
"state": "state",
"currentUnits": "currentUnits",
"realizedPL": "realizedPL",
"financing": "financing",
"dividendAdjustment": "dividendAdjustment",
"unrealizedPL": "unrealizedPL",
"marginUsed": "marginUsed",
"takeProfitOrder": "takeProfitOrder",
"stopLossOrder": "stopLossOrder",
"trailingStopLossOrder": "trailingStopLossOrder",
}
],
),
"lastTransactionID": "lastTransactionID",
}
class HomeConversionFactors(BaseModel):

Loading…
Cancel
Save