Context. Using the 1.56 m telescope at the Shanghai Observatory (ShAO), China, we monitored two sources, BL Lac object S5 0716+714 and flat spectrum radio quasar (FSRQ) 3C 273. For S5 0716+714, we report 4969 sets of CCD (Charge-coupled Device) photometrical optical observations (1369 for V band, 1861 for R band and 1739 for I band) in the monitoring time from Results. The two sources both show IDV properties for S5 0716+714. The timescales are in the range from 17.3 min to 4.82 h; for 3C 273, the timescale is ∆T = 35.6 min. Based on the periodic analysis methods, we find the periods P V = 24.24 ± 1.09 days, P R = 24.12 ± 0.76 days, P I = 24.82 ± 0.73 days for S5 0716+714, and P = 12.99 ± 0.72, 21.76 ± 1.45 yr for 3C 273. The two sources displayed the "bluer-when-brighter" spectral evolution properties. Conclusions. S5 0716+714 and 3C 273 are frequently studied objects. The violent optical variability and IDV may come from the jet. Gaussian fitting can be used to analyze IDVs. The relations between brightness (flux density) and spectrum are strongly influenced by the frequency.