Skip to content

Commit

Permalink
Added default to Array.get_id & Array.get_instrument
Browse files Browse the repository at this point in the history
  • Loading branch information
jamespeterschinner committed Dec 22, 2017
1 parent ad8587a commit f44c1eb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,10 @@ Added attributes to TradeSummary:
=======

- OandaClient.datetime_format is read only
- OandaClient._instruments is no longer a protected attribute. It is now OandaClient.instruments
- OandaClient._instruments is no longer a protected attribute. It is now OandaClient.instruments

5.0.2b0
=======

- Fixed bug in rest implementation. Positions now update correctly
- Added default argument to Array.get_id & Array.get_instrument
8 changes: 4 additions & 4 deletions async_v20/definitions/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,17 +295,17 @@ def construct_items(data):
instance._instruments = dict(_instruments)
return instance

def get_id(self, id_):
def get_id(self, id_, default=None):
try:
return self[self._ids[int(id_)]]
except KeyError:
return None
return default

def get_instrument(self, instrument):
def get_instrument(self, instrument, default=None):
try:
return self[self._instruments[instrument]]
except KeyError:
return None
return default

def dataframe(self, json=False, datetime_format=None):
"""Create a pandas.Dataframe"""
Expand Down

0 comments on commit f44c1eb

Please sign in to comment.