Check exchange name and remove redundant code, use IOC orders for OANDA
This commit is contained in:
parent
40f6330a13
commit
bf863f43b2
|
@ -43,7 +43,7 @@ class OANDAExchange(BaseExchange):
|
|||
# "price": "1.5000", - added later
|
||||
"stopLossOnFill": {"timeInForce": "GTC", "price": str(trade.stop_loss)},
|
||||
"takeProfitOnFill": {"price": str(trade.take_profit)},
|
||||
"timeInForce": "GTC",
|
||||
"timeInForce": "IOC",
|
||||
"instrument": trade.symbol,
|
||||
"units": str(amount),
|
||||
"type": trade.type.upper(),
|
||||
|
|
|
@ -7,24 +7,6 @@ from core.util import logs
|
|||
|
||||
log = logs.get_logger(__name__)
|
||||
|
||||
|
||||
def get_balance(account):
|
||||
account_info = account.client.get_account()
|
||||
cash = account_info["equity"]
|
||||
try:
|
||||
return float(cash)
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
|
||||
def get_market_value(account, symbol):
|
||||
try:
|
||||
position = account.client.get_position(symbol)
|
||||
return float(position["market_value"])
|
||||
except APIError:
|
||||
return False
|
||||
|
||||
|
||||
def execute_strategy(callback, strategy):
|
||||
cash_balance = strategy.account.client.get_balance()
|
||||
log.debug(f"Cash balance: {cash_balance}")
|
||||
|
@ -35,6 +17,9 @@ def execute_strategy(callback, strategy):
|
|||
base = callback.base
|
||||
quote = callback.quote
|
||||
direction = hook.direction
|
||||
if callback.exchange != account.exchange:
|
||||
log.error("Market exchange differs from account exchange.")
|
||||
return
|
||||
if account.exchange == "alpaca":
|
||||
if quote not in ["usd", "usdt", "usdc", "busd"]:
|
||||
log.error(f"Quote not compatible with Dollar: {quote}")
|
||||
|
|
|
@ -179,40 +179,6 @@ AccountDetailsSchema = {
|
|||
}
|
||||
|
||||
|
||||
{
|
||||
"account": {
|
||||
"marginCloseoutNAV": "35454.4740",
|
||||
"marginUsed": "10581.5000",
|
||||
"currency": "EUR",
|
||||
"resettablePL": "-13840.3525",
|
||||
"NAV": "35454.4740",
|
||||
"marginCloseoutMarginUsed": "10581.5000",
|
||||
"marginCloseoutPositionValue": "211630.0000",
|
||||
"openTradeCount": 2,
|
||||
"id": "101-004-1435156-001",
|
||||
"hedgingEnabled": False,
|
||||
"marginCloseoutPercent": "0.14923",
|
||||
"marginCallMarginUsed": "10581.5000",
|
||||
"openPositionCount": 1,
|
||||
"positionValue": "211630.0000",
|
||||
"pl": "-13840.3525",
|
||||
"lastTransactionID": "2123",
|
||||
"marginAvailable": "24872.9740",
|
||||
"marginRate": "0.05",
|
||||
"marginCallPercent": "0.29845",
|
||||
"pendingOrderCount": 0,
|
||||
"withdrawalLimit": "24872.9740",
|
||||
"unrealizedPL": "0.0000",
|
||||
"alias": "hootnotv20",
|
||||
"createdByUserID": 1435156,
|
||||
"marginCloseoutUnrealizedPL": "0.0000",
|
||||
"createdTime": "2016-06-24T21:03:50.914647476Z",
|
||||
"balance": "35454.4740",
|
||||
},
|
||||
"lastTransactionID": "2123",
|
||||
}
|
||||
|
||||
|
||||
class AccountSummaryNested(BaseModel):
|
||||
marginCloseoutNAV: str
|
||||
marginUsed: str
|
||||
|
|
Loading…
Reference in New Issue