-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathindex.js
33 lines (25 loc) · 793 Bytes
/
index.js
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
const axios = require("axios");
const SYMBOL = "BTCUSDT";
const BUY_PRICE = 34160;
const SELL_PRICE = 34501;
const API_URL = "https://testnet.binance.vision";//https://api.binance.com
let isOpened = false;
async function start() {
const { data } = await axios.get(API_URL + "/api/v3/klines?limit=21&interval=15m&symbol=" + SYMBOL);
const candle = data[data.length - 1];
const price = parseFloat(candle[4]);
console.clear();
console.log("Price: " + price);
if(price <= BUY_PRICE && isOpened === false){
console.log("comprar");
isOpened = true;
}
else if(price >= SELL_PRICE && isOpened === true){
console.log("vender");
isOpened = false;
}
else
console.log("aguardar");
}
setInterval(start, 3000);
start();