Part two, OFZ bond market screening

After I had a little understanding of how to minimize financial losses, I started to borrow some code from Kaggle Learn. With the help of which I will try to show in this article how to determine which positions are better not to climb while you still do not understand the market well.

Since all small players have been squeezed out of high-frequency trading, we will not consider it here; in an attempt to reach half a percent of profits from an average bank deposit, we will use the precursor of a signal bot with greater reliance on technical market analysis.

Background:

I became interested in stock exchange trading after learning about forex, the initial study of technical analysis made it clear how the kitchen is arranged and I abandoned trading until I started playing Eve Online. In this MMO, by a strange coincidence, I was mostly engaged in trading. Then, when Eve got boring, I opened a brokerage account for 10 thousand rubles.

  1. In the first iteration, I won 3.6% per annum on shares with an average interest rate on bank deposits of 8%.

  2. In the second iteration, seeing the sadness with dividend payments, I decided to switch to the bond market, before understanding what duration is, I lost about 4% of my brokerage account, having invested at the wrong time, in the wrong bonds … having greatly overestimated the trend towards recovery of the Russian economy.

  3. In the third iteration, after futile attempts to write something useful in bare Python, I figured out the pandas library a little – thanks to which, within a month, I recouped about half a percent to a percent of the losses previously incurred by bonds, starting to redistribute the shares of investments in bonds.

Federal Reserve Bond Market Screening:

So, in order to get out of the average minus on the brokerage account, caused by the untimely investment of the majority of funds that I don’t mind losing… in an attempt to recoup, in OFZ bonds with a duration until 2038… first of all, I needed to study the maximum possible number of bonds in an acceptable time.

Study using a table:

Shows the monthly gain or loss as a percentage per annum for each bond of interest. Bonds are sorted by the level of overall decline from October to date.

Diversification should be better balanced diversification, which means that buying mid-grade bonds for storage does not make sense yet, since the accumulated coupon income will be slightly less than the fall in the value of the bonds themselves. It is better to gradually get rid of the 243 purchased in hopes of economic recovery in favor of 234. Well, and slowly we need to look for a couple more positions to open, since everything is so sad with OFZ.

Studying with graphs:

The bonds are also sorted, from the most profitable to the most unprofitable, having looked a little closer at the charts, the question arises – if suddenly the bottom of 243 is soon reached, wouldn't it be easier to combine their sales with small speculations, not so much for the sake of further losses from resale at falling rates, but for practice in feeling the market.

Histogram research:

During the year 207 traded well up to 88, then there was a collapse to 86, then weak trading against the backdrop of a decline to 84 … 219, 226 similarly with a slight shift in price

234 during the year, single growth to 90, single fall to 88 and excellent trades between 88 and 90

243 traded well to 85, then a pronounced drop from 85 to 80, weak and dangerous trades from 80 to 76, drop 76 – 74, very weak and dangerous trades 74-68

Over the last 2 months: 226 moderate fall from 88 to 87, good trades at 86.5 slight fall at 86, good trades at 85

234 good trades in sideways flat at 89+89.7, one-time jump to 90

243 down 74-71, fair and somewhat dangerous trades 70-68

To sum it up, the picture of the last 2 months on the bond market looks somewhat more optimistic than over the last year.

Study with scatterplots:

Scatter plots help to assess the market situation after the last trend reversal. Plateau or bottom phases, if I am not mistaken, which are sometimes marked on candlesticks by a head and shoulders figure.

234: 87.6-88.1 growth after 2 cycles of fluctuations, and then very good trades from 88 to 90

226: satisfactory trading up to 88.8 amid a slight decline, over 10 days a decline to 86.7, then 14 days of trading in the region of 86.5, then a decline of half a percent in 2-3 days, then 24 days of trading at the level of 85.7 – 84.8

Trading looks a bit risky with 38 days of trading down slightly, with 16 days down 2.5%

243: fair trading with a slight drop from 88 to 84.5, then a drop to 79.5, then poor trading with a drop to 76.5, a drop to 73.2, then very poor trading

Further study of breaks in the table:

243 shows excellent trading, amid minimal price declines

207 demonstrate excellent trading against the backdrop of a slightly greater price decline than the minimum until mid-May 2024, then an extremely rapid decline on May 24, then rather risky trading against the backdrop of a pronounced price decline.

243 are showing a bit of a dangerous trade amid a moderate decline in prices in mid-February, then a moderate decline in March, very questionable for trading, a slightly smaller decline in May, questionable for trading, a sharp decline in May, a moderate decline since the end of May, questionable for trading

Results and conclusions:

  • Probably the future bot showed me in detail the main mistake of the 2nd stage of investments, when I changed from trading shares to holding bonds.

  • Based on the analysis of the historical part, it became clear that at the historical stage from approximately February 2024 to the present day, it was best to invest in bonds with a low duration.

  • Bonds with a duration until 2038, if held, bring losses from their decline much greater than the profit from their Accrued Coupon Income.

  • By starting to transfer funds from 243 to 234, I recouped about half a percent of the losses incurred by holding 243 for a long time.

  • With a low level of coding, bare Python will not bring any insight into studying historical data.

  • After connecting pandas, a table appeared that helped to make a high-quality choice of a new position.

  • After learning seaborn and matplotlib I was able to detail my errors quantitatively

  • As a preparation before writing a signal bot, it will be useful to study the historical situation on the market using Python and Data Science libraries.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *