From 4856169d028b17d9efbb3607c2db36fb1cdd1ad1 Mon Sep 17 00:00:00 2001 From: ttt733 Date: Wed, 5 Feb 2020 23:51:45 -0600 Subject: [PATCH] Handle response from position closing endpoints --- alpaca_trade_api/rest.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/alpaca_trade_api/rest.py b/alpaca_trade_api/rest.py index 1e5b4c97..7deaae37 100644 --- a/alpaca_trade_api/rest.py +++ b/alpaca_trade_api/rest.py @@ -294,11 +294,13 @@ def get_position(self, symbol): def close_position(self, symbol): '''Liquidates the position for the given symbol at market price''' - self.delete('/positions/{}'.format(symbol)) + resp = self.delete('/positions/{}'.format(symbol)) + return Order(resp) def close_all_positions(self): '''Liquidates all open positions at market price''' - self.delete('/positions') + resp = self.delete('/positions') + return [Order(o) for o in resp] def list_assets(self, status=None, asset_class=None): '''Get a list of assets'''