Saturday, July 6, 2024

Stock Trading System Design Interview

Don't Miss

Plan To Secure Your App


Security is a high-priority consideration for you when building a stock trading app since it will process sensitive information and the sector is governed by stringent regulations. Do the following:

I have earlier explained the importance of this approach in What is the best development approach to guarantee the success of your app?.

Software Architecture Interview Questions And Answers

As you plan your interview questions for a software architect, its important to have an idea of the kind of answers you expect from a qualified candidate. There are plenty of online sites for interview questions, interview preparation, and automatic test grading that suggest ideal answers for engineers. They typically include software design interview questions and software architecture interview questions and answers.

Develop Apis To Implement The Core Features

Trading-related features are the core features in your proposed app. Design and develop APIs to implement these features, which will enable you to use the full range of your business capabilities. Take the following steps:

  • Use tools like Postman to expedite API development and testing, moreover, use Swagger to document the APIs.
  • Host the APIs using your AWS account.
  • Proactively mitigate API security risks by using authentication, encryption, quotas, throttling, and gateways. You can read What is API security? for guidance.
  • Manage your API development, staging, and production environments effectively.
  • Use PostgreSQL as RDBMS and MongoDB as NoSQL databases for your APIs.
  • Make sure that the APIs support web, Android, and iOS.
  • Design meaningful URL paths and effective rules for requests and responses.

Read our guide How to build RESTful API for your mobile app? for more insights.

Recommended Reading: Good Morning America Kardashians Full Interview

How Do You Design A Chat Application Like Whatsapp Or Facebook Messenger

You have surely used WhatsApp and Facebook, right? No? If not let me tell you that a chat application allows you to send messages to your friend. Its a point to point connection.

You keep a friend list and see their status and chat with them. In WhatsApp, you can also connect groups but that is for advanced and experienced developers. At a minimum, you should provide a design to keep a friend list and send and receive messages from them.

If you need some tips then I suggest you check out Rocking System Design Course on Udemy, where you will find a whole case study to solve this problem.

9. How do you design a Twitter Clone?Twitter is a popular messaging service that lets you broadcast your messages to all your followers. You tweet and your followers see those messages, they can like or retweet.

Make sure you implement common features like followers, hashtag, tweet, delete, etc. If you going nowhere and stuck, you can follow the solution on System Design Interviews: Grokking the System Design Interview.

10. How to design a global video streaming service like YouTube or Netflix? While designing a video streaming service like Netflix or YouTube key thing is smooth streaming and buffering and functioning over low bandwidth connection, how do you manage those challenges.

11. How to design an ATM machine?An ATM machine allows a user to deposit and withdraw cash. It also allows a user to see his balance. How do you design such a system? What are your main challenges?

How Do We Know If Our Stock Trading System Design Is Valid Or Not

New Page 1 []

The only way to know if our trading system is good enough is by backtesting the rules. In this case, we will backtest our simple stock trading system design of the stochastic indicator plus the exponential moving average.

To correctly backtest our stock trading system, we need to check one by one every single trading opportunity we may find in the historical data and apply our rules of entry, exit, and stop loss points.

For example, we will open a long position when the exponential moving average is bullish, and the smoothed stochastic indicator turns positive when it is under 20 points. The entire strategy is defined here if you want to learn more.

After setting our profit and loss point, we need to check if the trade was profitable or not and then write down the result. We should repeat this process until we have covered at least 100 trades.

Our aim is not to win every single trade with the system but win at least 60% or 70% of the trades with a profit-loss ratio of about 2 or 1.5. That would make a good enough stock trading system.

Of course, as you might start to think, repeating this process 100 times is quite a bit tedious. However, some tools will help us to backtest any stock trading system design by automating them.

Recommended Reading: Interview For Supervisor Position Tips

Use A Mobile Device Lab On The Cloud For Testing

You need to ensure that your mobile app works with all devices. However, you need to test your app against a wide range of devices for this.

pCloudy offers this capability, with its mobile device and browser lab that has over 5,000 devices/browsers combinations. Check out the pCloudy documentation for guidance, also, review its pricing plans.

Choose Appropriate Paas And Mbaas Platforms

Use AWS Elastic Beanstalk, i.e., the PaaS offering from AWS to develop the web app. PaaS platforms offer the following advantages:

  • They manage the cloud infrastructure, networking, operating system, middleware, and runtime environment, and this enables you to focus on coding.
  • Integrating databases and APIs are easy with PaaS platforms, moreover, their DevOps and auto-scaling solutions are helpful.

