I am attemping to setup a research env. Pythong/C# are working with out issues with the Visual Studios. The issue I am having is what should be in cell 6 a pandas dataframe, I am getting a different type of object. I have seen in other examples that this type of set up have the correct output:
https://www.quantconnect.com/forum/discussion/2641/history-method-not-returning-a-dataframe-in-python/p1/comment-8071this is the notebook output
my config.json is as followed:
Jack Simonson
Hi Mathew,
Making a history requestion in the Research Environment requires passing the history call the securities that you want data for. In your example, you would want to call
history_plain_form = qb.History(qb.Securities.Keys, 4)
The qb.Securities.Keys argument will request history for all of the Securities in the Universe that you've added thus far, and so it would only be IBM in your example. (Note that the default resolution for historical data is minute, so add the resolution argument after the number of periods requested if you want data of a different resolution.)
Mathew Blonc
when i update the code I get the following error, could this error be related to pythonnet?
--------------------------------------------------------------------------- MissingMethodException Traceback (most recent call last) <ipython-input-3-0d1ab0d7de80> in <module>() 1 qb.AddForex("eurgbp") 2 qb.SetStartDate(2017,10,16) ----> 3 history_plain_form = qb.History(qb.Securities.Keys, 4) MissingMethodException: Method not found: 'System.__Canon Python.Runtime.PyObject.As()'. at QuantConnect.Extensions.TryConvert[T](PyObject pyObject, T& result) at QuantConnect.Algorithm.QCAlgorithm.<GetSymbolsFromPyObject>d__330.MoveNext() in C:\Users\blonc\Documents\Lean-master\Algorithm\QCAlgorithm.Python.cs:line 802 at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext() at System.Linq.Enumerable.<SelectManyIterator>d__17`2.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext() at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) at QuantConnect.Algorithm.QCAlgorithm.History(IEnumerable`1 requests, DateTimeZone timeZone) in C:\Users\blonc\Documents\Lean-master\Algorithm\QCAlgorithm.History.cs:line 545 at QuantConnect.Algorithm.QCAlgorithm.History(IEnumerable`1 requests) in C:\Users\blonc\Documents\Lean-master\Algorithm\QCAlgorithm.History.cs:line 473 at QuantConnect.Algorithm.QCAlgorithm.History(IEnumerable`1 symbols, Int32 periods, Nullable`1 resolution) in C:\Users\blonc\Documents\Lean-master\Algorithm\QCAlgorithm.History.cs:line 438 at QuantConnect.Algorithm.QCAlgorithm.History(PyObject tickers, Int32 periods, Nullable`1 resolution) in C:\Users\blonc\Documents\Lean-master\Algorithm\QCAlgorithm.Python.cs:line 540
Jack Simonson
Mathew,
Just to confirm, you do have EURUSD forex data in the data directory specified in the config.json file? If you haven't bought and downloaded this data to the necessary location, then making a history request would fail since you're asking for data from your local directory rather than the data available in the cloud.
Mathew Blonc
Yes I have downloaded and place only the daily data files in the correct location.
Jack Simonson
The default resolution for a history request is minute data, so try requesting daily data in the History request or specify daily resolution in the AddForex call, such as
qb.AddForex("eurgbp", Resolution.Daily) qb.SetStartDate(2017,10,16) history_plain_form = qb.History(qb.Securities.Keys, 4)
or
qb.AddForex("eurgbp") qb.SetStartDate(2017,10,16) history_plain_form = qb.History(qb.Securities.Keys, 4, Resolution.Daily)
This should solve the issue.
Mathew Blonc
For both of those you get which leads me to think it’s a pythonnet error?
TypeError Traceback (most recent call last) <ipython-input-3-9bb8c2795ff8> in <module>() 1 qb.AddForex("eurgbp") 2 qb.SetStartDate(2017,10,16) ----> 3 history_plain_form = qb.History(qb.Securities.Keys, 4, Resolution.Daily) TypeError: No method matches given arguments
Jack Simonson
It's possible that qb.Securities.Keys isn't a Python list and this is causing an issue. Can you try these lines and see if that works?
symbols = [x for x in qb.Securities.Keys] history_plain_form = qb.History(symbols, 4, Resolution.Daily)
Alexandre Catarino
Hi Mathew,
Are you using QuantConnect's fork/version of pythonnet?
Mathew Blonc
without issues, I can run python and c# in VS. Only when I try to run jupyter do I have problems. I do have python quantconnect installed. I looked at nugets and it does have quantconnects version of pythonnet. should bye "composer-dll-directory": ".", in config.json be set to anything other than "." could this be an issue?
the error i always have gotten and still am getting is "TypeError: No method matches given arguments" relating to qb.History() method.
Mathew Blonc
I may have found a partial step forward in this post:
https://www.quantconnect.com/forum/discussion/2641/history-method-not-returning-a-dataframe-in-python/p1/comment-8071
basically, the user is saying these methods do NOT even exist in the notebook version on LEAN. is this correct?
When I run the code
# Create an instance qb = QuantBook() # Select asset data spy = qb.AddEquity("SPY",Resolution.Daily) qb.SetStartDate(2018,7,3) history_plain_form = qb.History(20) history_plain_form
it actually does not throw any errors and returns
<QuantConnect.Util.0, Culture=neutral, PublicKeyToken=null]] at 0x2daeab88eb8>
but should this not be a data frame??
Halldor Andersen
Hi Mathew.
Specify the symbol within a list to retrieve a pandas DataFrame:
history = qb.History(["SPY"],20)
For more details check out this overload list for the History method, which is part of the Lean documentation.
We're working on updating our documentation section on Historical Data. Stay tuned!
Mathew Blonc
clearly, there is an environment set-up error, cause that takes me back to the method not found.
MissingMethodException Traceback (most recent call last) <ipython-input-43-52bbc6da1558> in <module>() ----> 1 history_plain_form = qb.History(["SPY"],20) MissingMethodException: Method not found: 'System.__Canon Python.Runtime.PyObject.As()'. at QuantConnect.Extensions.TryConvert[T](PyObject pyObject, T& result) at QuantConnect.Algorithm.QCAlgorithm.<GetSymbolsFromPyObject>d__381.MoveNext() in C:\Lean\Algorithm\QCAlgorithm.Python.cs:line 804 at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext() at System.Linq.Enumerable.<SelectManyIterator>d__17`2.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext() at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) at QuantConnect.Algorithm.QCAlgorithm.History(IEnumerable`1 requests, DateTimeZone timeZone) in C:\Lean\Algorithm\QCAlgorithm.History.cs:line 545 at QuantConnect.Algorithm.QCAlgorithm.History(IEnumerable`1 requests) in C:\Lean\Algorithm\QCAlgorithm.History.cs:line 473 at QuantConnect.Algorithm.QCAlgorithm.History(IEnumerable`1 symbols, Int32 periods, Nullable`1 resolution) in C:\Lean\Algorithm\QCAlgorithm.History.cs:line 438 at QuantConnect.Algorithm.QCAlgorithm.History(PyObject tickers, Int32 periods, Nullable`1 resolution) in C:\Lean\Algorithm\QCAlgorithm.Python.cs:line 542
Link Liang
Hi Mathew,
qb.History(20) returns a list of Slice object. You might see a different output from some old posts because we have a slightly different QuantBook object now, which is closer to QCAlgorithm and easier for the convertion between research environment and algorithm backtesting. More information about Slice object is here.
I cannot reproduce the “Method not found” error you have. Here is an example of accessing historical data in two different ways. In [1] outputs some data from Slice list, and In [2] prints a DataFrame. If you still encounter that error, please attach your notebook or full code so that we could address the issue in details.
Hope it helps!
Essam Saed
Hi every one
Me too is facing the same problem mentioned in this post where the algorithm could be easily ran on the cloud but on local jupyter i get the same error where self.History gives me No metthod matches given arguments for History i dont know what is wrong in setting my local environment
Mathew Blonc
the best way I found to get this functioning locally is to follow the steps with in the docer files, just use them as a guide. A key step is to make sure you compile your code with python settings as well as make sure to move the DLL. Just use docker files as step by step instructions and it has always worked for me.
Jared Broad
Matthew's suggestion is good if you want to install it locally. But the beauty of docker is it allows you to easily keep up with updates.
We're almost done releasing a new update to research which works better locally. Hopefully it'll be out this week.
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Mathew Blonc
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!