Coder Social home page Coder Social logo

Comments (10)

alvarobartt avatar alvarobartt commented on July 22, 2024

Hi @tommifi!

The functionality you are proposing is not done yet, since the retrieval function just admits one stock symbol per request, which means that just one str can be sent as stock parameter. Anyways, the improvement you are proposing will be evaluated, and if aproved, it will be available in next releases via allowing stock parameter to be a list of stock symbols in order to retrieve more than one stock pandas.DataFrame of historical data.

Currently, here is the solution to retrieve more than one stock historical data pandas.DataFrame and add them into a list of stock historical data objects:

import investpy

stocks = ['AAPL', 'GOOG']
dfs = list()

for stock in stocks:
    df = investpy.get_stock_historical_data(stock=stock, 
                                            country='united states',
                                            from_date='01/01/2010',
                                            to_date='01/01/2019')

    dfs.append(df)

Hope this helped you! :octocat: Stay tunned for future updates on this issue!

from investpy.

alvarobartt avatar alvarobartt commented on July 22, 2024

Hi @tommifi!

Just let you know that this issue will not be worked on for now, since currently using a for loop seems to be enough. Anyways, if you think that this issue is a relevant feature to include in investpy just let me know and I will re-open the issue whenever I have time to include it.

Thank you for the support! ⭐ :octocat:

from investpy.

freddie3399 avatar freddie3399 commented on July 22, 2024

Hi Alvaro,

Could you please write the complete code from

  1. extracting multiple stocks historical data (AAPL, GOOG)

  2. structure the data under
    Column
    'AAPL','Date','Open','High','Low','Close','Volume','Currency',GOOG','Date','Open','High','Low','Close','Volume','Currency'

  3. export to CSV or Excel

I'm very new to programming. Appreciate your kind guidance and support along my learning journey.

Thanks in advance!

from investpy.

alvarobartt avatar alvarobartt commented on July 22, 2024

Sure @freddie3399! I'll try to prepare a sample Python code for you to do that πŸ€—

from investpy.

ScottJRoberts avatar ScottJRoberts commented on July 22, 2024

Can I also see that python code sample??

from investpy.

alvarobartt avatar alvarobartt commented on July 22, 2024

Sure! I'll try to share it with you later today as I'm currently working and I need to create that script from scratch! πŸ‘πŸ»

from investpy.

gahoccode avatar gahoccode commented on July 22, 2024

Sure! I'll try to share it with you later today as I'm currently working and I need to create that script from scratch! πŸ‘πŸ»

Hi Alvaro! Were you able to write the code? I'm looking forward to hearing from you!

from investpy.

alvarobartt avatar alvarobartt commented on July 22, 2024

Hi @gahoccode, sorry I forgot to share that code, I'll try to prepare a simple code to achieve that so that you can use it! πŸ€—

Anyway, could you please share with me what do you exactly want? Is it something like:

- [AAPL,GOOG]
- Retrive latest stock information
- Append both DFs
- Save DF as Excel File

from investpy.

gahoccode avatar gahoccode commented on July 22, 2024

Hi @gahoccode, sorry I forgot to share that code, I'll try to prepare a simple code to achieve that so that you can use it! πŸ€—

Anyway, could you please share with me what do you exactly want? Is it something like:

- [AAPL,GOOG]
- Retrive latest stock information
- Append both DFs
- Save DF as Excel File

So just as what @freddie3399 said, I'd like to see how you
1.extracting multiple stocks historical data (AAPL, GOOG)

2.structure the data under
Column
'AAPL','Date','Open','High','Low','Close','Volume','Currency',GOOG','Date','Open','High','Low','Close','Volume','Currency'

  1. export to CSV or Excel

I tried to pull 2 stocks by applying the code you gave but the result turns out not quite what I expected. It seems that it only pulls either pull only 1 of the 2 or include prices in one column. I'd like to separate price by stock column. Trying to do a percent change calculation for multiple stocks in a table. Thanks!

from investpy.

pardeshishivam avatar pardeshishivam commented on July 22, 2024

Hi @gahoccode, sorry I forgot to share that code, I'll try to prepare a simple code to achieve that so that you can use it! πŸ€—

Anyway, could you please share with me what do you exactly want? Is it something like:

- [AAPL,GOOG]
- Retrive latest stock information
- Append both DFs
- Save DF as Excel File

Hello there Alvaro,
I too had the same query.
I tried your earlier vode of for loop but it shows run time error 520.
I am not sure you are aware but there is a similar library nsepy which I used for Indian markets it distinguishes stocks very diligently under different columns and we can append the list with ease

from investpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.