Creating a Stock Watchlist in Kotlin

The stock watchlist is likely one of the first visual tools a new retail investor will be introduced to. It’s both easy to understand and abuse as the new trader fills it up with every speculative penny stock they stumble across. For this project we will use Batil, an open-source library written in Kotlin that can integrate with your broker, to simplify the creation of our real-time stock watchlist.

Lane detection using Kotlin and OpenCV

In terms of hard problems in computer science, computer vision ranks up there as one of the toughest. Fortunately we have access to tools like OpenCV which comes pre-packaged with solutions for common problems like reading in a video feed or converting a color space. And thanks to native Java bindings, it is available for us to use in Kotlin.

Storing Secrets Securely in Kotlin

It’s not uncommon for applications to occasionally need to store secrets. The security of those secrets relies partly on the underlying cryptography and partly on the layout of the scheme. In this implementation, we will provide sensible defaults using dependency injection to simplify both testing and deployment to a production-ready system.

Using Retrofit to Integrate with an API

Integrating against an API involves a fair amount of work, especially if you want to do more than the bare minimum like including tests. Thanks to tools like Retrofit, OkHttp and their suite of plugins, this task becomes much more manageable.

Automating the Retrieval of a Verifier Code from E*TRADE

Automating browser actions is nothing new and as a developer I saw an opportunity to remove a manual step when I realized that the E*TRADE supplied Java client simply opens up a web browser. Having worked with Selenium and Phantom.js in the past, I found the Chrome DevTools Protocol to be a bit more challenging though that may have had more to do with the Reactive interface.

Making an Authorized Request to the E*TRADE API with OkHttp

While the default Java HttpClient is just fine for simple requests, we will be interacting with an OAuth v1 powered endpoint which will require requests to be signed. We shouldn’t have to worry about all those details and for that the OkHttp library fits our needs perfectly.

Reading a YAML Configuration File in Kotlin

During the heyday of Ruby development 10 years ago the YAML format was all the rage. But as developers moved towards Javascript-powered frameworks like node the preferred format for configuration files moved with them to JSON. It was the Java community, which had been enthrall to XML for the better part of a decade, that began to roll out better support for YAML.

Reading from the Command-Line in Kotlin

When it comes to breaking down complex problems into smaller ones Kotlin offers a full range of functional tools and patterns to make your job easier. Building on our previous entry around building a command-line application we will put several techniques to use to build a robust solution to the problem of accepting and validating user input.

Creating a Command-Line Application in Kotlin

Many folks associate Kotlin with Android but its uses extend far beyond programming for mobile. We will be building a “Hello World” command-line application packaged up as a JAR file, a format just about every Java developer should be familiar with. We will also make use of Github, Gradle and JetBrain’s IntelliJ IDEA, the gold standard in Java IDEs.

Connecting to the E*TRADE API

While there are a number of fantastic APIs available for those looking to build stock market related apps, most cost money for anything beyond the basics. But if you have an existing E*TRADE account and a bit of patience you can get realtime data, including options chains, from one of the top brokers in the market.

Start of a Journey

It all started at KotlinConf 2019 in Copenhagen. Technically I’d already been using Kotlin for nearly two years by that point having run teams that developed Android apps built with a mix of Java and Kotlin. But I’d left a good portion of the implementation up to the developers themselves, only going into the code to fiddle with Gradle build settings or giving pull requests a once over.