@mathieuc/tradingview 3.0.1 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/tests/prices.js DELETED
@@ -1,33 +0,0 @@
1
- const marketAPI = require('../main');
2
-
3
- (async () => {
4
- const market = marketAPI();
5
-
6
- market.on('logged', async () => {
7
- console.log('API LOGGED');
8
-
9
- const searchBTC = (await market.search('bitcoin euro', 'crypto'))[0];
10
- console.log('Found Bitcoin / Euro:', searchBTC);
11
- market.subscribe(searchBTC.id);
12
-
13
- const btcTA = (await market.getTA(searchBTC.type, searchBTC.id));
14
- console.log('Technical Analysis for Bitcoin / Euro:', btcTA);
15
- });
16
-
17
- market.on('price', (data) => {
18
- console.log(data.symbol, '=>', data.price);
19
- });
20
-
21
- const searchETH = (await market.search('ethereum euro', 'crypto'))[0];
22
- console.log('Found Ethereum / Euro:', searchETH);
23
-
24
- setTimeout(() => {
25
- console.log('Subscribe to', searchETH.id);
26
- market.subscribe(searchETH.id);
27
- }, 10000);
28
-
29
- setTimeout(() => {
30
- console.log('Unsubscribe from', searchETH.id);
31
- market.unsubscribe(searchETH.id);
32
- }, 20000);
33
- })();
package/tests/strategy.js DELETED
@@ -1,56 +0,0 @@
1
- const marketAPI = require('../main');
2
-
3
- const market = marketAPI(false);
4
-
5
- market.on('logged', async () => {
6
- const indicators = (await market.searchIndicator('strategy'))
7
- .filter((st) => (st.type === 'strategy' && st.access !== 'invite_only'))
8
- .map((st) => ({
9
- name: st.name,
10
- id: st.id,
11
- version: st.version,
12
- settings: {
13
- commission_type: 'percent',
14
- commission_value: 0,
15
- initial_capital: 25000,
16
- default_qty_value: 20,
17
- default_qty_type: 'percent_of_equity',
18
- currency: 'EUR',
19
- pyramiding: 10,
20
- },
21
- }));
22
-
23
- let total = indicators.length;
24
- console.log('Found', indicators.length, 'strategies');
25
-
26
- market.initChart({
27
- symbol: 'COINBASE:BTCEUR',
28
- period: '1D',
29
- range: 0,
30
- indicators,
31
- }, (_, strategies) => {
32
- const loaded = Object.keys(strategies).length;
33
- console.log(`Loading... ${loaded}/${total}`);
34
-
35
- if (loaded < total) return;
36
- market.end();
37
-
38
- console.log(
39
- 'Best strategies:',
40
- Object.keys(strategies).map((stName) => ({
41
- n: stName,
42
- p: Math.round(strategies[stName].performance.all.netProfitPercent * 1000) / 1000,
43
- })).sort((a, b) => b.p - a.p),
44
- );
45
- });
46
-
47
- market.on('error', (...data) => {
48
- if (data[1].type === 'study_error') {
49
- console.error('Error with study:', indicators[data[1].data]);
50
- total -= 1;
51
- return;
52
- }
53
-
54
- console.error(...data);
55
- });
56
- });