Skip to content
This repository was archived by the owner on Mar 10, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
package-lock.json
.DS_Store
7 changes: 7 additions & 0 deletions lib/fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ function chronik(wkn) {
function depot(wkn) {
return section('depot_log&aktie=' + wkn);
}
function ownDepot(){
return raw('index.php?section=agdepot&action=columns', 'POST', {
'columns[]': [0,1,2,3,4,5,6,7,8,9,15,17,18,19,20,21,22]
});
}
function agstruktur(wkn) {
return section('agstruktur&WKN=' + wkn);
}
Expand Down Expand Up @@ -103,6 +108,7 @@ function agsx() {
function orders() {
return section('agorderbuch');
}

module.exports = {
raw: raw,
section: section,
Expand All @@ -114,6 +120,7 @@ module.exports = {
indizes: indizes,
chronik: chronik,
depot: depot,
ownDepot: ownDepot,
agstruktur: agstruktur,
kontoauszug: kontoauszug,
kaeufer: kaeufer,
Expand Down
1 change: 1 addition & 0 deletions lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = {
indizes: require('./parser/indizes.js'),
chronik: require('./parser/chronik.js'),
depot: require('./parser/depot.js'),
parseOwnDepot: require('./parser/owndepot.js'),
aktionaere: require('./parser/aktionaere.js'),
kontoauszug: require('./parser/kontoauszug.js'),
kaeufer: require('./parser/kaeufer.js'),
Expand Down
169 changes: 169 additions & 0 deletions lib/parser/owndepot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
const cheerio = require('cheerio');
const format = require('../format.js');

function parseOwnDepot(html) {

let data = cheerio.load(html);


let aktien = [];
let aktientbody = data('#depot').children()[1];

aktientbody.children.filter(tr => tr.type !== 'text').forEach(tr => {

let tds = tr.children.filter(td => td.type !== 'text');

let wkn = tds[0].children[0].children[0].data;
let name = tds[0].children[0].children[2].children[0].data;

let notiz = tds[1].children[0].children[0].data;

let anzahl = tds[2].children[0].data;

let gKurs = tds[3].children[0].children[0].data;
let hKurs = tds[3].children[1].children[0].data;
let bKurs = tds[3].children[4].children[0].data;

let kPreis = tds[4].children[0].data;
let kDatum = tds[4].children[2].data;

let aenderung = tds[5].children[0];

let tKurs = tds[6].children[0].children[0].data;

let bWAktie = tds[7].children[0].data;

let kBW = tds[8].children[0].children[0].data;

let buchwert = tds[9].children[0].data;

let wachstum = tds[10].children[0].data;

let aGAlter = tds[11].children[0].data;

let oStatus = tds[12].children[0].data;

let hAktivitaet = tds[13].children[0].data;

let orders = (!tds[14].children[0].children[0]) ? "" : tds[14].children[0].children[0].data;

let kGV = tds[15].children[0].data;

let fP = tds[16].children[0].data;

aenderung = (aenderung.name === 'img') ? 0 : aenderung.children[0].data;

let aktie = {
wkn: +wkn,
name: name,
notiz: notiz,
anzahl: +anzahl,
gKurs: format.from(gKurs),
hKurs: format.from(hKurs),
bKurs: format.from(bKurs),
kPreis: format.from(kPreis),
kDatum: kDatum,
aenderung: aenderung,
tKurs: tKurs,
bWAktie: format.from(bWAktie),
kBW: format.from(kBW),
bW: format.from(buchwert),
wachstum: (!wachstum) ? 0 : +wachstum,
aGAlter: aGAlter,
oStatus: oStatus,
hAktivitaet: hAktivitaet,
orders: orders,
kGV: format.from(kGV),
fP: format.from(fP)
};

aktien.push(aktie);

});


let anleihen = [];

let tbody = data('#depotAnleihen').find('tbody');

tbody[0].children.filter(r => r.type === 'tag').forEach(row => {
row = row.children.filter(cell => cell.type === 'tag');
let vol = format.from(row[0].children[0].data);
let zins = row[1].children[0].data.replace('%', '');
let zinsbetrag = format.from(row[2].children[0].data);
let auszahlung = format.from(row[3].children[0].data);
let laufzeit = row[4].children[0].data;
let restlaufzeit = row[5].children[0].data;
let date = row[6].children[0].data.replace(' um', '');
date = format.date(date, date.substring(10));

let anleihe = {
volumen: vol,
zinssatz: +zins,
zinsbetrag: zinsbetrag,
auszahlung: auszahlung,
laufzeit: laufzeit,
restlaufzeit: restlaufzeit,
auszahlungsdatum: date
};
anleihen.push(anleihe);
});

let kredite = [];
let tbody_kredite = data('#depotKredite').find('tbody');
tbody_kredite[0].children.filter(r => r.type === 'tag').forEach(row => {
row = row.children.filter(cell => cell.type === 'tag');
let vol = format.from(row[0].children[0].data);
let zins = row[1].children[0].data.replace('%', '');
let zinsbetrag = format.from(row[2].children[0].data);
let auszahlung = format.from(row[3].children[0].data);
let laufzeit = row[4].children[0].data;
let restlaufzeit = row[5].children[0].data;
let date = row[6].children[0].data.replace(' um', '');
date = format.date(date, date.substring(10));

let kredit = {
volumen: vol,
zinssatz: +zins,
zinsbetrag: zinsbetrag,
rueckzahlungsbetrag: auszahlung,
laufzeit: laufzeit,
restlaufzeit: restlaufzeit,
rueckzahlungsdatum: date
};
kredite.push(kredit);
})

let zertis = [];
let tbody_zertis = data('#depotZertis').find('tbody');
tbody_zertis[0].children.filter(r => r.type === 'tag').forEach(row => {
row = row.children.filter(cell => cell.type === 'tag');
let betrag = format.from(row[0].children[0].data);
let hebel = row[1].children[0].data;
let punkte = format.from(row[2].children[0].data.match(/auf (.*) Pkt./)[1]);
let typ = row[2].children[0].data.includes('call') ? 'CALL' : 'PUT';
let auszahlung = format.from(row[3].children[0].data);
let ablaufdatum = row[4].children[0].data.replace(' um', '');
ablaufdatum = format.date(ablaufdatum, ablaufdatum.substring(10));

let zert = {
betrag: betrag,
hebel: +hebel,
typ: typ,
punkte: punkte,
auszahlung: auszahlung,
ablaufdatum: ablaufdatum,
};
zertis.push(zert);
})

let depot = {
aktien: aktien,
anleihen: anleihen,
kredite: kredite,
zertifikate: zertis
}
return depot;
}

module.exports = parseOwnDepot;
7 changes: 6 additions & 1 deletion lib/retrieve.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ function depot(wkn) {
return fetcher.depot(wkn).then(parser.depot);
}

function ownDepot(){
return fetcher.ownDepot().then(data => parser.parseOwnDepot(data));
}

function aktionaere(wkn) {
return fetcher.agstruktur(wkn).then(parser.aktionaere);
}
Expand Down Expand Up @@ -71,6 +75,7 @@ module.exports = {
aglist: agliste,
indizes: indizes,
depot: depot,
ownDepot: ownDepot,
chronik: chronik,
aktionaere: aktionaere,
kontoauszug: kontoauszug,
Expand All @@ -79,5 +84,5 @@ module.exports = {
trades: trades,
online: onlinelist,
bilanzen: bilanzen,
index: index,
index: index
};
74 changes: 63 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ const retrieve = agspiel.retrieve;
retrieve.agliste().then(list => {
console.log(list);
}).catch(console.log);

/** Gesamtes Depot auslesen
* retrieve.ownDepot().then(
* msg => console.log(msg));
* /