Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: add ability to filter instruments and contracts #7

Merged
merged 2 commits into from
Oct 22, 2022

Conversation

GoldenChrysus
Copy link
Contributor

get_conid by default returns the first contract of the first instrument it finds. This causes problems if multiple markets have instruments using this symbol, as a contract different from what was expected might be returned. I found this when looking up the $MUB US equity, which is not the first $MUB instrument returned by IB, so I didn't receive the contract ID I wanted.

Two parameters, instrument_filters and contract_filters, are added to get_conid. instrument_filters filters the instrument data, i.e. the name, chineseName, and assetClass fields. contract_filters filters the contract data, i.e the exchange and isUS fields. All filters must be fulfilled for the instrument/contract to be included. The filters can be used together.

I've added some samples of searching for US $MUB using the filters.

@sourcery-ai
Copy link

sourcery-ai bot commented Oct 22, 2022

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 6.76%.

Quality metrics Before After Change
Complexity 0.62 ⭐ 2.83 ⭐ 2.21 👎
Method Length 39.50 ⭐ 44.86 ⭐ 5.36 👎
Working memory 6.16 ⭐ 4.99 ⭐ -1.17 👍
Quality 85.66% 78.90% -6.76% 👎
Other metrics Before After Change
Lines 277 302 25
Changed files Quality Before Quality After Quality Change
src/easyib/easyib.py 85.66% ⭐ 78.90% ⭐ -6.76% 👎

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
src/easyib/easyib.py REST.get_conid 12 🙂 165 😞 50.25% 🙂 Try splitting into smaller methods
src/easyib/easyib.py REST.get_bars 2 ⭐ 70 🙂 11 😞 69.46% 🙂 Extract out complex expressions
src/easyib/easyib.py REST.modify_order 1 ⭐ 62 🙂 10 😞 73.59% 🙂 Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

@utilmon
Copy link
Owner

utilmon commented Oct 22, 2022

Thanks for the improvement!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants