A Recap on AMA with OKEx Financial Market Director Lennix Lai
Last week, we were very excited to announce the launch of a proud upgrade of our trading system, named the OKEx Lightning 2.0. Designed to be fast, stable and secure, the new system is being gradually implemented to all of our trading product lines, such as our upcoming OKEx Options.
To celebrate the launch, we held an ask-me-anything session with our Financial Market Director Lennix Lai on our English Telegram group on Dec 11 to answer the questions collected from our communities about the upgrade from our curious users. Lennix, who is with years of experience in legacy finance covering quant/HFT, risk management, regulations, and compliance, has been at the helm of the product and technology development of OKEx. We were pleased to him joining us to explain the upgrade in detail.
In case you missed it or wanted to revisit the exciting Q&As, here is a recap to all the 15 questions Lennix answered from our communities.
1. Is Lightning 2 100% OKEx tech or has 3rd parties? What is the speed of orders compared to previous one per second? What are main differences beside speed from previous one? How would it performance in a market overload with orders like in 2017 hype? Is fast and scalable for it?
(Twitter user: @xavelhinhax)
Lightning 2.0 is totally developed by our own technical team. OKEx has 100% intellectual property rights to the new system. The biggest advantage of Lightning 2.0 matching engine is the higher concurrent capacity. Due to the high concurrent volume in the process of matching, closing numerous positions and the need for liquidation at a very short time (esp. under the market is volatile), the technical challenge (in relation to ME) on derivatives is much more difficult than spot.
The new ME of OKEx has already been tested in various extreme market situations — based on our years of experience. Our new system can now comfortably handle no less than 100,000 orders per second. In a case like in October, under an extremely volatile market, OKEx is the only exchange without any system outage in this market. In 24hours, our trading volume of spot and contract is more than 13 billion USD. Compared with other exchanges, we are leading in trading speed and scalability. This is our new Lightning 2.0 matching system.
2. After this update, how is the performance of OKEx Lightning 2.0. Do u have the real data to persuade ur clinets which can believe OKEx matching system is better than others?
(Twitter user: @raisbeck18)
So we did some system performance tests. We measure latency data in toACK (order acknowledgment) and toLIVE (order_live) and it’s improved 100% in general. toACK improved from 50ms to 25ms; toCANCEL, the latency data nearly improved by 50%. All of these increasements are from the revolutionary improvement of Memoization、Publish–subscribe model、Binary protocol、Horizontal scaling and System Scaling.
Through this upgrade, our new system would be greatly improved in scalability, speed, reliability, and stability. The advantages of performance upgrade would be beneficial to web/app/API users
the data is important so quant/HFT can manage their expectation in terms of latency
3. Q1) What steps have been taken to reduce latency
Q2) Is there any orchestration mechanism to help ensure lower latency rates and reduction of slippage?
(Twitter user: @MoooonTo)
There are many factors that can affect the latency of a trading system. ME’s latency itself is one of them, but network connection, cross-border distance and market volatility also play important roles in it.
The ways that OKEx lightning 2.0 boosts our system performance and lowers latency are through memoization, user and trading pair data sharding, change of message format, system scaling, and the adoption of a publish-subscribe model.
For details, you may refer to our Medium:
re2) we expect lower latency of ME would help the overall liquidity of the market and hence potentially leads to a reduction of slippage.
Good illustration on lightning’s architecture.
4. How Lightning 2.0 distribute the loads of the entire system to different servers?🤔
(Twitter user: @Sahil90310786)
ok that’s a tough one 😛
So the horizontal scaling approach would lead a dilemma on load balancing: How to reasonably distribute the loads of the entire system to different servers?
A trading system basically stores orders, equity, and position data. To lower such data races, we did load sharding so to partition those data into shards according to the number of our users available. i.e. Users’ orders, equity, and position data are independently processed, which helps to ease issues on data races. And we further optimize it by batch-processing on each individual user
On the other hand, in relation to derivatives, margins on different underlying are totally segregated. So basically when we designed the sharding implementation we take users’ data and underlying as two core metrics. That finally further enhance our scalability
5. Is one of the reason why OKEx launching a better and faster matching engine — Lightning 2.0 because OKEx well soon launch Option Trading?
(Twitter user: @AltcoinDJ)
Since August, we have been upgrading our trading system for different trading pairs and trading products. The most recent completion is our perpetual swap system upgrade. Tell you what, our new USDT-margined futures are actually using the Lightning 2.0 system. I hope you can feel the difference.
One of the reasons for upgrading the matching engine is to support the upcoming OKEx Option. Our recent Options trading simulation and the upcoming live trading are also running on the new system. Compared to spot and futures, options are a very complex instrument and can fulfill more various trading needs of traders, and at the same time, its system requirement is also demanding in terms of latency, consistency and data integrity. It took us some time to perfect our trading system before rolling out the product. But I’m glad the team did a wonderful job and now we are launching live trading very soon.
Last but not least, don’t forget to join our option trading simulation contest tomorrow. Every participant will receive 10 BTC simulation fund. And the rewards are really attractive. You better not to miss it ; )
6. I am a crypto investor and I only care about cryptocurrency futures contracts, tell me the reason why I should choose your exchange platform instead of existing ones like BitMEX or Binance? What is your exchange’s advantage that can convince me to change from my favorite exchanges
(Twitter user: @phuongnari99)
So OKEx’s derivatives volume is the biggest in the world. I believe the key difference vs the other exchange on OKEx is its full-fledged of product offering — and most importantly. All are very liquid 🙂
- Spot, margin, fiat-to-crypto, futures and perpetual swap trading markets for major cryptocurrencies with the widest variety of leverage and expiry period for derivatives to offer.
- OKEx Pool which provides staking and hedging services of major crypto assets to miners
- Sophisticated risk management system like the tiered maintenance margin ratio system, mark price and margin modes to enable our users to manage their risks effectively.
7. What are the barrier in front of Lightning 2.0 & how you are planning to solve them?
(Twitter user: @Mochaz123)
OK, lots of tears. let me bring my napkin 😛
The crux of the problem is to keep the delicate balance between throughput and latency. For instance, we would like to increase the capacity via increase the batch-processing of events yet however such an approach would affect the latency.
Aside from this, we have to build a low-level dev tool and environment so to avoid some unexpected detrimental effect on latency embedded in a model toolbox. Lastly, we have to maintain a 24/7/365 robustness of the system and implemented hot backup in a relatively short time frame compared with traditional exchanges where they have time to close the market for settlement and clearing.
8. Lightning 1.0 using database matching but lightning 2.0 using “In memory Matching “. Can you please tell us about in memory Matching and how in memory Matching is better than database matching?
(Twitter user: @Engineers0786)
The system calculates the traded amount and generates a transaction entry after the matching. This method could ensure data consistency but failed to deal with many requests at the same time because of its long processing time.
so in-memory matching technique, where our system stores order data in-memory in the order matching engine during auto-matching, and less frequent access is required to the database during trading. All matching outcomes and intermediate data are also stored in-memory, which can reduce the quantities of inputs and outputs involved, hence significantly boost the order matching speed WITHOUT sacrificing the benefit of data correctioness as in DB-based ME
9. To achieve better & faster order matching engine, something must be sacrificed/improved upon. What present framework are you improving upon and how certain are you it doesn’t have any backlash
(Twitter user: @ejioforkel)
Although memoization can greatly reduce trading latency, crypto trading systems may risk losing data due to the suspension of power supply.
So to solve this issue, we take the event sourcing approach to persist the state of a business entity and store data in an event-centric way. The trading system traditionally stores data of the current state in the database, but events are stored to reflect state changes in the event sourcing approach, which enables the system to rebuild the state. The system periodically takes snapshots of the state, and re-orders the events after snapshots are created when rebuilding is required.
10. Q: What are the most prominent benefits that benefit the community from the presence of Lightning 2.0? and when is the launch?
(Twitter user: @xavelhinhax)
The lightning system will be implemented to all of our trading products, such as the latest USDT-margined futures and perpetual swap, as well as the options.
We just announced the option product details. Here at https://okexsupport.zendesk.com/hc/en-us/articles/360037777411 https://okexsupport.zendesk.com/hc/en-us/articles/360037737011
Option marks an incredible achievement in terms of product and tech of OKEx.
11. What are the drawbacks of the old Matching Engine? What is the benefit of the Matching engine — Lightning 2.0 compared to the previous version?
(Telegram user: @sandy)
Well, it is not a drawback to the old system. It’s just the design of the legacy system that can no longer support the demand from HFT and it’s inferred complexity of our wide-ranged product line. The volume growth on derivatives esp did incur pressure on DB and latency and somehow stability as well. We need a complete revamp of ME so to cater to the demand for the future. Load sharding, in-memory matching, are all leverage of latest tech so to solve the capacity issues
12. OKEx has been in the exchange field for many years, especially in the contract field. What I want to know is how does the OKEx trading system protect against extreme risks, such as flash crash?
(Telegram user: @sometimes_happens)
So OKEx has been implemented multiple risk measurement in derivatives — tiered margin, mark price, index abnormalities handling, a change in exec algo in liquidation algo — all there is a combined effort in preventing cascading liquidation and unnecessary clawback event extreme market condition. It works well — since 2019 we don’t see any clawback occurred.
13. Is there any difference between the Request/Response and Publish/Subscribe modes? How much transaction speed can I increase? ThankU
(Telegram user: @MariahHP)
In the publish-subscribe model, a queue is used for messaging. When a service needs to request other services, the information on the request is encapsulated into a message and placed onto the queue. Other services will subscribe to the message queue to obtain the information and process the request.
so in the request-response model, the client and the server are strongly coupled together. They are required to be available at the same time. The client can only wait until the server completes processing the request, which lowers its processing speed. However, in the publish-subscribe model, request processing is complete after the publisher places the message onto the queue. The publisher is decoupled from the subscriber. On the other hand, if the subscriber’s service is interrupted, the message persists on the queue and processing continues when his service resumes without the need for the publisher to resend the message, thus enhancing the reliability of system communication. Therefore, this pattern is adopted in almost all scenarios to improve our Lightning 2.0 system’s availability and throughput.
14. What are your goals in 2020 to enable high-frequency investors to trade on your stock exchange?
Does it meet your expectations with the daily transaction volume and usage rate of your stock exchange so far?
what are your superior features over other competitors in the competitive crypto market?
(Telegram user: @Nuhollic)
Believe you meant crypto-exchange 😛 So I believe considering the consistently upgrade and improvement in product/tech across crypto exchange globally in general, implying higher TPS, more API throttling, and lower round-trip of latency, so the strategies would become a lot of more latency-sensitive. I expect crypto would be heading toward a similar trend as with traditional exchange -where HFT would occupy more market shares in terms of trading volume. Eventually, it’s beneficial to the market as a whole with respect to liquidity and price discovery. And I think the latency we are talking about in crypto is still ms instead of microsecond as in traditional exchange. I don’t see there is a trend of ‘arm-race’ amongst HFT to invest in super-expensive infra, YET, in crypto
15. What affects Perpetual Swaps loan fee, will Okex have a plan to reduce Perpetual Swaps and Future fee, such as using OKB to pay fees?
(Telegram user: @duyeniavl)
Perpetual Swap ‘s funding fees are NOT charged by OKEx, whilst it’s the fee pay/received by position holders: the long pay the short OR the short pay the long. Perpetual swap’s funding fee is a cornerstone mechanism for the trading price is anchored against the spot price. And that’s the reason why perpetual swap is trading very close to spot price.
Join our new Telegram group
Don’t miss out our giveaways, promotions, events and many other offers in our new English Telegram group (https://t.me/OKExOfficial_English). Be part of the OKEx community to exchange trading ideas with our users from all over the world and level up your crypto trading.
More AMAs are coming soon. Until next time, happy trading!
Disclaimer: This material should not be taken as the basis for making investment decisions, nor be construed as a recommendation to engage in investment transactions. Trading digital assets involves significant risk and can result in the loss of your invested capital. You should ensure that you fully understand the risk involved and take into consideration your level of experience, investment objectives and seek independent financial advice if necessary.
Follow OKEx on: