gold-dz 1.0.0 → 1.1.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/index.js +69 -10
- package/package.json +21 -6
package/index.js
CHANGED
|
@@ -1,17 +1,76 @@
|
|
|
1
|
-
// gold-dz -
|
|
1
|
+
// gold-dz v1.1.0 - Prix réel Ga3 Dzayer - by Fares Oran
|
|
2
|
+
// Stratégie: Investing Onca + Dollar Square 255 + base prix hors masna3iya
|
|
3
|
+
|
|
4
|
+
async function getGoldPriceLive() {
|
|
5
|
+
try {
|
|
6
|
+
// 1. Jib prix Onca men API gratuit
|
|
7
|
+
const response = await fetch('https://api.gold-api.com/price/XAU');
|
|
8
|
+
if (!response.ok) throw new Error('API failed');
|
|
9
|
+
const data = await response.json();
|
|
10
|
+
const ounceUSD = data.price; // Ex: 2700$
|
|
11
|
+
|
|
12
|
+
// 2. Dollar Square - Souk parallèle Dzayer
|
|
13
|
+
const dollarDZ = 255; // T9ad tbadlou hna
|
|
14
|
+
|
|
15
|
+
// 3. 7seb prix gram base (24k = 99.9% pur)
|
|
16
|
+
const gram24k = (ounceUSD / 31.1035) * dollarDZ;
|
|
17
|
+
const gram21k = gram24k * 0.875; // 21/24 = 87.5%
|
|
18
|
+
const gram18k = gram24k * 0.75; // 18/24 = 75%
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
date: new Date().toLocaleDateString('fr-DZ'),
|
|
22
|
+
time: new Date().toLocaleTimeString('fr-DZ'),
|
|
23
|
+
location: 'Algérie - Ga3 Dzayer',
|
|
24
|
+
source: `Onca: $${Math.round(ounceUSD)} | Dollar: ${dollarDZ} DA`,
|
|
25
|
+
gold_18k: `${Math.round(gram18k).toLocaleString('fr-DZ')} DA/g`,
|
|
26
|
+
gold_21k: `${Math.round(gram21k).toLocaleString('fr-DZ')} DA/g`,
|
|
27
|
+
gold_24k: `${Math.round(gram24k).toLocaleString('fr-DZ')} DA/g`,
|
|
28
|
+
details: {
|
|
29
|
+
ounce_usd: Math.round(ounceUSD),
|
|
30
|
+
dollar_dzd: dollarDZ,
|
|
31
|
+
gram_24k_raw: Math.round(gram24k),
|
|
32
|
+
purity: { '18k': '75%', '21k': '87.5%', '24k': '99.9%' }
|
|
33
|
+
},
|
|
34
|
+
message: 'Prix base hors masna3iya - Ga3 Dzayer',
|
|
35
|
+
masna3iya_note: 'Bijoutiers yzido masna3iya (2000-4000 DA/g)'
|
|
36
|
+
};
|
|
37
|
+
} catch (error) {
|
|
38
|
+
// Fallback si API ma khdamch - prix Oran
|
|
39
|
+
return {
|
|
40
|
+
date: new Date().toLocaleDateString('fr-DZ'),
|
|
41
|
+
location: 'Oran, Algérie - Fallback',
|
|
42
|
+
gold_18k: '12,500 DA/g (fallback)',
|
|
43
|
+
gold_21k: '14,200 DA/g (fallback)',
|
|
44
|
+
gold_24k: '16,800 DA/g (fallback)',
|
|
45
|
+
error: 'API indisponible, prix fallback',
|
|
46
|
+
message: 'Souk Oran - Prix du jour'
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Version synchrone pour compatibilité (prix Oran)
|
|
2
52
|
function getGoldPrice() {
|
|
3
53
|
return {
|
|
4
54
|
date: new Date().toLocaleDateString('fr-DZ'),
|
|
5
|
-
location:
|
|
6
|
-
gold_18k:
|
|
7
|
-
gold_21k:
|
|
8
|
-
gold_24k:
|
|
9
|
-
message:
|
|
55
|
+
location: 'Oran, Algérie',
|
|
56
|
+
gold_18k: '12,500 DA/g',
|
|
57
|
+
gold_21k: '14,200 DA/g',
|
|
58
|
+
gold_24k: '16,800 DA/g',
|
|
59
|
+
message: 'Souk Oran - Prix du jour (utilise getGoldPriceLive() pour prix réel)'
|
|
10
60
|
};
|
|
11
61
|
}
|
|
12
62
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
63
|
+
// Pour Node < 18 qui n'a pas fetch natif
|
|
64
|
+
if (typeof fetch === 'undefined') {
|
|
65
|
+
try {
|
|
66
|
+
global.fetch = require('node-fetch');
|
|
67
|
+
} catch {}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
console.log("=== GOLD DZ v1.1.0 - Prix Ga3 Dzayer ===");
|
|
71
|
+
getGoldPriceLive().then(price => {
|
|
72
|
+
console.log(price);
|
|
73
|
+
console.log("=======================================");
|
|
74
|
+
});
|
|
16
75
|
|
|
17
|
-
module.exports = { getGoldPrice };
|
|
76
|
+
module.exports = { getGoldPrice, getGoldPriceLive };
|
package/package.json
CHANGED
|
@@ -1,18 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gold-dz",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Prix
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Prix de l'or en Algérie - Base prix Ga3 Dzayer hors masna3iya - Onca + Dollar Square",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "node index.js"
|
|
7
|
+
"test": "node index.js",
|
|
8
|
+
"start": "node index.js"
|
|
8
9
|
},
|
|
9
10
|
"keywords": [
|
|
10
11
|
"gold",
|
|
11
12
|
"algeria",
|
|
12
13
|
"dz",
|
|
13
14
|
"or",
|
|
14
|
-
"
|
|
15
|
+
"dhab",
|
|
16
|
+
"oran",
|
|
17
|
+
"prix",
|
|
18
|
+
"18k",
|
|
19
|
+
"21k",
|
|
20
|
+
"24k",
|
|
21
|
+
"gold-price"
|
|
15
22
|
],
|
|
16
|
-
"author": "Ben Mokhtar Fares
|
|
17
|
-
"license": "MIT"
|
|
23
|
+
"author": "Ben Mokhtar Fares <Oran, Algérie>",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/fares31-oss/gold-dz.git"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://github.com/fares31-oss/gold-dz#readme",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/fares31-oss/gold-dz/issues"
|
|
32
|
+
}
|
|
18
33
|
}
|