-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
112 lines (103 loc) · 3.76 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bitforex Transaction To CSV</title>
</head>
<body>
<h1 style="color: red;">THIS SITE IS HOSTED ON GITHUB YOU CAN SEE ALL THE CODE, NONE OF YOUR DATA WILL BE STORED IT IS ALL DONE IN THE BROWSER</h1>
<a href="https://github.com/hashn3rd/bitforex-transactions-json-to-csv-tool">https://github.com/hashn3rd/bitforex-transactions-json-to-csv-tool</a>
<h1>Bitforex Transaction JSON to CSV</h1>
<p>This site is intended to help you download your bitforex transaction data since no option to download is provided.</p>
<h2>Getting the data</h2>
<p>You can use the private bitforex api that is used to display your order history page to download your bitforex transactions as json</p>
<p>YOU MUST BE LOGGED INTO BITFOREX FOR THIS TO WORK</p>
<code>
https://www.bitforex.com/server/cointrade.act?cmd=getCompleteOrders&orderstate=6&busitype=coin-usdt-omi&size=100&page=1
</code>
<p>If you need more results, you can increase size=100 past the value 100</p>
<p>If changing size doesn't give you all the results you need you can change page to another number</p>
<p>If you need other coins you can chain busitype=coin-usdt-omi to usdt-btc or btc-eth etc</p>
<p>Once you have the data you can use the form below to convert it</p>
<h2>JSON to CSV</h2>
<textarea rows="20" cols="50" id="in"></textarea>
<button id="convert">Convert</button>
<textarea rows="20" cols="50" id="out"></textarea>
<script>
function getStatus(status) {
switch (status) {
case 0:
return 'not closed';
case 1:
return 'partial transaction';
case 2:
return 'completed';
case 3:
return 'partial canceled';
case 4:
return 'all revoked';
}
}
function formatTransaction(transaction) {
return {
orderid: transaction.orderid,
symbol: transaction.busitype,
total: transaction.dealAmount,
fee: transaction.tradeFee,
type: transaction.tradeType === 1 ? 'buy' : 'sell',
amount: transaction.orderAmount,
price: transaction.orderPrice,
transaction_created: new Date(transaction.createTime),
transaction_completed: new Date(transaction.endTime),
status: getStatus(transaction.orderState),
}
}
function extractData(transactions) {
const {data} = transactions;
return data.map(e => formatTransaction(e));
}
function generateCSVRow(transaction) {
return [
transaction.orderid,
transaction.transaction_created,
transaction.transaction_completed,
transaction.symbol,
transaction.type,
transaction.amount,
transaction.price,
transaction.fee,
transaction.total,
transaction.status
];
}
const HEADERS = [
'Order Id',
'Date Created',
'Date Completed',
'Symbol',
'Type',
'Amount',
'Price',
'Fee',
'Total',
'Status'
];
function generateCSV(transactions) {
const out = [HEADERS.join(',')];
for(const transaction of transactions) {
out.push(generateCSVRow(transaction).join(','));
}
return out.join('\n');
}
// generateCSV(extractData(data))
const input = document.getElementById('in');
const convert = document.getElementById('convert');
const out = document.getElementById('out');
convert.addEventListener('click', e => {
console.log(input.value);
const json = JSON.parse(input.value);
out.value = generateCSV(extractData(json));
});
</script>
</body>
</html>