farajfarook / Airwallex.CodeChallenge

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Airwallex coding challenge

The aim of this exercise is to implement an "alerting" service which will consume a file of currency conversion rates and produce alerts for a number of situations.

The build system is configured to handle Java or Kotlin, which is our preferred language. For the purpose of this coding exercise, you are allowed to choose a different programming language, provided that you provide us with a detailed instruction on how to build and run your program.

Input

The format of the file will simulate a stream of currency conversion rates. Each line will be properly structured JSON (http://jsonlines.org/):

{ "timestamp": 1554933784.023, "currencyPair": "CNYAUD", "rate": 0.39281 }

The fields in the JSON record are:

  • timestamp: the timestamp of the record in seconds since UNIX epoch, with fractional seconds specified
  • currencyPair: the sell and buy currencies which the rate relates to
  • rate: the conversion rate

You may assume that for each currency pair, currency conversion rates are streamed at a constant rate of one per second. ie. for two consecutive "CNYAUD" entries in in the input file, they will have timestamps that differ by one second:

{ "timestamp": 1554933784.023, "currencyPair": "CNYAUD", "rate": 0.39281 }
{ "timestamp": 1554933784.087, "currencyPair": "USDAUD", "rate": 0.85641 }
{ "timestamp": 1554933785.023, "currencyPair": "CNYAUD", "rate": 0.39295 }

Output

The alerting service should produce the following alerts, as JSON strings output to standard output:

  • when the spot rate for a currency pair changes by more than 10% from the 5 minute average for that currency pair
  • when the spot rate has been rising/falling for 15 minutes. This alert should be throttled to only output once per minute and should report the length of time of the rise/fall in seconds.

The format of the alerts produced should be:

{ "timestamp": 1554933784.023, "currencyPair": "CNYAUD", "alert": "spotChange" }
{ "timestamp": 1554933784.023, "currencyPair": "CNYAUD", "alert": "falling", seconds: 3450 }

Build and Execution

To build the application:

./gradlew clean build

To run the application:

./gradlew run --args example/input1.jsonl

Submissions

Submissions will be assessed on:

  • correctness
  • code structure
  • clean, readable code
  • performance

You can submit your solution either as an archive file or as a link to a private cloud repository (such as Google Drive). Please execute

./gradlew clean

to remove build artefacts prior to creating the archive file.

Note: We will not consider submissions that are uploaded to Github.

About


Languages

Language:Kotlin 97.9%Language:Java 2.1%