QuantConnect / QuantConnect/Lean

Improve Dictionary and Enumerable Python Handling

Open
#6,934 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

consistency
Dominant language
C#
Stars
21.7k
Forks
5.3k
Avg merge
2d 22h
Merged PRs (30d)
34

Description

Expected Behavior
  • Error messages are informative and helpful
  • Minimize the pure C# types in Python, and when absolutely required extend with common interface methods (len, items, keys)
Actual Behavior
markets = qb.BrokerageModel.DefaultMarketMap
<System.Collections.ObjectModel.ReadOnlyDictionary...
bars = qb.History[TradeBar](ibm.Symbol, start, end, Resolution.Minute)
<QuantConnect.Util.MemoizingEnumerable[TradeBar] object at 0x7...
Potential Solution
  1. Make the method return a naitve python type if possible -- in PythonNet if required.
  2. If not possible; provide common APIs for each one. len, append, items, keys etc.
  3. Catch the Memoizing enumerable / readonly dictionary error messages and provide a more informative error message.
Reproducing the Problem

Python History API Calls

Checklist
  • I have completely filled out this template
  • I have confirmed that this issue exists on the current master branch
  • I have confirmed that this is not a duplicate issue by searching issues
  • I have provided detailed steps to reproduce the issue

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Python History API calls and the returned ReadOnlyDictionary and MemoizingEnumerable examples described in the issue. Determine whether PythonNet can provide native Python types or whether common methods and clearer error messages are required. Done means Python callers receive usable collection behavior and informative errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, python
Domain
api, backend
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.