Our personal experience with the stock market in recent times has gotten us really intrigued. We’ve tried our beginners' luck and now we want to see if some non-traditional approaches like gamification and prolonged playing and essentially relying on your subconscious mind can help you start seeing the patterns and history repeat and help you get positive results.
What it does
F(of)x is a game that lets people from all over the world compete against each other to predict stock prices (from varying periods in history) in real-time for the stocks from the S&P 500 index. The game is comprised of 4 rounds, each 65 seconds long. The first round is for observing the stock and in subsequent rounds each user has to predict what the price of the stock would be “when the round ends” and they have to do this as quickly as possible. Your score of the round depends on your quickness and accuracy. Each stock stays for 3 rounds so people can develop patterns over longer periods.
How we built it
We have a python server responsible for game state like the stock prices and round state, and it publishes the data to the clients in real-time using Redis pub/sub channels and websockets. It also maintains a global leaderboard. The frontend is built in React and the subscribing services are built in Node JS. The subscribing services handle features like analytics, simulating a live stock market and users leaderboard.
Challenges I ran into
Since users can join and leave whenever they want, we had to make the experience of joining in the middle of a round running seamless and smooth. We used Redis pub/sub to achieve that. As soon as a new user joins, they are a subscriber to stock prices data, so they are able to see the stock function live right when they join. Similarly, consistent round state on the server and it’s distribution to the clients was tricky.
Accomplishments that I'm proud of
- Achieving a slick design when neither of us had experience in react
- Developing a smooth/seamless experience of playing this game
- Deploying this game to production on GCP with SSL
- Game design and thinking about the user journey and motivation and incorporating features like Global Leaderboard, user and global analytics.
- Integrating with User Session Management using Google Sign in.
What I learned
React is not as hard as we thought, It was nice to learn the workings of react and develop a nice UX. Deploying to production is still a pain. Setting up Nginx proxy with SSl and getting it working with websockets was an interesting challenge. Setting up redis (open-source) was extremely easy. Session-management on the backend using Node and cookies!
What's next for F(of)X
1 Integrate a betting system which allows you to bet on your prediction using bitcoin. The collected pot per round will be divided proportionally to the player’s scores with the house getting a small percentage.
- We want to correlate the global player sentiment on stocks with the actual prices of stocks moving forward and showcase these analytics.
- Expose an API to allow users to make bots that can make predictions for them.
- Create play rooms, where users can gather with their friends and play together exclusively. Since we are using redis, this should be fairly easy to add.