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

What´s the right way to create the iterable "quotes" list from a dataframe? #228

Closed
August1328 opened this issue May 8, 2022 · 4 comments
Labels
user support Help a user

Comments

@August1328
Copy link

I use another python TA module and wanted to compare it with this module, but I am already having problems at the beginning.

I can download historical quotes from IBKR into a dataframe "hist_quotes". The df looks like this:

date open high low close volume
954 2022-05-07 01:54:00 3.26 3.27 3.250 3.2599 7600.0
955 2022-05-07 01:55:00 3.26 3.26 3.250 3.2600 3900.0
956 2022-05-07 01:56:00 3.26 3.26 3.250 3.2500 300.0
957 2022-05-07 01:57:00 3.25 3.26 3.230 3.2300 17900.0
958 2022-05-07 01:58:00 3.25 3.27 3.245 3.2600 12500.0
...

The quotes parameter has be of type "Iterable[Quote]", so I converted the df to a list:
quotes = hist_quotes.values.tolist()

and then call the indicator
results = indicators.get_kvo(quotes, 34,55,13)

which breaks off with an error:

Python.Runtime.PythonException: 'list' value cannot be converted to Skender.Stock.Indicators.Quote

The content of "quotes" looks like this and it is iterable:

[[Timestamp('2022-05-06 10:00:00'), 3.23, 3.63, 3.23, 3.61, 98300.0], [Timestamp('2022-05-06 10:01:00'), 3.61, 3.63, 3.55, 3.62, 68900.0], [Timestamp('2022-05-06 10:02:00'), 3.62, 3.63, 3.51, 3.51, 65400.0], ....

I read every post available on this topic on stackoverflow and also tried different ways to create the quotes -- df.to_records(), df.to_dict(), iter(), ... but everything failed.

So, I am a little stuck... I guess the solution is rather simple, could someone show please help me with the right way? What am I missing?

@DaveSkender DaveSkender added the user support Help a user label May 8, 2022
@LeeDongGeon1996
Copy link
Member

LeeDongGeon1996 commented May 8, 2022

@August1328 Hi, thank you for using our library.
I guess you are passing just a list form of dataframe, but the library has its own Quote class. You have to pass the Iterable(ex. list) of Quote instances.

This comment may be helpful to you:

@August1328
Copy link
Author

Thanks, I missed this comment due to the different subject.

The calculation works fine now.

@LeeDongGeon1996
Copy link
Member

LeeDongGeon1996 commented May 8, 2022

Good to hear that!
If you have further questions, please let us know anytime :)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 7, 2022
@DaveSkender
Copy link
Member

Tip

For a working example using price quotes from a pandas.DataFrame, see our Replit of the Williams Fractal indicator. If you're having general trouble getting setup, see our QuickStart guide.

See also:

  • #1165

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
user support Help a user
Projects
None yet
Development

No branches or pull requests

3 participants