Skip to content

Commit

Permalink
Merge branch 'release/1.0.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
iamWing committed Apr 6, 2021
2 parents 3b145dd + dd93ef5 commit e3e2a40
Show file tree
Hide file tree
Showing 8 changed files with 168 additions and 148 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [v1.0.5] - 2021-04-06
Minor fixes on error code returns and missing property on `IBridge`.

### Added
- Property `accounts_manager` on interface `ibpy_native.interfaces.IBridge`.

### Fixed
- Value of `err_code` for all `ibpy_native.error.IBError` raised are now aligned
to be type `int` instead of `ibpy_native.error.IBErrorCode` being passed in
some cases.

## [v1.0.4] - 2021-03-15
Hotfix `IBBridge.req_historical_ticks`.

Expand Down Expand Up @@ -207,7 +218,8 @@ returns with `finished` mark as `True` unexpectedly while IB returns less than
1000 records but there're more historical ticks those should be fetched
in next request.

[Unreleased]: https://github.com/Devtography/ibpy_native/compare/v1.0.4...HEAD
[Unreleased]: https://github.com/Devtography/ibpy_native/compare/v1.0.5...HEAD
[v1.0.5]: https://github.com/Devtography/ibpy_native/compare/v1.0.5...v1.0.4
[v1.0.4]: https://github.com/Devtography/ibpy_native/compare/v1.0.4...v1.0.3
[v1.0.3]: https://github.com/Devtography/ibpy_native/compare/v1.0.3...v1.0.2
[v1.0.2]: https://github.com/Devtography/ibpy_native/compare/v1.0.2...v1.0.1
Expand Down
264 changes: 131 additions & 133 deletions Pipfile.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions ibpy_native/_internal/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async def resolve_contract(
return resolved_contract

raise error.IBError(
rid=req_id, err_code=error.IBErrorCode.RES_NO_CONTENT,
rid=req_id, err_code=error.IBErrorCode.RES_NO_CONTENT.value,
err_str="Failed to get additional contract details"
)

Expand Down Expand Up @@ -258,14 +258,14 @@ async def resolve_head_timestamp(

if len(res) > 1:
raise error.IBError(
rid=req_id, err_code=error.IBErrorCode.RES_UNEXPECTED,
rid=req_id, err_code=error.IBErrorCode.RES_UNEXPECTED.value,
err_str="[Abnormal] Multiple result received"
)

return int(res[0])

raise error.IBError(
rid=req_id, err_code=error.IBErrorCode.RES_NO_CONTENT,
rid=req_id, err_code=error.IBErrorCode.RES_NO_CONTENT.value,
err_str="Failed to get the earliest available data point"
)

Expand Down Expand Up @@ -332,7 +332,7 @@ async def req_historical_ticks(

if not result[1]:
raise error.IBError(
rid=req_id, err_code=error.IBErrorCode.RES_UNEXPECTED,
rid=req_id, err_code=error.IBErrorCode.RES_UNEXPECTED.value,
err_str="Not all historical tick data has been received "
"for this request. Please retry."
)
Expand Down Expand Up @@ -408,7 +408,7 @@ def cancel_live_ticks_stream(self, req_id: int):
f_queue.put(element=fq.Status.FINISHED)
else:
raise error.IBError(
rid=req_id, err_code=error.IBErrorCode.RES_NOT_FOUND,
rid=req_id, err_code=error.IBErrorCode.RES_NOT_FOUND.value,
err_str=f"Task associated with request ID {req_id} not found"
)
#endregion - Stream live tick data
Expand All @@ -430,7 +430,7 @@ def _unknown_error(self, req_id: int, extra: Any = None):
error code `50500: UNKNOWN`
"""
return error.IBError(
rid=req_id, err_code=error.IBErrorCode.UNKNOWN,
rid=req_id, err_code=error.IBErrorCode.UNKNOWN.value,
err_str="Unknown error: Internal queue reported error "
"status but no exception received",
err_extra=extra
Expand Down
4 changes: 2 additions & 2 deletions ibpy_native/_internal/_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def _init_req_queue(self, req_id: int):
self._req_queue[req_id].reset()
else:
raise error.IBError(
rid=req_id, err_code=error.IBErrorCode.QUEUE_IN_USE,
rid=req_id, err_code=error.IBErrorCode.QUEUE_IN_USE.value,
err_str=f"Requested queue with ID {str(req_id)} is "
"currently in use"
)
Expand All @@ -376,7 +376,7 @@ def _on_disconnected(self):
continue
if f_queue.status is not fq.Status.FINISHED or fq.Status.ERROR:
err = error.IBError(
rid=key, err_code=error.IBErrorCode.NOT_CONNECTED,
rid=key, err_code=error.IBErrorCode.NOT_CONNECTED.value,
err_str=_global.MSG_NOT_CONNECTED
)
f_queue.put(element=err)
Expand Down
2 changes: 1 addition & 1 deletion ibpy_native/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ async def req_historical_ticks(
start_date_time=start_date_time, show=tick_type
)
except error.IBError as err:
if err.err_code == error.IBErrorCode.NOT_CONNECTED.value:
if err.err_code == error.IBErrorCode.NOT_CONNECTED:
raise err
if retry_attemps < retry:
retry_attemps += 1
Expand Down
9 changes: 9 additions & 0 deletions ibpy_native/interfaces/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ def is_connected(self) -> bool:
"""
return NotImplemented

@property
@abc.abstractmethod
def accounts_manager(self) -> delegates.AccountsManagementDelegate:
""":obj:`ibpy_native.interfaces.delegates.AccountsManagementDelegate`:
`ibpy_native.manager.AccountsManager` instance that stores & manages
all IB account(s) related data.
"""
return NotImplemented

@property
@abc.abstractmethod
def orders_manager(self) -> delegates.OrdersManagementDelegate:
Expand Down
7 changes: 4 additions & 3 deletions ibpy_native/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def on_disconnected(self):
if self._account_updates_queue.status is not (
fq.Status.ERROR or fq.Status.FINISHED):
err = error.IBError(
rid=-1, err_code=error.IBErrorCode.NOT_CONNECTED,
rid=-1, err_code=error.IBErrorCode.NOT_CONNECTED.value,
err_str=_global.MSG_NOT_CONNECTED
)
self._account_updates_queue.put(element=err)
Expand Down Expand Up @@ -255,7 +255,8 @@ def on_order_submission(self, order_id: int):
)
else:
raise error.IBError(
rid=order_id, err_code=error.IBErrorCode.DUPLICATE_ORDER_ID,
rid=order_id,
err_code=error.IBErrorCode.DUPLICATE_ORDER_ID.value,
err_str=f"Existing queue assigned for order ID {order_id} "
"found. Possiblely duplicate order ID is being used."
)
Expand Down Expand Up @@ -305,7 +306,7 @@ def on_disconnected(self):
for key, f_queue in self._pending_queues.items():
if f_queue.status is not fq.Status.FINISHED or fq.Status.ERROR:
err = error.IBError(
rid=key, err_code=error.IBErrorCode.NOT_CONNECTED,
rid=key, err_code=error.IBErrorCode.NOT_CONNECTED.value,
err_str=_global.MSG_NOT_CONNECTED
)
f_queue.put(element=err)
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
# For a discussion on single-sourcing the version across setup.py and the
# project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version="1.0.4", # Required
version="1.0.5", # Required
# This is a one-line description or tagline of what your project does. This
# corresponds to the "Summary" metadata field:
# https://packaging.python.org/specifications/core-metadata/#summary
description="Implementation of the native python version of IB API", # Optional
description="Implementation of the native Python version of IB API", # Optional
# This is an optional longer description of your project that represents
# the body of text which users will see when they visit PyPI.
#
Expand Down

0 comments on commit e3e2a40

Please sign in to comment.