How to determine the coin amount needed for vin?
it seems the coin amount of vin calculated from vout.


It is. vin just references a vout from a previous transaction. Each output (vout) are referenced with the txid and an index (e.g. 0 or 1, because there can be multiple outputs in the same tx).

For more information about how transaction inputs and outputs work, see In getrawtransaction, what is the vout integer in the vin list?