Can we use data from other U.S. stocks other than the S & P 500? Can I use all the functions above qlib to get data?

You can only use securities which are listed by getTickersSP500() to invest and by getTickersSP500Data() to help you create portfolio weights.