Convert API responses with Glom
This commit is contained in:
@@ -133,19 +133,19 @@ class AlpacaExchange(BaseExchange):
|
||||
def cancel_trade(self, trade_id):
|
||||
pass
|
||||
|
||||
def get_position_info(self, asset_id):
|
||||
success, position = self.call("get_open_position", asset_id)
|
||||
def get_position_info(self, symbol):
|
||||
success, position = self.call("get_open_position", symbol)
|
||||
if not success:
|
||||
return (success, position)
|
||||
return (True, position)
|
||||
|
||||
def get_all_positions(self):
|
||||
items = []
|
||||
success, positions = self.call("get_all_positions")
|
||||
success, response = self.call("get_all_positions")
|
||||
if not success:
|
||||
return (success, positions)
|
||||
return (success, response)
|
||||
|
||||
for item in positions["itemlist"]:
|
||||
for item in response["itemlist"]:
|
||||
item["account_id"] = self.account.id
|
||||
item["unrealized_pl"] = float(item["unrealized_pl"])
|
||||
items.append(item)
|
||||
|
||||
Reference in New Issue
Block a user