Use this

=SUM((Table1[Security]=TRANSPOSE(IF(Table2[Type]="Stock",Table2[Security],"")))*(Table1[Value]))