The UX for PositionManager is complete. The UX is a simple Buy, Buy 10, Buy Max, Sell, Sell 10, Sell Max shown on a spreadsheet in Jupyter. Not rocket science, but getting the basics right. PositionManager is an alternate interface to trading. The idea is to watch the stock you want to buy on Thinkorswim and then use the Jupyter notebook to place the order. The eventual goal is to create automation but baby steps.
Use Thinkorswim to watch the stock

Use the PositionManager to Buy and Sell Quickly
I was trying to figure out the best way to create the UX and went down the rabbit hole of Jupyter widgets. They are great! Super simple to implement and works with the existing Python code. Highly recommend it as a way to write data-driven GUIs. Python is not my favorite language, but Jupyter has some majors plus points, especially with widgets.

Lastly, I implemented the broker interface. The broker abstracts different brokerage firms behind a standard API. For example, every broker will have a common interface that provides the same data. TD Ameritrade, Alpaca, and any future broker will have to implement:
  • account info
  • list orders
  • list positions
  • buy position
  • close position
Major props to tda-api for simplifying the TD Ameritrade API. Currently, I am only trading stocks, so I am not focused on options or other instruments.

Here is the current status of the engine. The green are done, the yellow are things that are partially done.

PositionManager is done

The next part is the OrderManager. The order manager will have two goals:
  • Track every buy and sell order into a database.
  • Track order executions.
  • Place effective buy and sell orders into the market starting with a simple strategy.

Botty McStockface: Design 1.0

Posted 15 days ago
Here is the first design I have designed for how the app works. I will go into depth on each one in later blog posts.

Primordial Design 1.0


Watchlists

These are individually picked stocks that located in Airtable and added to our broker's watchlists.

Broker

Currently, we are using TD Ameritrade and Alpaca. This service abstracts away the broker and provides a common interface to make orders, get account information, etc.

The Broker interface also provides an Order Manager. The Order Manager essentially tries to find the optimal fit for a trade to ensure execution.

Quotes are a real-time stream of tick data for a stock that is generated by the underlying broker.

Engine

The engine is the coordinator program with the ultimate interface of probability growth, probability fall. It coordinates with the Broker, Events, Strategies, and Position Manager. It is the worker bee of the system and, for that reason, is written in Go.

Strategies

The strategies are stateless event machines that are called by the engine with the relevant data. This makes it easy to scale as we add additional data. Each strategy returns a decision a tuple (Side, Probability). Side being long or short.

Hello, World!

Posted 15 days ago
I'm Abhi. I'm am learning about the economy and trading. Since I'm a software engineer, I am coming at trading as an engineering problem. Primordial's goal is to make money with a collection of different methods and we build the code to support those decisions. Everyone who writes code wants to do algotrading so much so everyone thinks that is the only way to do it. There are other ways to play. While I won't go into individual strategies that I will construct, I will go over how to build an overall system that can handle different loads.

I am using two books for everything thus far:

Professional Automated Trading
Trading Systems and Methods

(Both are Affiliate Links)