/media/bill/SWAPPER/Website - raw/economics, markets/SP500/0_SP500 notes.txt
www.BillHowell.ca 14Sep2020 initial
see also "SP500 Fibonacci mirror comments.txt"
********
20Sep2020 create composite images from "standard size" image outputs,
criteria : (think of this later)
only ONE image has axis labels?
obviously use a standard yearFrac duration - much simpler graph generation (just specify start yearFrac, adjustable for searches)
want to eliminate graph borders, titles, etc (except for one graph)
********
16Sep2020 Web-page for "1872-2020 SP500 index, ratio of opening price to semi-log detrended price, TradingView data"
/media/bill/SWAPPER/Website - raw/economics, markets/SP500/1872-2020 SP500 index, ratio of opening price to semi-log detrended price.html
17Sep2020 web-page uploaded to ::
http://www.BillHowell.ca/economics, markets/SP500/1872-2020 SP500 index, ratio of opening price to semi-log detrended price.html
Post to TradingView :
&&&&&&&&
1872-2020 SP500 index : a [time, mind]-bending perspective
The ratio of the historical SP500 price to its semi-log trend price for the same date is plotted in the graph linked below. The price scaling is according to Fibonacci ratios, as commonly used by many stock market technical analysts, which I often find to be helpful or at least interesting, as it so often provides convenient matches with data series.
[url=http://www.billhowell.ca/economics,%20markets/SP500/1872-2020%20SP500%20index,%20ratio%20of%20opening%20price%20to%20semi-log%20detrended%20price.html]http://www.billhowell.ca/economics,%20markets/SP500/1872-2020%20SP500%20index,%20ratio%20of%20opening%20price%20to%20semi-log%20detrended%20price.html[/url]
I rather (arbitrarily, haphazardly) copy-pasted sections of the graph from the 1950-2020 time-frame, and shuffled them to lie over sections of the 1872-1960 section of the original graph.
Even knowing that the (eyes, mind) often see patterns that aren't really there (as per random noise), one can basically re-create the essence of the 1872-1960 time-frame simply by copying ONLY 4 chunks of the 1950-2020 time-frame!! Of course, there is nothing new about this - TradingView members are often comparing current market squiggles to the past, over different timescales. I would actually be surprised if the above graph hasn't already been done hundreds of times before. (TradingView System_T, Amjad Farooq, TexasWestCapital) and others are examples of recent pattern-matching for the SP500, with their comparisons of the 2020 crash to other time periods.
(Commentary, graphs, data, source programs) can be found at :
[url=http://www.billhowell.ca/economics,%20markets/SP500/1872-2020%20SP500%20index,%20ratio%20of%20opening%20price%20to%20semi-log%20detrended%20price.html]http://www.billhowell.ca/economics,%20markets/SP500/1872-2020%20SP500%20index,%20ratio%20of%20opening%20price%20to%20semi-log%20detrended%20price.html[/url]
Obviously, this isn't quite at the smaller timescales for informing trading decisions Users can adapt the "overlays of time periods" themselves by downloading a gimp file (GNU Image Manipulation Program) if they are willing to go through fire to learn gimp.
********
15Sep2020 SP500 - create two "eyeballed" periods of log-linear trending
see also "SP500 Fibonacci mirror comments.txt"
eyeball semi-log line fit measured physicaly on the screen (I don't have a printer)
Capture key data by eyeball placing trend lines on TradingView
https://www.tradingview.com/symbols/SPX/?exchange=SP :
early (nearly-) horizontal trend :
01Feb1871 6.09
01Feb1923 6.20
later trend
01Jan1941 13.34 (also 13.10)
01Sep2020 3361.99
cross-over year
01Apr1926 6.20 (also 6.32)
Graph saved as : /media/bill/SWAPPER/Website - raw/economics, markets/SP500/SP500 TradingView eyeballed trends for (1872-1926) and (1926-2020).png
semi-log equations :
log(y2) = log(y1) + slope*(x2 - x1)
or y2 = 10^[log(y1) + slope*(x2 - x1)]
where
slope = [log(y_end) - log(y_start)] / (x_end - x_start)
= constant over the semi-log trend line
Set-up of semi-log trend lines [01Feb1871-01Apr1926, 01Apr1926-01Sep2020] :
Data-points - as basis of formulae :
Note that I ignore errors by ignoring [actual variations in days/month, leap year, leap second] etc.
This should be more accurate, but then again, I merely eyeball the trends, rather than regress-fit the data.
year_frac(01Feb1871) = 1871 years + [1 month * 30.5 days/month + 1 day]/365.25 days/year
= 1871 + ([(1 * 30.5) + 1]/365.25)
= 1871.09
year_frac(01Feb1923) = 1923 years + [1 month * 30.5 days/month + 1 day]/365.25 days/year
= 1923 + ([(1 * 30.5) + 1]/365.25)
= 1923.09
year_frac(01Apr1926) = 1926 years + [3 months * 30.5 days/month + 1 day]/365.25 days/year
= 1926 + ([(3 * 30.5) + 1]/365.25)
= 1926.25
year_frac(01Jan1941) = 1941 years + [0 months * 30.5 days/month + 1 day]/365.25 days/year
= 1941 + ([(0 * 30.5) + 1]/365.25)
= 1941.0
year_frac(01Sep2020) = 2020 years + [8 months * 30.5 days/month + 1 day]/365.25 days/year
= 2020 + ([(8 * 30.5) + 1]/365.25)
= 2020.67
01Feb1871-01Apr1926 trend :
delta(log(SP500)) : was supposed to be horizontal but is at limits of [computer mouse, hand, eye] resolution
slope = [log(6.20)-log(6.09)]/(01Apr1926-01Feb1871)
= [log(6.20)-log(6.09)]/55.0
= 0.000141353
SP500(year, 1871-1926 trend) = 10^[log(6.09) + (1.41353e-4*(year - 1871.17))]
checks :
SP500(1923.09, 1871-1926 trend) = 10^[log(6.09) + (1.41353e-4*(1923.09 - 1871.17))] = 6.09 WRONG!!??
01Jan1941-01Sep2020 trend :
slope = [log(3361.99)-log(13.34)]/(01Sep2020 - 01Jan1941)
= [log(3361.99)-log(13.34)]/(2020.67 - 1941.0)
= 0.0301423
SP500(year, 1871-1926 trend) = 10^[log(13.34) + (0.0301423*(year - 1941.0))]
checks :
SP500(1941.0, 1871-1926 trend) = 10^[log(13.34) + (0.0301423*(2020.67 - 1941.0))] = 297545. WRONG!!??
01Apr1926-01Sep2020 trend :
slope = [log(3361.99) - log(6.20)]/(01Sep2020 - 01Apr1926)
= [log(3361.99) - log(6.20)]/(2020.67 - 1926.25)
= 0.0289579
SP500(year, 1926-2020 trend) = 10^[(log 6.20) + (0.0289579*(year - 1926.25))]
checks :
SP500(2020.67, 1926-2020 trend) = 10^[(log 6.20) + (0.0289579*(2020.67 - 1926.25))] = 297549. WRONG!!!?
Notice the error (difference) between the slopes of the [01Apr1926, 01Jan1941]-01Sep2020 trends
difference(slopes) = (0.0301423 - 0.0289579)/0.0289579 = 4.1% which seems about right, given the [hand, eye, mouse] problems (I'm being lazy, as everything could be magnified)
Notice the "discontinuity" at the junction of the 1871-1926 and 1926-2020 trends.
+-----+
For QNial simple programming code, see :
link d_Qndfs link d_Qndfs 'semi-log formula.ndf'
qnial> test_SP500_1871_1926
********
test_SP500_1871_1926
+-------------+-------+------+--------------+
|parameter : |xStart |yStart|semi-log slope|
+-------------+-------+------+--------------+
|standard : |1871.08| 6.09| 0.000140925|
+-------------+-------+------+--------------+
|calculated : |1871.08| 6.09|0.000140925 |
+-------------+-------+------+--------------+
+-------------+---------+---------+---------+
|dateStrings |01Feb1871|01Feb1923|01Apr1926|
+-------------+---------+---------+---------+
|years |1871.08 |1923.08 |1926.25 |
+-------------+---------+---------+---------+
|standard : | 6.09| 6.19363| 6.2|
+-------------+---------+---------+---------+
|calculated : | 6.09| 6.19363| 6.2|
+-------------+---------+---------+---------+
qnial> test_SP500_1926_2020
********
test_SP500_1871_1926
+-------------+-------+------+--------------+
|parameter : |xStart |yStart|semi-log slope|
+-------------+-------+------+--------------+
|standard : |1926.25| 6.2| 0.0289587|
+-------------+-------+------+--------------+
|calculated : |1926.25| 6.2|0.0289587 |
+-------------+-------+------+--------------+
+-------------+---------+---------+---------+
|dateStrings |01Apr1926|01Jan1941|01Sep2020|
+-------------+---------+---------+---------+
|years |1926.25 |1941. |2020.67 |
+-------------+---------+---------+---------+
|standard : | 6.2| 13.34| 3361.99|
+-------------+---------+---------+---------+
|calculated : | 6.2| 16.5774| 3361.99|
+-------------+---------+---------+---------+
Notes :
- 15Sep2020 Note the difference for 01Jan1941. This is because the "standard" used 1941 as the end-point of the trend line, whereas the "calculated" used 2020 as the end-point.
- This is a nice illustration of typical errors in my measurements off the TradingView chart -> [eyes, hand, mouse].
qnial program :
/media/bill/PROJECTS/Qnial/MY_NDFS/semi-log formula.ndf
********
14Sep2020 SP500 back to 1872
TradingView charts back to 1872, but where can I find the data?
- perhaps download from TradingView? - I printed a chart of TradingBView going back to 1872, but now I can't find it? SPCFD:SPX https://www.tradingview.com/symbols/SPX/?exchange=SP
>> OK!!! this worked (yeah!))
- earliest data so far from Yahoo finance 1928-present
https://finance.yahoo.com/quote/%5EGSPC/history
https://www.macrotrends.net/2324/sp-500-historical-chart-data
S&P 500 Index - 90 Year Historical Chart
Interactive chart of the S&P 500 stock market index since 1927. Historical data is inflation-adjusted using the headline CPI and each data point represents the month-end closing value. The current month is updated on an hourly basis with today's latest value. The current price of the S&P 500 as of September 11, 2020 is 3,340.97
https://politicalcalculations.blogspot.com/2006/12/sp-500-at-your-fingertips.html#.X1_REqZ7lhE
>> goes back to 1871, but I can't get the data
Try : use TradingView chart - extract data with image program
search "extract data pints from an image of a graph"
https://automeris.io/WebPlotDigitizer/
WebPlotDigitizer
Web based tool to extract data from plots, images, and maps
Free to use, opensource and cross-platform (web and desktop)
capture TradingView graph in hi-res :
/media/bill/SWAPPER/Website - raw/economics, markets/SP500/SP500 1972-2020 TradingView, using WebPlotDigitizer.png>> works well!
I saved to :
/media/bill/SWAPPER/Website - raw/economics, markets/SP500/SP500 1972-2020 TradingView, using WebPlotDigitizer.dat
+-----+
I took Pro+ upgrade to TradingView to download data <300$US /yr - start paying in Jan2021
https://www.tradingview.com/pine-script-docs/en/v4/essential/Sessions_and_time_functions.html
This is the “Bar date/time” script:
//@version=4
study("Bar date/time")
plot(time)
The time variable returns the date/time (timestamp) of each bar’s opening time in UNIX format [1] and in the exchange’s timezone. As can be seen from the screenshot, the time value on the last bar is equal to 1397593800000. This value is the number of milliseconds that have passed since 00:00:00 UTC, 1 January, 1970 and corresponds to Tuesday, 15th of April, 2014 at 20:30:00 UTC. The chart’s time gauge in the screenshot shows the time of the last bar as 2014-04-15 16:30 because it has a 4-hour difference between the exchange’s timezone, which is the default time returned by the time function.
https://kodify.net/tradingview/date-time/time-values/
Unix time: measuring seconds since 1970
Unix time (also called epoch time and POSIX time) is a system that describes a point in time based on how many seconds passed since 00:00 UTC on Thursday January 1, 1970 (Wikipedia, 2019). That means a Unix timestamp is the difference in seconds between some date and time and January 1, 1970.
https://www.libreofficehelp.com/date-time-formats-libreoffice-calc/
Dates are stored as numbers in Calc and each day represents a number counted from the date Dec 12, 1899. However, you can change it from the menu Tools -> Options -> LibreOffice Calc -> Calculate.
/media/bill/SWAPPER/Website - raw/economics, markets/SP500/z_Old/SP500 1872-2020 from TradingView old data.dat
# enddoc