Skip to content

Commit

Permalink
Housekeeping
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-kn committed Oct 31, 2020
1 parent 4b42305 commit 3cee1af
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 33 deletions.
18 changes: 9 additions & 9 deletions comdirect_api/comdirect_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ def get_depot_transactions(self, depot_id, with_instrument=False, **kwargs):
:param depot_id: Depot-ID
:param with_instrument: Include instrument information. Defaults to False.
:param wkn: filter by WKN
:param isin: filter by ISIN
:param instrument_id: filter by instrumentId
:param max_booking_date: filter by booking date, Format "JJJJ-MM-TT"
:param transaction_direction: filter by transactionDirection: {"IN", "OUT"}
:param transaction_type: filter by transactionType: {"BUY", "SELL", "TRANSFER_IN", "TRANSFER_OUT"}
:param booking_status: filter by bookingStatus: {"BOOKED", "NOTBOOKED", "BOTH"}
:param min_transaction_value: filter by min-transactionValue
:param max_transaction_value: filter by max-transactionValue
:key wkn: filter by WKN
:key isin: filter by ISIN
:key instrument_id: filter by instrumentId
:key max_booking_date: filter by booking date, Format "JJJJ-MM-TT"
:key transaction_direction: filter by transactionDirection: {"IN", "OUT"}
:key transaction_type: filter by transactionType: {"BUY", "SELL", "TRANSFER_IN", "TRANSFER_OUT"}
:key booking_status: filter by bookingStatus: {"BOOKED", "NOTBOOKED", "BOTH"}
:key min_transaction_value: filter by min-transactionValue
:key max_transaction_value: filter by max-transactionValue
:return: Response object
"""
return self.depot_service.get_depot_transactions(depot_id, with_instrument, **kwargs)
Expand Down
47 changes: 23 additions & 24 deletions comdirect_api/service/depot_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ def get_all_depots(self):
response = self.session.get(url).json()
return response

def get_depot_positions(self, depot_id, with_depot=True, with_positions=True, with_instrument=False, instrument_id=None):
def get_depot_positions(self, depot_id, with_depot=True, with_positions=True, with_instrument=False,
instrument_id=None):
"""
5.1.2. Fetch information for a specific depot.
Expand Down Expand Up @@ -64,40 +65,38 @@ def get_depot_transactions(self, depot_id, with_instrument=False, **kwargs):
:param depot_id: Depot-ID
:param with_instrument: Include instrument information. Defaults to False.
:param wkn: filter by WKN
:param isin: filter by ISIN
:param instrument_id: filter by instrumentId
:param max_booking_date: filter by booking date, Format "JJJJ-MM-TT"
:param transaction_direction: filter by transactionDirection: {"IN", "OUT"}
:param transaction_type: filter by transactionType: {"BUY", "SELL", "TRANSFER_IN", "TRANSFER_OUT"}
:param booking_status: filter by bookingStatus: {"BOOKED", "NOTBOOKED", "BOTH"}
:param min_transaction_value: filter by min-transactionValue
:param max_transaction_value: filter by max-transactionValue
:key wkn: filter by WKN
:key isin: filter by ISIN
:key instrument_id: filter by instrumentId
:key max_booking_date: filter by booking date, Format "JJJJ-MM-TT"
:key transaction_direction: filter by transactionDirection: {"IN", "OUT"}
:key transaction_type: filter by transactionType: {"BUY", "SELL", "TRANSFER_IN", "TRANSFER_OUT"}
:key booking_status: filter by bookingStatus: {"BOOKED", "NOTBOOKED", "BOTH"}
:key min_transaction_value: filter by min-transactionValue
:key max_transaction_value: filter by max-transactionValue
:return: Response object
"""
kwargs_mapping = {
"wkn" : "WKN",
"isin" : "ISIN",
"instrument_id" : "instrumentId",
"max_booking_date" : "max-bookingDate",
"transaction_direction" : "transactionDirection",
"transaction_type" : "transactionType",
"booking_status" : "bookingStatus",
"min_transaction_value" : "min-transactionValue",
"max_transaction_value" : "max-transactionValue"
"wkn": "WKN",
"isin": "ISIN",
"instrument_id": "instrumentId",
"max_booking_date": "max-bookingDate",
"transaction_direction": "transactionDirection",
"transaction_type": "transactionType",
"booking_status": "bookingStatus",
"min_transaction_value": "min-transactionValue",
"max_transaction_value": "max-transactionValue"
}

url = '{0}/brokerage/v3/depots/{1}/transactions'.format(self.api_url, depot_id)
params = {'without-attr': 'instrument'} if not with_instrument else {}

for arg, val in kwargs.items():
api_arg = kwargs_mapping.get(arg)
if api_arg is None:
raise ValueError('Keyword argument {} is invalid'.format(arg))
else:
params[api_arg] = val

print(params)


response = self.session.get(url, params=params).json()
return response

0 comments on commit 3cee1af

Please sign in to comment.