Would you like to use the same linear layers for both inputs?
If so, you could just create a tensor of the shape [batch_dim, nb_stocks, in_features] and the layers will be applied on each nb_stock dimension.