-
Notifications
You must be signed in to change notification settings - Fork 42
/
datasets_info.pl
66 lines (65 loc) · 2.03 KB
/
datasets_info.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/perl
use DBI;
no warnings;
my $dbh = DBI->connect(
"dbi:SQLite:dbname=$ARGV[0]",
"",
"",
{ RaiseError => 0 },
);
my $stmt = qq(SELECT name FROM sqlite_master WHERE type='table' AND name LIKE '%candles%';);
my $sth = $dbh->prepare( $stmt );
my $rv = $sth->execute();
my @row;
while (@row = $sth->fetchrow_array()) {
$stmt = qq(SELECT datetime(start, 'unixepoch') FROM `main`.@row order by start ASC LIMIT 1;);
my $sth = $dbh->prepare( $stmt );
my $rv = $sth->execute();
my @row2;
while (@row2 = $sth->fetchrow_array()) {
print "@row\nstart: @row2\n";
}
$stmt = qq(SELECT datetime(start, 'unixepoch') FROM `main`.@row order by start DESC LIMIT 1;);
my $sth = $dbh->prepare( $stmt );
my $rv = $sth->execute();
my @row2;
while (@row2 = $sth->fetchrow_array()) {
print "end: @row2\n";
}
$stmt = qq(select count(*) FROM @row;);
my $sth = $dbh->prepare( $stmt );
my $rv = $sth->execute();
while (@row2 = $sth->fetchrow_array()) {
print "candles: @row2\n";
}
my $stmt = qq(SELECT avg(vwp) FROM `main`.@row);
my $sth = $dbh->prepare( $stmt );
my $rv = $sth->execute();
while (@row2 = $sth->fetchrow_array()) {
print "avarage price: @row2\n";
}
my $stmt = qq(SELECT min(low) FROM `main`.@row;);
my $sth = $dbh->prepare( $stmt );
my $rv = $sth->execute();
while (@row2 = $sth->fetchrow_array()) {
print "lowest price: @row2\n";
}
my $stmt = qq(SELECT max(high) FROM `main`.@row;);
my $sth = $dbh->prepare( $stmt );
my $rv = $sth->execute();
while (@row2 = $sth->fetchrow_array()) {
print "highest price: @row2\n";
}
my $stmt = qq(SELECT sum(trades) FROM `main`.@row;);
my $sth = $dbh->prepare( $stmt );
my $rv = $sth->execute();
while (@row2 = $sth->fetchrow_array()) {
print "trades: @row2\n";
}
my $stmt = qq(SELECT sum(volume) FROM `main`.@row;);
my $sth = $dbh->prepare( $stmt );
my $rv = $sth->execute();
while (@row2 = $sth->fetchrow_array()) {
print "volume: @row2\n\n";
}
}