Read our guide 10 top PaaS providers for 2020 for more information.

Sign-up for AWS Amplify, i.e., the MBaaS offering from AWS using the same AWS account. You get the following advantages:

  • Since Amplify manages the cloud infrastructure, persistent storage, etc., you dont need to build and manage the mobile backend.
  • You can easily integrate APIs when using Amplify, moreover, the platform makes it easier to implement features like user management and push notifications.

Also, MBaaS platforms like Amplify make it easier to scale a mobile app, as I have explained in How to choose the best Mobile Backend as a Service ?.

You May Like: How To Prepare For Google Engineering Manager Interview

Section : System Availability

Software engineers aim to build systems that are reliable. A reliable system is one that consistently satisfies a user’s needs, whenever that user seeks to have that need satisfied. A key component of that reliability is Availability.

It’s helpful to think of availability as the resiliency of a system. If a system is robust enough to handle failures in the network, database, servers etc, then it can generally be considered to be a fault-tolerant system – which makes it an available system.

Of course, a system is a sum of its parts in many senses, and each part needs to be highly available if availability is relevant to the end user experience of the site or app.

Basics Of The Stock Trading System Design

Robinhood Stock Application Backend Design | Mock System Design Interview From System Design Bible

The key to starting the design of a stock trading system is to use the different technical analysis indicators available in the market.

Abiding by the rules of the technical indicators we may use, we will define the entire behavior of our trading system.

A simple stock trading system design will have at least two types of technical indicators that will help us define what is happening in the stock market: a trend following indicator and an oscillator.

Using a trend following indicator, we will be able to define the current direction of the stock price, and with the oscillator, we will be able to spot weakness points that will help us jump into the trend and make money with it.

Do you need a fast Stock Trading Journal that helps you make better decisions?

In this short video, we will show you how to know in detail the results of your trading, how to get an estimate of the number of stocks to trade based on risk, and how to drastically reduce the time it takes to record your trades with this Journal

For example, we are going to be using a combination of the smoothed stochastic indicator with a 200-period exponential moving average to define a system, just like we saw in this article here.

With these two tools, we will have a quite simple stock trading system design.

After learning how our indicators work, the next thing we need to do is to set up the rules of the stock trading system.

Recommended Reading: How To Video Interview Well

System Design Interview Questions Concepts You Should Know

You may have heard the terms “Architecture” or “System Design.” These come up a lot during developer job interviews especially at big tech companies.

I wrote this in-depth guide when preparing for my FAANG software engineering interviews. It covers the essential software system design concepts you need to reason your way through distributed systems, and it helped me get into Google as an engineer, after more than 15 years of being a corporate lawyer.

This is not an exhaustive treatment, since System Design is a vast topic. But if you’re a junior or mid-level developer, this should give you a strong foundation.

From there, you can dig deeper with other resources. I’ve listed some of my favourite resources at the very bottom of this article.

I’ve broken this guide into bite-sized chunks by topic and so I recommend you bookmark it. I’ve found spaced learning and repetition to be incredibly valuable tools to learn and retain information. And I’ve designed this guide to be chunked down into pieces that are easy to do spaced repetition with.

Let’s get started!

Better Than A Database

So why bother with this? Why not just persist all data to a database and consume it directly from there? Well, you need a system to queue up the messages because each message corresponds to a task that needs to be done based on that message’s data. So in our ticketing example, if 100 people make a booking in 35 minutes, putting all that in the database doesn’t solve the problem of emailing those 100 people. It just stores a 100 transactions. Pub/Sub systems handle the communication, the task sequencing and the messages get persisted in a database. So the system can offer useful features like “at least once” delivery , persistent storage, ordering of messages, “try-again”, “re-playability” of messages etc. Without this system, just storing the messages in the database will not help you ensure that the message gets delivered and acted upon to successfully complete the task.

Read Also: Should You Send An Email After An Interview

Software Architecture Interview Questions And How To Use Them

Software architecture is a broad, general plan that defines goals and guides the development of a software program. Most developers view such a plan as essential before any technical steps in creating a software program.

At the software architecture stage, all stakeholders in the proposed program have their say, negotiating the elements that will affect them most. Most of the questions raised are general: Will the software program be user-friendly? What is the overall organization of the system? Will users be able to adapt to it quickly?

And software developers might ask, What security features will there be? Will it run at high speed? Will it be scalable? Easy to maintain and debug?

These and related questions are the basis of communication among stakeholders so that an understanding is reached about their expectations. Taking the time to negotiate the elements of the system architecture is crucial in controlling the cost and changes in system fundamentals once the work is underway can be hugely disruptive, as one feature change often impacts all the rest.

