At the age of 35, Emperor Wudi sent him to Yunnan, Sichuan, Guizhou and other places. After the death of his father Sima Tan, Sima Qian succeeded to the throne as an official.
In BC 104 (the first year of Taichu), he began to compile historical records. In 99 BC (the second year of Tian Han), Li Ling attacked the Huns and was defeated and surrendered. Emperor Wu of the Han Dynasty was furious. Sima Qian defended Li Ling and angered Emperor Wu of the Han Dynasty. He was arrested and sentenced to death.
In order to fulfill his father's last wish, complete historical records and leave them to future generations, he endured "corruption (the torture of cutting off his nose or reproductive organs)" with humiliation.
In 96 BC (the first year of Taishi), he was pardoned and released from prison, issued a written order and mastered the confidential documents of the emperor. So he worked hard to write books and devoted himself to writing historical records. Around the age of 55, he finally finished writing and revising the whole book.
Extended data:
Among the astrologers in the Han Dynasty, Sima Qian should be the first to be put forward. Everyone knows that Sima Qian is a great historian, but they don't know that he is also an expert in astronomy and astrology.
In fact, as long as you carefully read his official book in Historical Records, you can understand that calling him an expert in astronomical astrology is by no means a hollow name. A profound literary master like Sima Qian will never define his own scope and limit his own knowledge system and exploration field.
Ancient historians have always regarded ephemeris as one of their duties, so it is not surprising that they are proficient in astrology. Sima Qian did not use astrology to measure specific personnel changes, but summed up historical laws, which can not be said to be his creative application of Galaxy Studies.
References:
Baidu Encyclopedia-Sima Qian