We discuss the asset allocation problem in the important class of parametric non-linear time series models called the threshold autoregressive model in (J. Roy. Statist. Soc. Ser. A 1977; 140:34-35; Patten Recognition and Signal Processing. Sijthoff and Noordhoff: Netherlands, 1978; and J. Roy. Statist. Soc. Ser. B 1980; 42:245-292). We consider two specific forms, one self-exciting (i.e. the SETAR model) and the other smooth (i.e. the STAR) model developed by Chan and Tong (J. Time Ser. Anal. 1986; 7:179-190). The problem of maximizing the expected utility of wealth over a planning horizon is considered using a discrete-time dynamic programming approach. This optimization approach is flexible enough to deal with the optimal asset allocation problem under a general stochastic dynamical system, which includes the SETAR model and the STAR model as particular cases. Numerical studies are conducted to demonstrate the practical implementation of the proposed model. We also investigate the impacts of non-linearity in the SETAR and STAR models on the optimal portfolio strategies.