The invention discloses a
stock prediction method and
system based on time constraint comparative learning, and the method comprises the steps: obtaining the historical daily frequency
transaction data of a stock, including an opening price, a closing price, a highest price, a lowest price, and a trading volume; preprocessing the data and dividing the data into a
training set, a
verification set and a
test set; constructing a
time sequence prediction model with independent fragments; constructing positive and negative samples based on time constraints; designing a
loss function and training the model; and the model predicts and outputs the stock yield. Through the
time sequence encoder with independent segments, the problem of data offset existing in the stock market can be effectively solved, generalization on a
test set is improved, positive and negative samples are constructed through comparative learning, stock
modes with similar incomes can be effectively captured, and through time constraint, the influence of big trend on stock incomes in different periods can be eliminated.