Inspiration

We invest in stocks to grow our wealth and there are varieties of brokers that offer such services. When we have invested with more than one brokers, it becomes a challenge to keep track of our investment portfolio.

By harnessing the power of Wit.ai, we have decided to build an easy-to-use chat bot that assists individuals with portfolio management and performance tracking. The chat bot ideally provides a natural and fun way for us to organize our investments, making our book-keeping easy and accessible.

What it does

Stockeeper allows users to quickly organise their stock investment and keep track of our overall position. Simply tell Stockeeper the orders you have made by sending a text or leaving a voice message, he will be able to provide analytics such as stocks allocation, overall P&L, daily portfolio performance, and so on.

How we built it

Stockeeper sits in a Heroku application server. The brain of Stockeeper was written in Python, which interacts with Wit.ai and Facebook Messenger during the conversation. An AWS S3 instance was used to host generated images and Apache Redis was used to cache useful information in between sessions. Financial market data extracted from Yahoo Finance are analysed together with users’ trading portfolio.

Challenges we ran into

At the start of the project, it was easy to generate responses for sentences that have less than one entity. However, when we dealt with tasks that required more than one entity to complete, it is common that users do not include all the information in one sentence. We then needed to prompt users to input the missing information. For example, a user may say “I bought 100 shares of Facebook yesterday”, Stockeeper would have to ask users the executed price while remembering the context in the previous sentence. Not until we have made good use of the State Machine design pattern and Apache Redis to store relevant state information, we struggled to maintain this dialog flow.

Accomplishments that we're proud of

We are proud of implementing a solution that provides efficiency in managing our stock investment. Also, being able to train Stockeeper understanding voices with Wit.ai Speech API is a great accomplishment. In addition, we have made a good start in using state machine design pattern which helps maintain a natural dialog flow when users interact with Stockeeper.

What we learned

Wit.ai is a powerful tool that helps extract key information from unstructured text and voice data for building applications. However, we learnt that it is very important not to over rely on Wit.ai. Striking a balance between what our applications should handle and what Wit.ai can predict is important. For example, when a user says “two eight zero zero”, Wit.ai won’t distinguish whether this refers to a Hong Kong stock ticker (2800.HK) or 2800 number of shares. This is very fair because we didn’t provide any prior information to Wit.ai, and only our application knew the full context. In such circumstances, we applied Quick Replies messenger feature to solve the problem. Quick Replies provides a good user experience through pre-filtering available options for users. In our application, we provided users a selection of tickers to choose from when Stockeeper is expecting a stock in the next response.

What's next for Stockeeper

Stockeeper is a proof-of-concept that demonstrates its capability of managing finance-related CRUD tasks. The next focus for Stockeeper would be providing him more analytical power. We want Stockeeper to trigger price alerts based on trading indicators such as MACD, Bollinger bands and RSI, etc. Ideally, we would also like to include as many investment assets as possible apparently because users don’t just invest in stocks.

Share this project:

Updates