Hi all,
I am gathering weekly data by the following script:
request_params = StockBarsRequest(
symbol_or_symbols=“IVP”,
timeframe=TimeFrame(1, TimeFrameUnit.Week),
start=“2024-03-15”,
end=“2024-05-14”
)
bars_df2 = data_client.get_stock_bars(request_params).df
I am getting this data:
open high low close volume trade_count vwap
symbol timestamp
IVP 2024-03-18 04:00:00+00:00 0.0506 0.0550 0.0417 0.0504 32157632.0 20904.0 0.048592
2024-03-25 04:00:00+00:00 0.0519 0.0617 0.0340 0.0455 46036706.0 27335.0 0.049961
2024-04-01 04:00:00+00:00 0.0475 0.0535 0.0405 0.0479 125521041.0 49737.0 0.054046
2024-04-08 04:00:00+00:00 0.0476 0.0560 0.0451 0.0509 110508898.0 45423.0 0.052615
2024-04-15 04:00:00+00:00 0.0494 0.0494 0.0385 0.0400 68278889.0 32272.0 0.043226
2024-04-22 04:00:00+00:00 0.0393 0.0456 0.0352 0.0440 81574062.0 39442.0 0.042096
2024-04-29 04:00:00+00:00 0.0440 0.0445 0.0385 0.0397 48896761.0 25773.0 0.041040
2024-05-06 04:00:00+00:00 0.0360 5.3000 0.0340 3.8600 56833122.0 308901.0 1.544303
2024-05-13 04:00:00+00:00 3.4800 3.4800 2.3600 2.7000 1499191.0 16400.0 2.767639
All Open low high close data are off before 2024-05-13.
Why it is like this? Am I doing something wrong?
@huseyin You are asking about historical prices which seem ‘off’. You aren’t doing anything wrong. The issue you are seeing is because IVP (Inspire Veterinary Partners) had a 1:100 reverse stock split on 2024-05-08. That means that for every 100 shares before that date one received 1 share of the new ‘split’ shares. That stock split effectively made a single ‘post split’ share worth 100x that of a share ‘pre-split’. That is probably why the prices before 2024-05-13 seem ‘off’.
To account for splits and make the bar data more easily comparable, one can specify adjustment=split
. Something like this
request_params = StockBarsRequest(
symbol_or_symbols='IVP',
timeframe=TimeFrame(1, TimeFrameUnit.Week),
start='2024-03-15',
end='2024-05-14',
adjustment='split',
)
bars_df2 = client.get_stock_bars(request_params=request_params).df.tz_convert('America/New_York', level='timestamp')
This returns the following dataframe which probably loos better.
Thank you so much. You are so helpful
I tried your script but I am getting this error:
ConnectionError: (‘Connection aborted.’, RemoteDisconnected(‘Remote end closed connection without response’))
Without adjustment=‘split’, it works
I am trying to download around 8000 tickers for last 25 weeks
@huseyin One thing to try is fetching the data in smaller ‘chunks’ of symbols. Try chunks of 2000 to start. There isn’t an explicit limit to the number of symbols, however the symbols become part of the URL as a query parameter. A lot of symbols creates a very long URL. Some networks don’t handle long URLs very well. The ‘Remote end closed connection without response
’ error is suspicious.
Is there a particular reason you are fetching that many symbols? While technically there are about 11,000 tradable symbols in the asset table, only about half of those are really ‘tradable’. About half are warrants, rights, limited partnerships, preferred stock, and simply very lightly traded equities, which one probably shouldn’t trade without actually knowing more about the asset. A high level filter you may want to use is if the equity is ‘fractionable’. That eliminates a lot of those odd equities. For reference, in my days at Quantopian, the universe of ‘tradable’ assets was generally found to be only about 3000.
Thank you so much, I am downloading them one by one. And using fractionable is good option to know