Showing
1 changed file
with
23 additions
and
59 deletions
... | @@ -12,8 +12,6 @@ const HTTPS = require('https'); | ... | @@ -12,8 +12,6 @@ const HTTPS = require('https'); |
12 | const domain = "2019102152.osschatbot.ga" | 12 | const domain = "2019102152.osschatbot.ga" |
13 | const sslport = 23023; | 13 | const sslport = 23023; |
14 | const TARGET_URL = 'https://api.line.me/v2/bot/message/reply' | 14 | const TARGET_URL = 'https://api.line.me/v2/bot/message/reply' |
15 | - | ||
16 | - | ||
17 | const bodyParser = require('body-parser'); | 15 | const bodyParser = require('body-parser'); |
18 | const crypto = require('crypto'); | 16 | const crypto = require('crypto'); |
19 | const queryEncode = require('querystring').encode; | 17 | const queryEncode = require('querystring').encode; |
... | @@ -38,7 +36,7 @@ app.use(bodyParser.json()); | ... | @@ -38,7 +36,7 @@ app.use(bodyParser.json()); |
38 | const connect = mongoose.connect(config.mongoURI, { | 36 | const connect = mongoose.connect(config.mongoURI, { |
39 | useNewUrlParser: true, useUnifiedTopology: true | 37 | useNewUrlParser: true, useUnifiedTopology: true |
40 | }) | 38 | }) |
41 | - .then(() => console.log('디비연결 성공')) | 39 | + .then(() => console.log('db connected...')) |
42 | .catch((err) => console.log(err)); | 40 | .catch((err) => console.log(err)); |
43 | 41 | ||
44 | 42 | ||
... | @@ -69,18 +67,15 @@ function get_asset(market) { | ... | @@ -69,18 +67,15 @@ function get_asset(market) { |
69 | if (data[i].currency == "KRW") { | 67 | if (data[i].currency == "KRW") { |
70 | current_asset += Number(data[i].balance); | 68 | current_asset += Number(data[i].balance); |
71 | pre_asset += Number(data[i].balance); | 69 | pre_asset += Number(data[i].balance); |
72 | - // hold_coin[data[i].currency]={volume:data[i].balance}; | ||
73 | } else { | 70 | } else { |
74 | pre_asset += Number(data[i].balance * data[i].avg_buy_price) | 71 | pre_asset += Number(data[i].balance * data[i].avg_buy_price) |
75 | candle = await get_candle(5, "KRW-" + data[i].currency); | 72 | candle = await get_candle(5, "KRW-" + data[i].currency); |
76 | current_asset += Number(candle[0].trade_price * data[i].balance); | 73 | current_asset += Number(candle[0].trade_price * data[i].balance); |
77 | - // hold_coin[data[i].currency]={avg_buy_price:data[i].avg_buy_price,volume:data[i].balance,current_price:candle[0].trade_price}; | ||
78 | } | 74 | } |
79 | } | 75 | } |
80 | resolve({ pre_asset: pre_asset.toFixed(0).replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ","), current_asset: current_asset.toFixed(0).replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ","), profit_data: (current_asset - pre_asset).toFixed(0).replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ",") , yield_data: Number((current_asset - pre_asset) / pre_asset * 100).toFixed(2).replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ",") }); | 76 | resolve({ pre_asset: pre_asset.toFixed(0).replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ","), current_asset: current_asset.toFixed(0).replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ","), profit_data: (current_asset - pre_asset).toFixed(0).replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ",") , yield_data: Number((current_asset - pre_asset) / pre_asset * 100).toFixed(2).replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ",") }); |
81 | } else if (market == "coin") { | 77 | } else if (market == "coin") { |
82 | var hold_coin = new Object(); | 78 | var hold_coin = new Object(); |
83 | - | ||
84 | for (var i = 0; i < data.length; i++) { | 79 | for (var i = 0; i < data.length; i++) { |
85 | var candle; | 80 | var candle; |
86 | if (data[i].currency == "KRW") { | 81 | if (data[i].currency == "KRW") { |
... | @@ -90,20 +85,21 @@ function get_asset(market) { | ... | @@ -90,20 +85,21 @@ function get_asset(market) { |
90 | var avg_buy_price = Number(data[i].avg_buy_price).toFixed(data[i].avg_buy_price < 1 ? 3 : 0) | 85 | var avg_buy_price = Number(data[i].avg_buy_price).toFixed(data[i].avg_buy_price < 1 ? 3 : 0) |
91 | var volume = Number(data[i].balance).toFixed(8); | 86 | var volume = Number(data[i].balance).toFixed(8); |
92 | var current_price = Number(candle[0].trade_price).toFixed(data[i].current_price < 1 ? 3 : 0); | 87 | var current_price = Number(candle[0].trade_price).toFixed(data[i].current_price < 1 ? 3 : 0); |
88 | + var buying_money=(avg_buy_price*volume).toFixed(0).toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ",");; | ||
89 | + var evaluation_money=(current_price*volume).toFixed(0).toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ",");; | ||
93 | var yield_data = (current_price - avg_buy_price) / avg_buy_price * 100; | 90 | var yield_data = (current_price - avg_buy_price) / avg_buy_price * 100; |
94 | yield_data = Number(yield_data).toFixed(2); | 91 | yield_data = Number(yield_data).toFixed(2); |
95 | avg_buy_price = avg_buy_price.toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ","); | 92 | avg_buy_price = avg_buy_price.toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ","); |
96 | volume = volume.toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ","); | 93 | volume = volume.toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ","); |
97 | current_price = current_price.toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ","); | 94 | current_price = current_price.toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ","); |
98 | yield_data = yield_data.toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ","); | 95 | yield_data = yield_data.toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ","); |
99 | - hold_coin[data[i].currency] = { avg_buy_price, volume, current_price, yield_data }; | 96 | + hold_coin[data[i].currency] = { avg_buy_price, volume, current_price, yield_data,buying_money,evaluation_money }; |
100 | } | 97 | } |
101 | } | 98 | } |
102 | resolve(hold_coin); | 99 | resolve(hold_coin); |
103 | } else { | 100 | } else { |
104 | data.filter(function (item) { | 101 | data.filter(function (item) { |
105 | if (item.currency == market.split('-')[1]) { | 102 | if (item.currency == market.split('-')[1]) { |
106 | - // resolve(item); | ||
107 | empty.market = item; | 103 | empty.market = item; |
108 | } else if (item.currency == "KRW") { | 104 | } else if (item.currency == "KRW") { |
109 | empty.KRW = item | 105 | empty.KRW = item |
... | @@ -120,7 +116,6 @@ function get_asset(market) { | ... | @@ -120,7 +116,6 @@ function get_asset(market) { |
120 | } | 116 | } |
121 | async function get_marketName() { | 117 | async function get_marketName() { |
122 | var data = new Array(); | 118 | var data = new Array(); |
123 | - //전체 암호화폐 리스트 불러오기 | ||
124 | let response = await fetch(`${server_url}/v1/market/all`, options) | 119 | let response = await fetch(`${server_url}/v1/market/all`, options) |
125 | .then(res => res.json()) | 120 | .then(res => res.json()) |
126 | .then(json => { | 121 | .then(json => { |
... | @@ -150,8 +145,6 @@ async function transaction_coin(coin_name, side, volume, price, ord_type, first | ... | @@ -150,8 +145,6 @@ async function transaction_coin(coin_name, side, volume, price, ord_type, first |
150 | price: price, | 145 | price: price, |
151 | ord_type: ord_type, | 146 | ord_type: ord_type, |
152 | } | 147 | } |
153 | - //시장가 매수인 경우 price를 얼마치 살건지 입력 | ||
154 | - //시장가 매도인경우 volume에 몇개를 팔건지 입력 | ||
155 | const query = queryEncode(body) | 148 | const query = queryEncode(body) |
156 | const hash = crypto.createHash('sha512') | 149 | const hash = crypto.createHash('sha512') |
157 | const queryHash = hash.update(query, 'utf-8').digest('hex') | 150 | const queryHash = hash.update(query, 'utf-8').digest('hex') |
... | @@ -183,40 +176,31 @@ async function transaction_coin(coin_name, side, volume, price, ord_type, first | ... | @@ -183,40 +176,31 @@ async function transaction_coin(coin_name, side, volume, price, ord_type, first |
183 | lookup_order(result.uuid); | 176 | lookup_order(result.uuid); |
184 | } | 177 | } |
185 | if (side == "bid") { | 178 | if (side == "bid") { |
186 | - //처음 매수일 때 | ||
187 | if (first) { | 179 | if (first) { |
188 | const user = new User({ uid: 1, krw_balance: my_asset.KRW.balance, market: coin_name, count: 1, avg_buy_price: my_asset.market.avg_buy_price, volume: my_asset.market.balance }); | 180 | const user = new User({ uid: 1, krw_balance: my_asset.KRW.balance, market: coin_name, count: 1, avg_buy_price: my_asset.market.avg_buy_price, volume: my_asset.market.balance }); |
189 | await user.save().then(() => { isuser = true }) | 181 | await user.save().then(() => { isuser = true }) |
190 | - //2회 이상 매수일 때 | ||
191 | } else { | 182 | } else { |
192 | User.findOneAndUpdate({ uid: 1 }, { krw_balance: my_asset.KRW.balance, avg_buy_price: my_asset.market.avg_buy_price, volume: my_asset.market.balance, $inc: { count: 1 } }, { new: true }, (err, result) => { | 183 | User.findOneAndUpdate({ uid: 1 }, { krw_balance: my_asset.KRW.balance, avg_buy_price: my_asset.market.avg_buy_price, volume: my_asset.market.balance, $inc: { count: 1 } }, { new: true }, (err, result) => { |
193 | if (err) { | 184 | if (err) { |
194 | - // console.log(err); | 185 | + console.log(err); |
195 | } else { | 186 | } else { |
196 | - // console.log(result); | ||
197 | } | 187 | } |
198 | }) | 188 | }) |
199 | } | 189 | } |
200 | } else if (side == "ask") { | 190 | } else if (side == "ask") { |
201 | - //1회 매수 후 매도일 때 | ||
202 | - console.log("매도 쪽으로 진입"); | ||
203 | if (first) { | 191 | if (first) { |
204 | - console.log("1회 매수 후 매도") | 192 | + User.findOneAndDelete({market:coin_name},(err,res)=>{ |
205 | - User.deleteOne({ market: coin_name }, (err, res) => { | 193 | + if(err){ |
206 | - if (err) { | 194 | + console.log(err); |
207 | - // console.log(err); | 195 | + }else{ |
196 | + krw_balance=my_asset.KRW.balance; | ||
197 | + divided_money=krw_balance/10; | ||
208 | } | 198 | } |
209 | - krw_balance = my_asset.KRW.balance; | 199 | + }) |
210 | - divided_money = krw_balance / 10; | ||
211 | - }); | ||
212 | - //분할 매수 분할 매도 중일 때 | ||
213 | } else { | 200 | } else { |
214 | - console.log("여러번 매수 후 매도"); | ||
215 | User.findOneAndUpdate({ uid: 1 }, { krw_balance: my_asset.KRW.balance, avg_buy_price: my_asset.market.avg_buy_price, volume: my_asset.market.balance, count: 1 }, { new: true }, (err, result) => { | 201 | User.findOneAndUpdate({ uid: 1 }, { krw_balance: my_asset.KRW.balance, avg_buy_price: my_asset.market.avg_buy_price, volume: my_asset.market.balance, count: 1 }, { new: true }, (err, result) => { |
216 | if (err) { | 202 | if (err) { |
217 | - // console.log(err); | 203 | + console.log(err); |
218 | - } else { | ||
219 | - console.log(result); | ||
220 | } | 204 | } |
221 | }) | 205 | }) |
222 | } | 206 | } |
... | @@ -225,7 +209,6 @@ async function transaction_coin(coin_name, side, volume, price, ord_type, first | ... | @@ -225,7 +209,6 @@ async function transaction_coin(coin_name, side, volume, price, ord_type, first |
225 | return; | 209 | return; |
226 | } | 210 | } |
227 | async function get_marketInfo() { | 211 | async function get_marketInfo() { |
228 | - //각 암호화폐 정보 조회 | ||
229 | var name_list = await get_marketName(); | 212 | var name_list = await get_marketName(); |
230 | const url2 = `${server_url}/v1/ticker/?markets=${name_list}`; | 213 | const url2 = `${server_url}/v1/ticker/?markets=${name_list}`; |
231 | var arr = new Array(); | 214 | var arr = new Array(); |
... | @@ -259,7 +242,7 @@ async function save_coin(arr) { | ... | @@ -259,7 +242,7 @@ async function save_coin(arr) { |
259 | }); | 242 | }); |
260 | await coin.save((err) => { | 243 | await coin.save((err) => { |
261 | if (err) { | 244 | if (err) { |
262 | - // console.log(err) | 245 | + console.log(err) |
263 | } | 246 | } |
264 | }) | 247 | }) |
265 | } | 248 | } |
... | @@ -272,9 +255,8 @@ async function refresh_db() { | ... | @@ -272,9 +255,8 @@ async function refresh_db() { |
272 | if (result.length !== 0) { | 255 | if (result.length !== 0) { |
273 | Coin.deleteMany({ tid: { $gt: 0 } }, (err, result) => { | 256 | Coin.deleteMany({ tid: { $gt: 0 } }, (err, result) => { |
274 | if (err) { | 257 | if (err) { |
275 | - // console.log(err); | 258 | + console.log(err); |
276 | } else { | 259 | } else { |
277 | - // console.log(result); | ||
278 | } | 260 | } |
279 | }) | 261 | }) |
280 | } | 262 | } |
... | @@ -291,36 +273,29 @@ async function get_candle(minute, market) { | ... | @@ -291,36 +273,29 @@ async function get_candle(minute, market) { |
291 | return candle; | 273 | return candle; |
292 | } | 274 | } |
293 | async function price_comparison(candle, user_data = null, isbuying = false) { | 275 | async function price_comparison(candle, user_data = null, isbuying = false) { |
294 | - //매수한 코인이 있을 때 | ||
295 | var isbuying = isbuying; | 276 | var isbuying = isbuying; |
296 | if (user_data != null) { | 277 | if (user_data != null) { |
297 | console.log("매수 평균가 : " + user_data.avg_buy_price + ", 현재 가격 : " + candle[0].trade_price); | 278 | console.log("매수 평균가 : " + user_data.avg_buy_price + ", 현재 가격 : " + candle[0].trade_price); |
298 | - //매수평균가가 현재 시장 가격보다 더 비쌀 경우 | ||
299 | var yield_data = (candle[0].trade_price - user_data.avg_buy_price) / user_data.avg_buy_price * 100; | 279 | var yield_data = (candle[0].trade_price - user_data.avg_buy_price) / user_data.avg_buy_price * 100; |
300 | if(yield_data<=-1){ | 280 | if(yield_data<=-1){ |
301 | - // if (user_data.avg_buy_price > candle[0].trade_price) { | ||
302 | if (user_data.count < 9) { | 281 | if (user_data.count < 9) { |
303 | transaction_coin(user_data.market, "bid", null, divided_money, "price", false) | 282 | transaction_coin(user_data.market, "bid", null, divided_money, "price", false) |
304 | } else if(user_data.count==9) { | 283 | } else if(user_data.count==9) { |
305 | transaction_coin(user_data.market, "bid", null, Math.floor(user_data.krw_balance-(user_data.krw_balance*0.001)), "price", false) | 284 | transaction_coin(user_data.market, "bid", null, Math.floor(user_data.krw_balance-(user_data.krw_balance*0.001)), "price", false) |
306 | } | 285 | } |
307 | - //매수평균가가 현재 시장 가격보다 더 쌀 경우 | ||
308 | - //수수료 포함 0.5% 이상 수익중일 때 | ||
309 | } else if (yield_data >= 0.5) { | 286 | } else if (yield_data >= 0.5) { |
310 | - //매수 count가 1회이면서 수익률이 1.5프로 이상일때 시장가 전액 매도 | 287 | + console.log(user_data); |
311 | - if (user_data.count == 1 && yield_data >= 1.5) { | 288 | + if (user_data.count == 1) { |
289 | + if(yield_data>=1.5){ | ||
312 | transaction_coin(user_data.market, "ask", user_data.volume, null, "market"); | 290 | transaction_coin(user_data.market, "ask", user_data.volume, null, "market"); |
313 | - //전체 계좌 제산의 10프로를 제외한 나머지 코인을 매도 | 291 | + }else{ |
292 | + } | ||
314 | } else { | 293 | } else { |
315 | transaction_coin(user_data.market, "ask", (user_data.volume / user_data.count) * (user_data.count - 1), null, "market", false); | 294 | transaction_coin(user_data.market, "ask", (user_data.volume / user_data.count) * (user_data.count - 1), null, "market", false); |
316 | } | 295 | } |
317 | } | 296 | } |
318 | - //매수한 코인이 없을 때 | ||
319 | } else { | 297 | } else { |
320 | await Coin.findOne({ name: candle[0].market }).then(async (result) => { | 298 | await Coin.findOne({ name: candle[0].market }).then(async (result) => { |
321 | - //가격이 떨어졌을때 | ||
322 | - //해당 코인의 count를 +1 해준다 | ||
323 | - //해당 코인의 count가 3이상이면 upbit api로 매수 주문을 보낸다. | ||
324 | if (candle.length!=0 && result.length!=0) { | 299 | if (candle.length!=0 && result.length!=0) { |
325 | var yield_data = (candle[0].trade_price - result.current_price) / result.current_price * 100; | 300 | var yield_data = (candle[0].trade_price - result.current_price) / result.current_price * 100; |
326 | if (result.current_price > candle[0].trade_price) { | 301 | if (result.current_price > candle[0].trade_price) { |
... | @@ -331,15 +306,12 @@ async function price_comparison(candle, user_data = null, isbuying = false) { | ... | @@ -331,15 +306,12 @@ async function price_comparison(candle, user_data = null, isbuying = false) { |
331 | isbuying = true; | 306 | isbuying = true; |
332 | } | 307 | } |
333 | }).catch(err => { console.log(err) }) | 308 | }).catch(err => { console.log(err) }) |
334 | - //가격이 상승했을때 | ||
335 | - //해당 코인의 count를 초기화한다. | ||
336 | } else if(result.current_price<candle[0].trade_price){ | 309 | } else if(result.current_price<candle[0].trade_price){ |
337 | console.log(result.korean_name + " " + candle[0].unit + "분 동안" + yield_data.toFixed(2) + "% 상승"); | 310 | console.log(result.korean_name + " " + candle[0].unit + "분 동안" + yield_data.toFixed(2) + "% 상승"); |
338 | await Coin.findOneAndUpdate({ name: candle[0].market }, { current_price: candle[0].trade_price, down_count: 0, $inc: { up_count: 1 } }, { new: true }).then(async (result) => { | 311 | await Coin.findOneAndUpdate({ name: candle[0].market }, { current_price: candle[0].trade_price, down_count: 0, $inc: { up_count: 1 } }, { new: true }).then(async (result) => { |
339 | }).catch(err => { console.log(err); }) | 312 | }).catch(err => { console.log(err); }) |
340 | } | 313 | } |
341 | }else{ | 314 | }else{ |
342 | - console.log(result); | ||
343 | } | 315 | } |
344 | }) | 316 | }) |
345 | } | 317 | } |
... | @@ -347,10 +319,8 @@ async function price_comparison(candle, user_data = null, isbuying = false) { | ... | @@ -347,10 +319,8 @@ async function price_comparison(candle, user_data = null, isbuying = false) { |
347 | } | 319 | } |
348 | async function check_coin(t1) { | 320 | async function check_coin(t1) { |
349 | User.find().then(async (user_data) => { | 321 | User.find().then(async (user_data) => { |
350 | - //매수한 코인이 있을 때 | ||
351 | var isbuying = user_data.length != 0 ? true : false; | 322 | var isbuying = user_data.length != 0 ? true : false; |
352 | if (isbuying) { | 323 | if (isbuying) { |
353 | - //3회 이상 매수 했을시 15분봉으로 교체해서 가격 확인 | ||
354 | if (user_data[0].count >= 3&&delay_count%3!=0&&user_data[0].count!=10) { | 324 | if (user_data[0].count >= 3&&delay_count%3!=0&&user_data[0].count!=10) { |
355 | delay_count+=1; | 325 | delay_count+=1; |
356 | } else { | 326 | } else { |
... | @@ -359,7 +329,6 @@ async function check_coin(t1) { | ... | @@ -359,7 +329,6 @@ async function check_coin(t1) { |
359 | await price_comparison(candle, user_data[0]); | 329 | await price_comparison(candle, user_data[0]); |
360 | } | 330 | } |
361 | } | 331 | } |
362 | - //코인 count and 매수 매도 작업 | ||
363 | for (var i = 0; i < t1.length; i++) { | 332 | for (var i = 0; i < t1.length; i++) { |
364 | if (user_data[0] && user_data[0].market == t1[i]) { | 333 | if (user_data[0] && user_data[0].market == t1[i]) { |
365 | continue; | 334 | continue; |
... | @@ -378,7 +347,6 @@ async function latest_repeat(t1) { | ... | @@ -378,7 +347,6 @@ async function latest_repeat(t1) { |
378 | let minutes = today.getMinutes(); | 347 | let minutes = today.getMinutes(); |
379 | let seconds = today.getSeconds(); | 348 | let seconds = today.getSeconds(); |
380 | if (seconds ==0) { | 349 | if (seconds ==0) { |
381 | - // if (minutes == 0 && seconds == 0) { | ||
382 | clearInterval(check_time); | 350 | clearInterval(check_time); |
383 | sort_info = (await sort_data()); | 351 | sort_info = (await sort_data()); |
384 | (await refresh_db()); | 352 | (await refresh_db()); |
... | @@ -394,7 +362,6 @@ async function latest_repeat(t1) { | ... | @@ -394,7 +362,6 @@ async function latest_repeat(t1) { |
394 | let minutes = today.getMinutes(); | 362 | let minutes = today.getMinutes(); |
395 | let seconds = today.getSeconds(); | 363 | let seconds = today.getSeconds(); |
396 | console.log("현재 시간은 " + today.toLocaleTimeString()); | 364 | console.log("현재 시간은 " + today.toLocaleTimeString()); |
397 | - //24시간마다 db 최신화... | ||
398 | if (count == 12 * 24) { | 365 | if (count == 12 * 24) { |
399 | count = 0; | 366 | count = 0; |
400 | sort_info = (await sort_data()); | 367 | sort_info = (await sort_data()); |
... | @@ -449,7 +416,7 @@ function lookup_order(uuid,avg_buy_price=0,market="") { | ... | @@ -449,7 +416,7 @@ function lookup_order(uuid,avg_buy_price=0,market="") { |
449 | if(avg_buy_price!=0){ | 416 | if(avg_buy_price!=0){ |
450 | trading_notice(body.side, price, funds, volume,yield_data,market); | 417 | trading_notice(body.side, price, funds, volume,yield_data,market); |
451 | }else{ | 418 | }else{ |
452 | - trading_notice(body.side, price, funds, volume); | 419 | + trading_notice(body.side, price, funds, volume,0,market); |
453 | } | 420 | } |
454 | }) | 421 | }) |
455 | return; | 422 | return; |
... | @@ -458,7 +425,7 @@ function trading_notice(side, price, funds, volume,yield_data=0,market="") { | ... | @@ -458,7 +425,7 @@ function trading_notice(side, price, funds, volume,yield_data=0,market="") { |
458 | var messages = new Array(); | 425 | var messages = new Array(); |
459 | if (side == "bid") { | 426 | if (side == "bid") { |
460 | messages.push({ "type": "text", "text": "매수 주문이 체결되었습니다." }); | 427 | messages.push({ "type": "text", "text": "매수 주문이 체결되었습니다." }); |
461 | - messages.push({ "type": "text", "text": `${market}\n체결 금액 : ${funds}원\n체결 수량 : ${volume}개\n체결 평균가 : ${price}원\n` }); | 428 | + messages.push({ "type": "text", "text": `${market}\n체결 금액 : ${funds}원\n체결 수량 : ${volume}개\n체결 평균가 : ${price}원` }); |
462 | } else { | 429 | } else { |
463 | messages.push({ "type": "text", "text": "매도 주문이 체결되었습니다." }); | 430 | messages.push({ "type": "text", "text": "매도 주문이 체결되었습니다." }); |
464 | messages.push({ "type": "text", "text": `${market}\n체결 금액 : ${funds}원\n체결 수량 : ${volume}개\n체결 평균가 : ${price}원\n수익률 : ${yield_data}%` }); | 431 | messages.push({ "type": "text", "text": `${market}\n체결 금액 : ${funds}원\n체결 수량 : ${volume}개\n체결 평균가 : ${price}원\n수익률 : ${yield_data}%` }); |
... | @@ -505,7 +472,6 @@ async function lookup_asset(replyToken) { | ... | @@ -505,7 +472,6 @@ async function lookup_asset(replyToken) { |
505 | ] | 472 | ] |
506 | } | 473 | } |
507 | }, (error, response, body) => { | 474 | }, (error, response, body) => { |
508 | - console.log(body) | ||
509 | }); | 475 | }); |
510 | return; | 476 | return; |
511 | } | 477 | } |
... | @@ -522,7 +488,7 @@ async function lookup_hold_coin(replyToken) { | ... | @@ -522,7 +488,7 @@ async function lookup_hold_coin(replyToken) { |
522 | } else { | 488 | } else { |
523 | messages.push({ | 489 | messages.push({ |
524 | "type": "text", | 490 | "type": "text", |
525 | - "text": `${coin_list[i]}\n보유 수량 : ${(result[coin_list[i]].volume)}개\n매수 평균가 : ${result[coin_list[i]].avg_buy_price}원\n현재가 ${result[coin_list[i]].current_price}원\n수익률 : ${result[coin_list[i]].yield_data}%` | 491 | + "text": `${coin_list[i]}\n보유 수량 : ${(result[coin_list[i]].volume)}개\n매수 평균가 : ${result[coin_list[i]].avg_buy_price}원\n현재가 ${result[coin_list[i]].current_price}원\n매수 금액 : ${result[coin_list[i]].buying_money}\n평가 금액 : ${result[coin_list[i]].evaluation_money}\n수익률 : ${result[coin_list[i]].yield_data}%` |
526 | }) | 492 | }) |
527 | } | 493 | } |
528 | } | 494 | } |
... | @@ -543,7 +509,6 @@ async function lookup_hold_coin(replyToken) { | ... | @@ -543,7 +509,6 @@ async function lookup_hold_coin(replyToken) { |
543 | }); | 509 | }); |
544 | return; | 510 | return; |
545 | } | 511 | } |
546 | - | ||
547 | app.post('/hook', function (req, res) { | 512 | app.post('/hook', function (req, res) { |
548 | var eventObj = req.body.events[0]; | 513 | var eventObj = req.body.events[0]; |
549 | if (eventObj.message.text == "자산") { | 514 | if (eventObj.message.text == "자산") { |
... | @@ -562,7 +527,6 @@ try { | ... | @@ -562,7 +527,6 @@ try { |
562 | }; | 527 | }; |
563 | HTTPS.createServer(option, app).listen(sslport, async () => { | 528 | HTTPS.createServer(option, app).listen(sslport, async () => { |
564 | console.log(`[HTTPS] Server is started on port ${sslport}`); | 529 | console.log(`[HTTPS] Server is started on port ${sslport}`); |
565 | - // console.log(await get_asset()); | ||
566 | await get_asset().then((result) => { | 530 | await get_asset().then((result) => { |
567 | krw_balance = result[0].balance; | 531 | krw_balance = result[0].balance; |
568 | divided_money = krw_balance / 10 | 532 | divided_money = krw_balance / 10 | ... | ... |
-
Please register or login to post a comment