Implement closing positions and refuse to post rejected trades
This commit is contained in:
@@ -117,6 +117,16 @@ class OANDAExchange(BaseExchange):
|
||||
items.append(item)
|
||||
return items
|
||||
|
||||
def close_position(self, side, symbol):
|
||||
data = {
|
||||
f"{side}Units": "ALL",
|
||||
}
|
||||
r = positions.PositionClose(
|
||||
accountID=self.account_id, instrument=symbol, data=data
|
||||
)
|
||||
response = self.call(r)
|
||||
return response
|
||||
|
||||
def close_all_positions(self):
|
||||
# all_positions = self.get_all_positions()
|
||||
|
||||
@@ -124,5 +134,4 @@ class OANDAExchange(BaseExchange):
|
||||
# print("POS ITER", position)
|
||||
r = positions.PositionClose(accountID=self.account_id)
|
||||
response = self.call(r)
|
||||
print("CLOSE ALL POSITIONS", response)
|
||||
return response
|
||||
|
||||
Reference in New Issue
Block a user