Categories
Uncategorized

Building Pseudo Markets Next Gen with OpenAI Codex: Part 1

When I started the Pseudo Markets project back in 2020, I was a recent college grad who just started working as a software engineer in the financial services industry. Even though I had prior software engineering experience at smaller companies, I never worked at the scale of a Fortune 500. This was reflected in the earliest versions of the project where monolithic structures prevailed, and scalability was an afterthought. As I gained additional experience on the job, I slowly started to refine my approach to the project, which introduced better design patterns and a more modular structure. Despite my efforts to keep the project moving, life and work got in the way, and it became dormant for several years.

Fast forward to today, where I am still working for the same financial services firm, but as a Technical Product Manager. Throughout my time as an engineer, I grew more interested in the products I was building rather than how they were being built. This led me to my current role, where I drive the product direction for very large scale trading systems. I wanted to revisit the project because I not only have significantly more domain knowledge, but also because I no longer write code as part of my day to day work. This project allows me to keep my engineering skills sharp, while also experimenting with the biggest thing in tech right now: AI.

I’ve been using AI coding tools such as GitHub Copilot and OpenAI Codex for over a year at this point. My usage has gone from just writing simple unit tests to building entire features, reverse engineering legacy applications, and more. With Pseudo Markets Next Gen, I’ve been heavily leveraging OpenAI Codex to write most of the code, so I can focus more on system design and business rules. This approach has allowed me to rewrite the entire “legacy” platform in just a few days, along with enhancements that were stuck in my backlog for years. While the generated code is far from perfect in the first iteration, the speed at which I can build is simply unmatched. I’ve learned a lot of things that work, and don’t work, along the way which I will be sharing through this series. I also followed several approaches to using Codex: building on top of boilerplate code, re-building from a legacy solution, and building from scratch using a Product Requirements Document (PRD). Today, I’ll be focusing on building on top of boilerplate code.

The first component I wanted to rewrite was the authentication and authorization subsystem in the previous Unified API solution. It was clunky to say the least, and I wanted the authentication and authorization flows to live in their own microservice. Rather than starting completely from scratch, I put together some boilerplate code for what I wanted the authorization service to look like. I wrote all of the initial scaffolding, entities, contracts, and the like. From there, I engaged with Codex in an interactive session to iteratively build out the service. I provided some forward thinking context to make sure that design decisions were mindful of how services would use the authentication and authorization later down the road, but I didn’t want to muddy the water by providing too much context at this stage. At the time, GPT 5.4 was the top model from OpenAI, and I found that it worked pretty well throughout each iteration. Reviewing the code was a challenge, due to the sheer amount of it at the end of the cycle. I quickly learned that I should also be engaged in code review more frequently, rather than deferring the detailed review towards the end of building out the feature (or in this case, an entire application). Code review skills are only going to become more important for every software engineer that works with AI tooling.

It took me about 8 hours to develop the application from boilerplate structure to full functionality. I reckon I could have cut that time down with better usage of plan mode, requirements docs, SME skill files, and other tricks to push more of the coding workflow into Codex. These are all techniques I used to develop other components of the platform, which I will go into additional detail in the next few posts. This is just the beginning, and I am confident that I can launch the full platform within the next few months, which is something I’ve been wanting to do for the past 6 years.

Categories
Uncategorized

Pseudo Markets Next Gen

After a lengthy hiatus from the Pseudo Markets project, I am excited to announce the next generation version of the platform. It features a simplified architecture, more accurate business rules, and container friendly microservices built with .NET 10. You can check it out here: https://github.com/pseudomarkets/pseudomarkets-ng-monorepo

As part of this rewrite, I am taking extensive advantage of the agentic coding features in OpenAI Codex. Keep an eye out for more posts on that.

Categories
Uncategorized

Breaking the Monolith: Decoupling login from the Unified API

When the Pseudo Markets project was first conceived in mid 2019, I had very little experience working with distributed systems. All of the previous backends I had worked with were huge monoliths that connected to a single relational data storage system. Since then, I have had the opportunity to work with systems that handle daily transactional volumes I wouldn’t even be able to fathom just a few years ago. One of the design decisions I made when coming up with the primary backend system for Pseudo Markets was driven by my lack of knowledge of making certain services independent, decoupled, and small. Despite not running into any immediate issues with the current design, I took it upon myself to apply what I have learned in the past year or so to re-architect the entire solution, starting with decoupling the large and tightly packed core functionality of the Unified API.

Several large pieces, such as the core equities trading platform, market data service, and portfolio performance reporting service have already been decoupled into their own services. This allows horizontal scaling as each service is distributed, whereas the previous architecture would only benefit from vertical scaling. This also allows the Unified API to just focus on one job, bringing together or “unifying” data from different services. Decoupling login and authentication from the Unified API brings the entire platform one step closer to becoming fully distributed. While most of the work is porting out and cleaning up the existing authentication code, I also have an excellent opportunity to start utilizing the Real Time Data Store (Aerospike) as a fully functional system of record. Currently, the RTDS is used as a high speed caching layer for the Market Data Service, but I have plans to move all data from the Relational Data Store (SQL Server) into RTDS.

The new Unified Auth Service will feature the capability to sync account, user, and token data across RTDS and RDS, provide data from either source, and function as both a standalone API as well as a DLL. There will be 3 modes of operation:

  • RDS Mode: All logins will be processed using data from RDS
  • RTDS Mode: All logins will be processed using data from RTDS
  • Hybrid Mode: Logins will go through round robin to use RTDS or RDS

