Skip to content

Commit

Permalink
Merge pull request #35 from shlomikushchi/master
Browse files Browse the repository at this point in the history
Convert account data from api to float locally
  • Loading branch information
Shlomi Kushchi authored Apr 9, 2020
2 parents 01d91c9 + 1acd521 commit 44cf9b6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions alpaca_backtrader_api/alpacabroker.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,13 @@ def update_positions(self):

is_sell = broker_positions_mapped_by_symbol[name].side ==\
'short'
size = broker_positions_mapped_by_symbol[name].qty
size = int(broker_positions_mapped_by_symbol[name].qty)
if is_sell:
size = -size
positions[data] = Position(
size,
broker_positions_mapped_by_symbol[name].avg_entry_price
float(broker_positions_mapped_by_symbol[
name].avg_entry_price)
)
return positions

Expand Down Expand Up @@ -153,7 +154,7 @@ def getcash(self):
def getvalue(self, datas=None):
# don't use self.o.get_value(). it takes time for local store to get
# update from broker.
self.value = self.o.oapi.get_account().portfolio_value
self.value = float(self.o.oapi.get_account().portfolio_value)
return self.value

def getposition(self, data, clone=True):
Expand Down

0 comments on commit 44cf9b6

Please sign in to comment.