In program trading, trading strategy is determined by forecasting the tendency of prices in the future, based on calculating historical data according to the trading model. This paper proposes a linear regression trading model. It discusses the principle of the model, algorithm implementation and efficiency in running. Finally, an optimal algorithm for linear regression in Program-trading system is obtained which is competent in a real-time calculation for plenty of historical data. The algorithm's time complexity is least.