Importing data from file with ID dependencies
The only thing I can think of is a combination of a staging table and some shell scripting. 

First step: import the raw file into a staging table, e.g. history_data_import which only contains time and value. 

Second step: extract the corresponding values for the pair table from the filename and create a SQL statement like the following:

with pair_id as (
  select id
  from pair
  where exchange = 'binance' --&lt;&lt; this is "generated"
    and base_coin = 'btc' --&lt;&lt; this is "generated"
    and quoted_coin = 'usd' --&lt;&lt; this is "generated"
)
insert into history_data (pair, time, value)
select pi.id, imp.time, imp.value
from history_data_import imp
  cross join pair_id pi;


This assumes that the combination of (exchange, base_coin, quoted_coin) is unique in the pair table so that only a single row is returned when looking up the id.

How exactly you extract the parts of the filename is a different topic and depends on the operating system you are using. On Linux this is probably a piece of cake for awk gurus. But this would better be asked on e.g. https://superuser.com/