Skip to content

Commit c88d3f1

Browse files
committed
feat: add bundled bin/app.js file
1 parent 8f68474 commit c88d3f1

File tree

1 file changed

+175
-0
lines changed

1 file changed

+175
-0
lines changed

bin/app.js

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
import $e7wri$chalk from "chalk";
2+
import $e7wri$figlet from "figlet";
3+
import $e7wri$prompts from "prompts";
4+
import {to as $e7wri$to} from "await-to-js";
5+
import $e7wri$axios from "axios";
6+
import $e7wri$ora from "ora";
7+
import $e7wri$bignumberjs from "bignumber.js";
8+
import $e7wri$precisiontradingindicators from "precision-trading-indicators";
9+
10+
11+
12+
13+
14+
15+
const $2ee3875f01c08fb7$export$5fc33d4e2758bd58 = (0, $e7wri$axios).create({
16+
baseURL: "https://api.binance.com/api/v3"
17+
});
18+
19+
20+
const $3c700f1948406e0b$export$b1319c00e04db0d9 = async (args)=>{
21+
return (0, $2ee3875f01c08fb7$export$5fc33d4e2758bd58).request({
22+
method: "GET",
23+
url: "/ticker/price",
24+
params: args
25+
});
26+
};
27+
const $3c700f1948406e0b$export$9e5c183359f8fd67 = async (args)=>{
28+
return (0, $2ee3875f01c08fb7$export$5fc33d4e2758bd58).request({
29+
method: "GET",
30+
url: "/klines",
31+
params: args
32+
});
33+
};
34+
35+
36+
37+
var $5d5c81297ed46af3$export$5128aa4ecd1280a4;
38+
(function(IntervalChoice) {
39+
IntervalChoice["MINUTE_1"] = "1m";
40+
IntervalChoice["MINUTE_3"] = "3m";
41+
IntervalChoice["MINUTE_5"] = "5m";
42+
IntervalChoice["MINUTE_15"] = "15m";
43+
IntervalChoice["MINUTE_30"] = "30m";
44+
IntervalChoice["HOUR_1"] = "1h";
45+
IntervalChoice["HOUR_2"] = "2h";
46+
IntervalChoice["HOUR_4"] = "4h";
47+
IntervalChoice["HOUR_6"] = "6h";
48+
IntervalChoice["HOUR_8"] = "8h";
49+
IntervalChoice["HOUR_12"] = "12h";
50+
IntervalChoice["DAY_1"] = "1d";
51+
IntervalChoice["DAY_3"] = "3d";
52+
IntervalChoice["WEEK_1"] = "1w";
53+
IntervalChoice["MONTH_1"] = "1M";
54+
})($5d5c81297ed46af3$export$5128aa4ecd1280a4 || ($5d5c81297ed46af3$export$5128aa4ecd1280a4 = {}));
55+
56+
57+
const $f0aed1fa18949526$export$aa40d6b8948fbc43 = {
58+
getTickers: (0, $e7wri$ora)("Fetching tickers..."),
59+
getKlines: (0, $e7wri$ora)("Fetching klines...")
60+
};
61+
const $f0aed1fa18949526$export$a867bcbce9e92f58 = Object.entries((0, $5d5c81297ed46af3$export$5128aa4ecd1280a4)).map(([title, value])=>({
62+
title: title,
63+
value: value
64+
}));
65+
const $f0aed1fa18949526$export$d102b3be7ceada42 = {
66+
timestamp: [],
67+
open: [],
68+
high: [],
69+
low: [],
70+
close: [],
71+
volume: []
72+
};
73+
74+
75+
76+
77+
78+
const $9e97c0d5330f7bcb$export$847f4ee65531b89 = (data, period = 14)=>{
79+
const indicator = new (0, $e7wri$precisiontradingindicators)((0, $e7wri$bignumberjs));
80+
const ohlcv = data.reduce((acc, [timestamp, open, high, low, close, volume])=>({
81+
timestamp: [
82+
...acc.timestamp,
83+
timestamp
84+
],
85+
open: [
86+
...acc.open,
87+
(0, $e7wri$bignumberjs)(open)
88+
],
89+
high: [
90+
...acc.high,
91+
(0, $e7wri$bignumberjs)(high)
92+
],
93+
low: [
94+
...acc.low,
95+
(0, $e7wri$bignumberjs)(low)
96+
],
97+
close: [
98+
...acc.close,
99+
(0, $e7wri$bignumberjs)(close)
100+
],
101+
volume: [
102+
...acc.volume,
103+
volume
104+
]
105+
}), (0, $f0aed1fa18949526$export$d102b3be7ceada42));
106+
const bollinger = indicator.BOLLINGER_BANDS(ohlcv.close, 20, 2);
107+
const candlestick = indicator.getCandlestickPattern(ohlcv);
108+
const trend = indicator.getTrend(bollinger.mid, period);
109+
return {
110+
trend: trend,
111+
candlestick: candlestick
112+
};
113+
};
114+
115+
116+
console.clear();
117+
console.log((0, $e7wri$chalk).greenBright.bold((0, $e7wri$figlet).textSync("cryptosignal", {
118+
font: "Larry 3D",
119+
showHardBlanks: true
120+
})) + "\n");
121+
(async ()=>{
122+
let err, tickers, klines;
123+
(0, $f0aed1fa18949526$export$aa40d6b8948fbc43).getTickers.start();
124+
[err, tickers] = await (0, $e7wri$to)((0, $3c700f1948406e0b$export$b1319c00e04db0d9)({}));
125+
(0, $f0aed1fa18949526$export$aa40d6b8948fbc43).getTickers.stop();
126+
if (err) {
127+
console.error((0, $e7wri$chalk).red("An error has occured while fetching triggers."));
128+
return;
129+
}
130+
const prompt = await (0, $e7wri$prompts)([
131+
{
132+
name: "symbol",
133+
type: "autocompleteMultiselect",
134+
message: "Symbol",
135+
min: 1,
136+
choices: tickers?.data?.map((ticker)=>({
137+
title: ticker.symbol,
138+
value: ticker.symbol
139+
}))
140+
},
141+
{
142+
name: "interval",
143+
type: "select",
144+
message: "Interval",
145+
choices: (0, $f0aed1fa18949526$export$a867bcbce9e92f58)
146+
}
147+
]);
148+
if (!prompt.symbol || !prompt.interval) return;
149+
const outputs = {};
150+
try {
151+
(0, $f0aed1fa18949526$export$aa40d6b8948fbc43).getKlines.start();
152+
for (const symbol of prompt.symbol){
153+
[err, klines] = await (0, $e7wri$to)((0, $3c700f1948406e0b$export$9e5c183359f8fd67)({
154+
symbol: symbol,
155+
interval: prompt.interval
156+
}));
157+
outputs[symbol] = (0, $9e97c0d5330f7bcb$export$847f4ee65531b89)(klines?.data, 14);
158+
}
159+
} catch (err) {
160+
(0, $f0aed1fa18949526$export$aa40d6b8948fbc43).getKlines.stop();
161+
return console.error((0, $e7wri$chalk).red("An error has occured while fetching klines."));
162+
} finally{
163+
(0, $f0aed1fa18949526$export$aa40d6b8948fbc43).getKlines.stop();
164+
}
165+
console.table(Array(...Object.entries(outputs)).map(([symbol, output])=>({
166+
Symbol: symbol,
167+
Interval: prompt.interval,
168+
"Pattern Direction": output.candlestick.pattern,
169+
"Pattern Name": output.candlestick.name,
170+
"Pattern Score": output.candlestick.score,
171+
"Active Trend": output.trend
172+
})));
173+
})();
174+
175+

0 commit comments

Comments
 (0)