Against the background of the gradual deepening of China Railway’s market-oriented reform, and in order to improve the revenue and competitiveness for high-speed railway (HSR) passenger transport, this paper studies the joint optimization problem of the high-speed railway ticket pricing and allocation considering the dynamic demand characteristics of passengers during the pre-sale period. Firstly, we use the compound non-homogeneous Poisson process to describe the passengers' ticket-purchasing process and use the sparse method to simulate the passengers' ticket demand during the pre-sale period. Secondly, taking the ticket pricing and allocation as the decision variables and considering the full utilization of the train seat capacity, a stochastic nonlinear-programming mathematical model is established with the goal of maximizing the train revenue. A particle swarm algorithm is designed to solve the model. Finally, this study takes the G19 train running on the Beijing–Shanghai HSR in China as a case study to verify the effectiveness of the model and algorithm. The results show that the joint optimization scheme of ticket pricing and allocation considering dynamic demand yields a revenue of CNY 601,881, which increases the revenue by 1.01% with a small adjustment of the price compared with the fixed ticket price and pre-allocation scheme. This study provides scientific support for the decisions made by railway transportation enterprises, which is conducive to further increasing the potential ticket revenue and promoting sustainable development.