Stock Exchange System Design : Distributed Transactions, Financial System

  Рет қаралды 53,057

Vinayak Sangar

Vinayak Sangar

Жыл бұрын

Join the discord community to share more learnings on system design and distributed systems:
/ discord

Пікірлер: 56
@superrin
@superrin 15 күн бұрын
the story telling is great. Easy to understand. Thanks a lot!
@sangamsahai9823
@sangamsahai9823 Жыл бұрын
Bro this is gold !! Thanks sooooo much for making these and please keep making more :)
@tasinpoyraz6679
@tasinpoyraz6679 Жыл бұрын
As a programmer Love to watch this kind of video excellent work.
@nikhilbesra
@nikhilbesra Жыл бұрын
Great Video actually. I was looking for Stock Exchange design and believe me i have gone through the other videos which have higher views and I can guarantee this has the best content.
@Emir_bs182
@Emir_bs182 Жыл бұрын
Great concept videos you made.
@thebks1
@thebks1 Жыл бұрын
This is amazing and unique content
@Oyunlog_2011
@Oyunlog_2011 Жыл бұрын
Thanks for sharing information and education video.
@gulhanturk3004
@gulhanturk3004 Жыл бұрын
Interesting video learn more about from this video.
@Rafael-yn7fq
@Rafael-yn7fq Жыл бұрын
Keep this up! Great videos
@sangarvinayak
@sangarvinayak Жыл бұрын
Thanks!
@bhishmaacharya7535
@bhishmaacharya7535 Жыл бұрын
Wow.. somehow this amazing content found on my feed.
@sangarvinayak
@sangarvinayak Жыл бұрын
Glad you enjoy it!
@tonyyang8424
@tonyyang8424 Жыл бұрын
I think those queues design is problematic, if the queue is the normal queue. Instead it should be the priority queue which are sorted by price and timestamp.
@architguleria989
@architguleria989 2 ай бұрын
That is actually the task of matching engine as per my understanding. It can use redis to maintain sorted sets and do the matching. Queues are primarily introduced to achieve async behaviour.
@ankitpersie1
@ankitpersie1 2 ай бұрын
@@architguleria989 agreed.i think the queues should only be used for maintaining the chronological order of placed orders for fairness and downstream system should do the logic of matching.
@vex123
@vex123 Жыл бұрын
This is great stuff! Would really love to see how you would translate this system diagram into an Object-oriented software architecture. Can you please make a vide on that?
@somghos4363
@somghos4363 3 ай бұрын
Great insightful video!! one design considration. we can use one kafka cluster here . with different topic for each stock list. this kafka can also help in notification and analtyyics. purpose
@goyalpankaj237
@goyalpankaj237 8 ай бұрын
Really Nice Content! One point - There should be one more service that will consume the Matched order Topic messages to debit/credit the actual stocks from the Demat of the Customers.
@SunnyKumar-ud9gp
@SunnyKumar-ud9gp 3 ай бұрын
Loved the content
@vardaansangar3568
@vardaansangar3568 Жыл бұрын
Great design
@joelfoit
@joelfoit Жыл бұрын
Excellent, well thoughout course. Would you have time to do a follow up video on the executor service to expand on how you'd design that part. I know you mentioned the airline reservation ticket but would be nice if you actually went in detail on the executor service here. Thanks again though !
@digitalmarketer9675
@digitalmarketer9675 Жыл бұрын
You cover more information on your. 43 minutes video this is great to watch
@yaldagh5157
@yaldagh5157 10 ай бұрын
Thank you
@AdityaGupta-fz8mr
@AdityaGupta-fz8mr 4 ай бұрын
Superb
@sampatkalyan3103
@sampatkalyan3103 Жыл бұрын
Great video.
@mr_world_wide
@mr_world_wide 9 ай бұрын
I think the matcher can be designed with using queues, we can simply keep 2 tables for sell and buy orders, each time customer makes a sell or buy request just put the request in a queue, which is then picked up by the matcher. If it is a buy request matcher queries the sell table for the unmatched sell orders, if appropriate order is found, it marks both the records as match in their respective tables then passes the request to executor queue. if it is a sell request matcher queries the buy table for the unmatched buy order and does the same. Adding a the unmatched orders in the queues again will prohibit us from giving fifo service.
@varshard0
@varshard0 6 ай бұрын
That's my exact design for an interview and from the feedback, it's not optimal enough with the db overhead. It's better to have the matcher also store trees of buy/sell and match them in memory instead. The buy and sell tables can exist for record keeping and restoring the tree if the matcher die.
@sumitraut6987
@sumitraut6987 Жыл бұрын
Fantastic ☺️
@sangarvinayak
@sangarvinayak Жыл бұрын
Thanks 🤗
@techinbanking6177
@techinbanking6177 11 ай бұрын
Good effort but lot of things missing like estimation of storage facilities, if the market time is 10 hrs then how come 86400 (24 hrs) for calculation? Order request missing type like Market/Limit Order.
@DimagKiDahii
@DimagKiDahii 11 ай бұрын
👏👏👏👏👏👏👏👏👏👏👏
@ravipradeep007
@ravipradeep007 2 ай бұрын
Nice video , just one comment @37.58 when you are discussing about limit orders , imagine there are 1 million limit orders for a stock which is going through a nose dive the matcher system might get overwhelmed , second i am assuming queue is not ordered and say a stocks price is 100 and somebody has placed a limit buy order at 105 at 11.00 am and someone else at 102 11.02 am , but since the matcher is taking them out sequentially it might end up matching 11.00 order since it would be fetched first , to a sell order , if the matcher has not pulled the whole queue , This can be a big bottleneck or more so incorrect behaviour
@TheKshitijagrawal
@TheKshitijagrawal Жыл бұрын
I have my doubts about choosing order request db as NOSQL. 1. I don't believe order request data is going to be in hundreds of TB because this will only store one day worth data - this should less than 1 TB data. Matched orders is where we will maintain the history of orders but then there again we can split that into data for current day and history database. 2. Order request database does require high consistency. Often clients would like to modify their orders which are yet to be matched or cancel these. 3. Lastly, I have my doubt on order_id being the primary query key because trading mostly happen via brokers like icici direct or zerodha so will zerodha poll status for each order_id.. I guess that, they might poll based on their broker id or something which gives info in bulk.
@meditationdanny701
@meditationdanny701 Жыл бұрын
Hey Kshitij will try to answer your doubts based on my experience and understanding in the order you have asked 1. Keeping both ongoing order request and past order data in order request table make sense as we aggregate all order related info int o its own collection which makes our data denormalized that avoid unnecessary joins and can have a flag to make active order this will help us in our future API's hence no-sql storage 2. So based on our initial assumption we are letting user update their ongoing order hence data is consistent by nature 3. Yes in matched order there should a broker_id by here the order status user is requesting is abstracted wrt our order request status and yes internally we need to expose a webhook endpoint to get the realtime status and according updating our order request table service coulmn
@jaykumarjaviya1941
@jaykumarjaviya1941 Жыл бұрын
what if once the matcher service finds a match and processes it for the executor service? and during that time client cancel his buy/sell order?
@marcioduarte2906
@marcioduarte2906 18 күн бұрын
How do you manage consistency between when you get a message from the queue (SQS), have a positive match, send it to the Executor service and then delete the message from SQS? Do you have an intermediate step in the Matcher service in which you synchronously check and update the state of those orders (maybe in the db) before deleting the message from SQS? My concern is: If you have orders Buy A with Sell B matching, you process them, send another message to the queue for the Executor Service and right after you fail to delete those messages from SQS (in the Matcher service) Then retry happens and you get more messages from both Buy and Sell queue. A and B but now also Sell C, this time the algorithm matches A and C, sends it to the Executor service successfully and deletes A and C from SQS successfully. We are not in an inconsistent state, The executor service cannot de-dup on Buy A and we've effectively lost a Sell C order. Thanks
@amriteshsingh2952
@amriteshsingh2952 3 ай бұрын
Thanks for the video, very insightful. I am just wondering about the matching service which takes the events from buy and sell queues and matches them. Since the queue maintains the messages in order, and a buy event can match with a sell order which is present in later part of the queue, how do we match the orders in that case here?
@timo9madrid7
@timo9madrid7 3 ай бұрын
same question for me. did you figure it out?
@ashutosh_verma_fullstack
@ashutosh_verma_fullstack Жыл бұрын
good design, but i think you could have optimized matcher service a bit using, cna u help me with app you are using for this presentation.
@namduong6028
@namduong6028 Жыл бұрын
what software do you use, sir?
@rabindrapatra7151
@rabindrapatra7151 11 ай бұрын
what is the time complexity of matcher service.
@user-ih6dk7xj5l
@user-ih6dk7xj5l 10 ай бұрын
Why matching engine runs once in 5 seconds? Why this system can handle 60k rps for every stock, but match them only once in 5 secs? I don't understand. HFT will drop this exchange (imagine if its real) at 6 second and never come back )
@banjodeiyowun
@banjodeiyowun Жыл бұрын
what software is the drawing board?
@jacintduduka9137
@jacintduduka9137 10 ай бұрын
The order request db could have been a queue as well, instead of a nosql db? Why did you prefer a nosql over a queue?
@ankitpersie1
@ankitpersie1 2 ай бұрын
i think for persistence.Where will the customer see the status and history of their orders.
@ayushtiwari4686
@ayushtiwari4686 Жыл бұрын
What if the matcher service pulls out some data from the queue and goes down, how are we going to update that order
@ayushtiwari4686
@ayushtiwari4686 Жыл бұрын
Queue locks the entry, ignore 😅
@bhaskarsharan4280
@bhaskarsharan4280 5 ай бұрын
NSE today has approx 2000 stocks, so what you are proposing 2000 SQS in place?
@kl-1183
@kl-1183 7 ай бұрын
greeting's sir, how can i connect you regarding a critical project.
@rabindrapatra7151
@rabindrapatra7151 11 ай бұрын
why someone will buy from more than sell value. this looks absurd to me.
@rabindrapatra7151
@rabindrapatra7151 11 ай бұрын
10 minutes video becoming 40 minutes.
@vinayakmajgaonkar6168
@vinayakmajgaonkar6168 4 ай бұрын
Run video on 1.5 speed thank me later ...🎉
@huynhtrung6338
@huynhtrung6338 11 ай бұрын
As a software engineer who are developing systems using Nasdaq exchange stack, i can this video is crap! Nobody nowadays will design an exchange like this.
@itisyerdad
@itisyerdad 11 ай бұрын
Care to go into detail about how it is crap? It's also meant to be a system design interview question so being the most "up-to-date" iteration is not necessarily the goal (especially since not everyone will actually understand how a stock exchange even works). The goal is to have a conversation and see how the interviewee responds.
How to Build an Exchange
38:17
Jane Street
Рет қаралды 167 М.
2000000❤️⚽️#shorts #thankyou
00:20
あしざるFC
Рет қаралды 16 МЛН
La revancha 😱
00:55
Juan De Dios Pantoja 2
Рет қаралды 60 МЛН
How to bring sweets anywhere 😋🍰🍫
00:32
TooTool
Рет қаралды 51 МЛН
MEU IRMÃO FICOU FAMOSO
00:52
Matheus Kriwat
Рет қаралды 12 МЛН
Top 7 Most-Used Distributed System Patterns
6:14
ByteByteGo
Рет қаралды 232 М.
Design Twitter - System Design Interview
26:16
NeetCode
Рет қаралды 457 М.
Google system design interview: Design Spotify (with ex-Google EM)
42:13
IGotAnOffer: Engineering
Рет қаралды 997 М.
How traders orders get matched (exchange matching algorithms)
9:18
Zerodha Stock Broker System Design (in Hindi)
1:22:22
opendevs
Рет қаралды 9 М.
STOCK EXCHANGE SYSTEM DESIGN | AMAZON INTERVIEW QUESTION DESIGN STOCK EXCHANGE
35:02
Tech Dummies Narendra L
Рет қаралды 192 М.
2000000❤️⚽️#shorts #thankyou
00:20
あしざるFC
Рет қаралды 16 МЛН