-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbtce.js
More file actions
92 lines (85 loc) · 2.06 KB
/
Copy pathbtce.js
File metadata and controls
92 lines (85 loc) · 2.06 KB
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
BtcePair =
{
btc_usd: 1,
btc_rur: 17,
btc_eur: 19,
ltc_btc: 10,
ltc_usd: 14,
ltc_rur: 21,
ltc_eur: 27,
nmc_btc: 13,
nmc_usd: 28,
nvc_btc: 22,
nvc_usd: 29,
usd_rur: 18,
eur_usd: 20,
trc_btc: 23,
ppc_btc: 24,
ppc_usd: 31,
ftc_btc: 25,
xpm_btc: 30,
};
var BTCE =
{
getTicker: function (pair, result)
{
$.getJSON("https://btc-e.com/api/2/" + pair + "/ticker", result);
},
getDepth: function(pair, result)
{
$.getJSON("https://btc-e.com/api/2/" + pair + "/depth", result);
},
getTrades: function(pair, result)
{
$.getJSON("https://btc-e.com/api/2/" + pair + "/trades", result);
},
getFees: function(method, price, pair, result)
{
$.ajax({
type: "POST",
url: "https://btc-e.com/ajax/order",
data:
{
calculate: method,
btc_count: 1,
btc_price: price,
pair: pair
},
success: function (data)
{
result(data["fee"]);
}
});
}
};
function BTCETrading(api_key, api_secret)
{
nonce = Math.round((new Date()).getTime() / 1000);
requestHelper = function (postArgs, result)
{
postArgs["nonce"] = nonce.toString();
nonce++;
var data = "";
$.each(postArgs, function (key, value)
{
data += key + "=" + value + '&';
});
if (data.length > 0)
data = data.substring(0, data.length - 1);
var hash = CryptoJS.HmacSHA512(data, api_secret);
$.ajax({
url: "https://btc-e.com/tapi",
type: 'post',
data: postArgs,
headers: {
Key: api_key,
Sign: hash.toString(CryptoJS.enc.Hex).toLowerCase()
},
success: result
});
}
this.getInfo = function(result)
{
requestHelper({ "method": "getInfo" }, result);
}
}