LondonAirquality Analysis with IcCube

../london.jpeg

If you do analytics, you probably usually go straight for Python Notebooks, and create a bunch of graphs to visualize the analysed data.

When you don’t want to show that data to someone outside, and hide implementation details, a nice alternative, and my de facto favourite, is to go and use IcCube.

As an exercice, I was teaching how to get ready and graph quickly with IcCube, using air quality data.

Writing an API Wrapper in GoLang

I had a really time-limited effort to do to prove how to write a command line wrapper for an open API a customer is developping.

The target Rest API is the jquants-api, as presented in a previous post.

I chose to implement the wrapper in GoLang, which proved to be extremely fast and pleasant to do. The task was eventually done in a short evening, and the resulting Golang wrapper with core features has been uploaded on github.

Loom - Fibers, Continuations and Tail-Calls for the JVM

I am excited about Project Loom. The project focuses on easy to use lightweight concurrency for the JavaVM. Nowadays, the JavaVM provides a one java thread to one OS thread model to the programmer. While it’s actually the current Oracle implementation, it used to be that many JavaVM versions ago, threads provided to the programmer were actually green threads.

Project Loom goes down that road again, providing lightweight threads to the programmer. Those lightweight threads are mapped to OS threads in a “many-to-many” relationship.

Tokyo Stock Exchange Jquants API

The just out of beta jquants-api propose sets of daily financial data from over 4000 listed companies on the Tokyo Stock Exchange.

/jquants/area-5-2-2.jpg

Currently, the sets of data that can be accessed via the API are:

with more to come in the near future.

While current historical data is only available starting from 2017 users are encouraged to provide feedback to the API via usual github (etc..) channels so as to understand usage in more details.

Embed IcCube

Building up on the previous iccube tutorial, here are a few key extensions to reporting. First how to extract data from a command line client written

Get data using CLI (or Java)

	String url, user, password, file;

    public static void main (String... args) throws Exception {
    
        Connection connection = DriverManager.getConnection(url, user, password);

        OlapConnection olapConnection = connection.unwrap(OlapConnection.class);
        runMDX(file, olapConnection);

        if (watch) {
            try {
                watch(file, olapConnection);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }

        olapConnection.close();

    }


    public static String mdxQueryfromFile(String file) throws IOException {
        Path p = new File(file).toPath();
        System.out.println(p.toAbsolutePath());
        return Files.readString(p);
    }

    private static void runMDX(String file, OlapConnection olapConnection) throws OlapException, IOException {
        CellSet cellSet = olapConnection.createStatement().executeOlapQuery(mdxQueryfromFile(file));
        RectangularCellSetFormatter formatter = new RectangularCellSetFormatter(false);
        PrintWriter writer = new PrintWriter(System.out);
        formatter.format(cellSet, writer);
        writer.flush();
    }

Working with last N days/weeks etc…

WITH
SET LastWeek AS ClosingPeriod( [issueCompletion].[issueCompletion].[Day])
SET Last2Weeks AS {LastWeek.Item(0).Lag(13):LastWeek.Item(0)}
SELECT Last2Weeks ON 1, [Measures].[closedIssues] on 0
FROM [redmineProduction]

Create custom measures to compare with a previous period


create MEMBER [Measures].[OneYearAgo]
 AS
 (ParallelPeriod([Year],1),[Measures].[London Mean Roadside:Nitrogen Dioxide (ug/m3)])
   
create MEMBER [Measures].[DiffOneYearAgo]
 AS
Iif( IsEmpty( [Measures].[OneYearAgo] ), 0, [Measures].[London Mean Roadside:Nitrogen Dioxide (ug/m3)] - [Measures].[OneYearAgo] )
create MEMBER [Measures].[6 Months Moving Avg] AS
    AVG([Date].[Date].CurrentMember : [Date].[Date].CurrentMember.lag(6), [Measures].[London Mean Roadside:Nitrogen Dioxide (ug/m3)])

Export/Import server side + report

Find the schemas here …