[Tutor] Fwd: 10+ Different Python Script?
Steven D'Aprano
steve at pearwood.info
Wed Jul 13 09:08:06 EDT 2016
On Wed, Jul 13, 2016 at 05:03:41AM -0700, Crusier wrote:
> I have a python script which is used for downloading Real Time Stocks.
> Currently, there is over a 1000 stocks in the Portfolio.
>
> If I download the market info during market hours, it would take over
> 40 minutes to finish downloading all the market info.
That's only 2.4 seconds per stock. Depending on how much data each stock
provides, that doesn't sound like much time to me.
(1) How much data is downloaded? Perhaps you are downloading as fast
as your internet conection will allow.
(2) How long does it take to download outside of market hours? Perhaps
the supplier throttles the speed that you can download during market
hours, or perhaps they're just overloaded with requests and can't supply
information any faster.
> Since I am
> trading stock real time, I am thinking of breaking it down into 100
> stocks per group, so I could make the download time shorter.
Why do you think that downloading 10*100 stocks will take less time
than downloading 1000 stocks? Either way, you still have to download the
same amount of information.
> For the
> market info, I will put into database and for data analysis.
>
> My Question is as follows:
>
> Please advise if I should put the portfolio and split it into 10
> different scripts, so each scripts consists a list of 100+ number of
> stocks. Or is there any Pythonic way to approach this problem??
Absolutely not. You shouldn't have the portfolio inside the script. You
should have one script, and ten portfolios. Then you give the name of
the portfolio as an argument to the script:
myscript.py portfolio1
myscript.py portfolio2
myscript.py portfolio3
...
myscript.py portfolio10
or possibly:
myscript.py portfolio1 portfolio2 portfolio3 ... portfolio10
> I am currently using Multi Thread but there is an Operational Error....
What sort of error?
> I am having a hard time to approach OOP. I just can't grasp the
> understanding of it as it seems so abstract. Please advise.
One related question per email please. It makes it easier to follow the
conversations if you put unrelated questions in different emails.
--
Steve
More information about the Tutor
mailing list