Add more hooks to active management
This commit is contained in:
@@ -46,6 +46,20 @@ class OpenPositions(BaseModel):
|
||||
lastTransactionID: str
|
||||
|
||||
|
||||
def parse_time(x):
|
||||
"""
|
||||
Parse the time from the Oanda API.
|
||||
"""
|
||||
if "openTime" in x:
|
||||
ts_split = x["openTime"].split(".")
|
||||
else:
|
||||
ts_split = x["trade"]["openTime"].split(".")
|
||||
microseconds = ts_split[1].replace("Z", "")
|
||||
microseconds_6 = microseconds[:6]
|
||||
new_ts = ts_split[0] + "." + microseconds_6 + "Z"
|
||||
return new_ts
|
||||
|
||||
|
||||
def prevent_hedging(x):
|
||||
"""
|
||||
Our implementation breaks if a position has both.
|
||||
@@ -522,7 +536,7 @@ OpenTradesSchema = {
|
||||
"id": "id",
|
||||
"symbol": "instrument",
|
||||
"price": "price",
|
||||
"openTime": "openTime",
|
||||
"openTime": parse_time,
|
||||
"initialUnits": "initialUnits",
|
||||
"initialMarginRequired": "initialMarginRequired",
|
||||
"state": "state",
|
||||
@@ -680,7 +694,7 @@ TradeDetailsSchema = {
|
||||
"id": "trade.id",
|
||||
"symbol": "trade.instrument",
|
||||
"price": "trade.price",
|
||||
"openTime": "trade.openTime",
|
||||
"openTime": parse_time,
|
||||
"initialUnits": "trade.initialUnits",
|
||||
"initialMarginRequired": "trade.initialMarginRequired",
|
||||
"state": "trade.state",
|
||||
|
||||
Reference in New Issue
Block a user