You can track progress here: https://github.com/pseudomarkets/PseudoMarkets.Unified.Auth. I’m hoping to get this working in our dev environment first, then promoting to our new DR server in Austin, before finally pushing it out to our two primary prod app servers in DFW.

Categories
Uncategorized

[Release] Trading Platform Service Deployment

Starting next Tuesday, the Unified API on app.pseudomarkets.live will begin processing all orders through the new, OS service based Consolidated Trading Platform. This allows all trading logic to be fully decoupled from the Unified API, and can support higher volumes and availability thanks to its distributed nature. Currently, all trades will be routed through the a single queue into the “Pool A” service. In the near future, there the load will be split up with another queue into “Pool B”, wherein orders for even account numbers will go to “A” and odds into “B”. We look forward to the improvements the new trading platform will bring to the overall Pseudo Markets, and we can’t wait to share what we have in store next.

Categories
Uncategorized

[Release] Market Data Service Deployment

I am very happy to announce that the Market Data Service has been deployed to production, and that the quotation endpoint in the Unified API, as of version 1.3.0, will consume market data from the new service. Aside from the vastly improved performance and cleanliness of the implementation, there are 3 key changes in how price data is formed.

Latest Price

The Latest Price endpoint will now use the midpoint of IEX TOPS bid and ask pricing during intraday requests, and will fall back to Twelve Data Real Time Price data during non-market hours. Since IEX TOPS does not have a rate limit, this is the best choice for the most frequent look-ups during regular market hours. This is also the price reference that will be used when making trades, replacing the previous Smart Quote system.

Smart Quote

The Smart Quote endpoint will now be composed of an aggregated average price across Twelve Data Real Time Price, IEX TOPS bid/ask midpoint, and Alpha Vantage Global Quote.

Cached Prices

In an effort to stay within data provider rate limits, we will now be enforcing a 2 minute cache on hits to Latest Price, Smart Quote, and Indices. Caching is done on a per symbol basis, and the data source field will reflect whether the pricing data was served from the cache layer or not. As data provider limits change, the cache TTL will be adjusted to accommodate our plan limits.

Categories
Uncategorized

Pseudo Markets Infrastructure

Pseudo Markets aims offer a highly scaleable system, starting with the software solution itself up to the hardware that it runs on. The current infrastructure is quite small, but we are hoping to continue to expand.

https://docs.google.com/spreadsheets/d/1E3U0WuU64ZSKW41NIDrM9nCq-1atvdQ4gBdHlo2CQWo/edit?usp=sharing

Servers that support data synchronization are primed for “hot failover” meaning that every database record written in the source database will be copied over to the target DB almost instantly. This will allow for complete immediate failover in the event that the primary app server goes down. Backup instances that are used for “cold failover” such as the proposed App 3 server will not be able to be active until the primary DB is restored completely.

You can think of App 1 and App 2 as the primary production “cluster” that is always in sync and ready to take over should one of them fail. For the most part, App 1 will be the primary public facing instance used by WebTrader, MobileTrader, and CLTrader. App 3 will serve as an offsite backup, hosted in a completely different environment and will require a full DB restore from App 1 or App 2 before functionality can be nominal.

Categories
Uncategorized

Initial release of TwelveDataSharp

In an effort to improve the modularity of the Pseudo Markets Unified API, we are developing in-house .NET Standard 2.0 libraries for accessing stock market data from providers such as IEX, Twelve Data, and Alpha Vantage. The first data provider to have it’s API calls packaged into a NuGet will be Twelve Data, and we believe we are building the first fully open-source Twelve Data .NET library. The GitHub repo is available here: https://github.com/pseudomarkets/TwelveDataSharp and contains a link to NuGet.org where you can download and add TwelveDataSharp into your own .NET project. Please note that Twelve Data has a very large API and we are working on adding as many endpoints as possible, and contributions through GitHub are greatly appreciated. For now, we are focusing on supporting the high demand APIs from the Time Series and Technical Indicator subcategories.

Categories
Uncategorized

New Hosted Instance

I am proud to announce that we now have a new, CentOS 8 based server running the Pseudo Markets Unified API. It is available at https://app2.pseudomarkets.live and you can try out the API here: https://app2.pseudomarkets.live/api/Quotes/SmartQuote/AAPL. If you’d like to become an official host send an email to poweredbypseudomarkets@gmail.com with details about your instance.

Categories
Uncategorized

CLTrader Release 1.0.1

The latest version of CLTrader is now available from GitHub. This release has some notable improvements, including the following

  • Improved input validation
  • Support for short-selling with the latest Pseudo Markets Unified Web API release
  • New U.S Equity and ETF research menu

You can download the binary here: https://github.com/pseudomarkets/CLTrader/releases

Categories
Uncategorized

Status of Pseudo Markets

Pseudo Markets hasn’t been able to get a lot of attention lately due to my involvement in many other projects, but rest assured it hasn’t been forgotten. Most of the architecture will be changing, moving from NoSQL to traditional SQL for storing bookkeeping data and transactions. Quotes from IEX will be delivered on request rather than the sync and reload approach using Aerospike. A new homegrown identity server is being developed, and the entire interface will launch as a Xamarin app first and a web portal coming afterwards. I am going to start with the basics which will include account creation, buying and selling equities against a default cash balance of $1000000 per user, and viewing daily P/L data from your portfolio. I am hoping to get most of this done within the next month which is a bit ambitious considering the slow pace as of late, but I think I can do it. I am looking for contributors as well, so feel free to reach out (shravan AT shravanj DOT com).

Design a site like this with WordPress.com
Get started