An expert in systems architecture is important for your organizations software development team. As you might expect, that puts pressure on the hiring process.

Identifying the right software architecture interview questions can help you assess candidates for technical, varied, and subtle skills and characteristics. Lets walk through some examples.

What Is A Trading System

Build a dashboard

A stock trading system is a set of rules we define in order to help us trade in the stock market with the idea of profiting over time.

Typically, a trader will define his/her own stock trading system, creating its rules and changing the different parameters of the system until they find a solution that satisfied them and makes them feel comfortable when trading.

We will be deepening more about this in a moment, but first, we will be learning how to design a stock trading system to help you understand this better.

Don’t Miss: Where Can I Go For Tsa Precheck Interview

Ip Hashing Based Selection

You can configure your load balancer to hash the IP address of incoming requests, and use the hash value to determine which server to direct the request too. If I had 5 servers available, then the hash function would be designed to return one of five hash values, so one of the servers definitely gets nominated to process the request.

IP hash based routing can be very useful where you want requests from a certain country or region to get data from a server that is best suited to address the needs from within that region, or where your servers cache requests so that they can be processed fast.

In the latter scenario, you want to ensure that the request goes to a server that has previously cached the same request, as this will improve speed and performance in processing and responding to that request.

If your servers each maintain independent caches and your load balancer does not consistently send identical requests to the same server, you will end up with servers re-doing work that has already been done in as previous request to another server, and you lose the optimization that goes with caching data.

Bonus Questions For Experienced Engineers

There are plenty of resources available for low-level system design questions and object-oriented design interview questions. The following, however, are examples of the types of questions posed to candidates seeking an upper-level position:

  • Can you name some metrics for measuring system performance?
  • What is load balancing, and why is it important to system design?
  • How would you design a tinyURL system?
  • Also Check: What Are Good Interview Questions To Ask A Potential Employer

    Improving Design Handoffs: A Guide

    To build an awesome and successful digital product you need to do a lot of things. Such as planning, market research, build a prototype, design it, code it, ship it etc. For this whole process, you need to go through lots of handoffs and team communications. One of the more painful handoffs is the Design-to-Development Handoff.

    This happens usually as the design and development happen in 2 separate teams. The design team handles creating the design system, user interfaces, graphics and visuals. The dev team turn the design deliverables into a functional product.

    Explain What Is Secondary Markets What Is The Difference Between The Secondary And Primary Market

    Robinhood Stock Exchange System Design | How to Receive Realtime Stock Updates

    Secondary market is where the trading of securities is done. It consists of both equities as well as debt markets.

    The main difference is that in the primary market an investor can buy securities directly from the company through companys IPO while in the secondary one buys securities from other investors willing to sell the same. Equity shares, bonds, preference shares, etc. are available in the secondary market.

    Read Also: What Are Common Questions Asked In An Interview

    Section : Consistent Hashing

    One of the slightly more tricky concepts to understand is hashing in the context of load balancing. So it gets its own section.

    In order to understand this, please first understand how hashing works at a conceptual level. The TL DR is that hashing converts an input into a fixed-size value, often an integer value .

    One of the key principles for a good hashing algorithm or function is that the function must be deterministic, which is a fancy way for saying that identical inputs will generate identical outputs when passed into the function. So, deterministic means – if I pass in the string “Code” and the function generates a hash of 11002, then every time I pass in “Code” it must generate “11002” as an integer. And if I pass in “code” it will generate a different number .

    Sometimes the hashing function can generate the same hash for more than one input – this is not the end of the world and there are ways to deal with it. In fact it becomes more likely the more the range of unique inputs are. But when more than one input deterministically generates the same output, it’s called a “collision”.

    With this in firmly in mind, let’s apply it to routing and directed requests to servers. Let’s say you have 5 servers to allocate loads across. An easy to understand method would be to hash incoming requests , and then generate hashes for each request. Then you apply the modulo operator to that hash, where the right operand is the number of servers.

    Delivery Of Share And Making Payment

    In the next step, the investor has to deliver the shares sold or has to pay cash for the shares bought. The investor has to do so immediately after receiving the contract note or before the day when the broker shall make delivery of shares to the exchange or make payment. This is known as Pay in Day.

    Read Also: How To Pass The Coding Interview

    Develop Test And Deploy Your Web App

    Code the web app using Node.js, which is a popular open-source runtime environment. Take the following steps:

    More articles

    Popular Articles