(ich verteile die Datenimport-Beschreibung auf einzelne Posts pro exchange, hier jetzt Bitcoin Central)Datenimport Bitcoin CentralImportEs gibt derzeit keinen automatischen export der Trade-Daten von bitcoin-central.net :-(. Ich hatte vor einiger Zeit davout (PM me for his email-address if you need it) angelabert er mailte mir einen CSV export. Header sieht so aus:
ID,"Account operation type","Operation ID","Operation type","Traded BTC","Traded currency","Price per coin","BTC address","E-mail address","Transaction ID",Amount,Currency,"Created at","Updated at","Value date"
Damit können wir die Tabelle 'bitcoin_central' anlegen und befüllen:
bitbuch=# drop table bitcoin_central;
bitbuch=# create table bitcoin_central (id int, account_operation_type varchar(16), operation_id int, operation_type varchar(16), BTC_traded decimal(20,8), FIAT_traded decimal(20,8), rate decimal(20,8), BTC_address varchar(52), email varchar(30), trans_id varchar(64), trans_amount decimal(20,8), trans_currency varchar(3), datum_created timestamp, datum_updated timestamp, datum_value timestamp);
bitbuch=# copy bitcoin_central(id, account_operation_type, operation_id, operation_type, BTC_traded, FIAT_traded, rate, BTC_address, email, trans_id, trans_amount, trans_currency, datum_created, datum_updated, datum_value)
from '/path/bitcoin_central.csv' delimiter ',' CSV HEADER;
Dannach prüfen wie im ersten Post unter "Datenimport" beschrieben.
tradesJetzt können wir die Tabelle 'trades' befüllen:
bitbuch=# delete from trades where exchange = 'bitcoin_central';
bitbuch=# insert into trades(exchange, datum, trade_id, fiat_currency, delta_BTC, delta_fiat, delta_EUR, fee_BTC, fee_fiat, fee_EUR)
bitbuch=# select 'bitcoin_central' as exchange, datum_value, operation_id, 'EUR' as fiat_currency,
sum(case when trans_currency = 'BTC' and account_operation_type = 'NULL' then trans_amount else 0 end) as delta_BTC,
sum(case when trans_currency = 'EUR' and account_operation_type = 'NULL' then trans_amount else 0 end) as delta_fiat,
sum(case when trans_currency = 'EUR' and account_operation_type = 'NULL' then trans_amount else 0 end) as delta_EUR,
-sum(case when trans_currency = 'BTC' and account_operation_type = 'Fee' then trans_amount else 0 end) as fee_BTC,
-sum(case when trans_currency = 'EUR' and account_operation_type = 'Fee' then trans_amount else 0 end) as fee_fiat,
-sum(case when trans_currency = 'EUR' and account_operation_type = 'Fee' then trans_amount else 0 end) as fee_EUR
from bitcoin_central
where operation_type = 'Trade'
group by datum_value, operation_id, fiat_currency
order by datum_value;