Overview:

Create a Trading Module to execute gold futures trades via API on Thinkofswim brokerage platform.

Background:

Client currently has a black box module that generates trading signals. There are 4 potential signals this blackbox can generate:

  • Buy to open long position
  • Sell to close long position
  • Sell to open short position
  • Buy to close short position

These signals are written into a database. The new Trading module will need to query this database periodically, initially every 10-15 seconds, and if it finds a new signal, it will have to submit a trade request to the online broker via the broker's API.

PHASE ONE

Implement API trading on Thinkorswim platform

Settings:

  • Ability to specify Futures Broker account information to implement login into the Futures Broker account
  • Ability to specify trading parameters:
    • Type of futures contract or Symbol
    • Number of contracts

Create a Trading Module that will be able to retrieve signals from the database and submit Market orders to the online broker using the broker's API.

Create a process that requests current prices from the Broker and stores these prices into a new table in the database every 30 seconds.

Create a process that calculates the current P&L for open positions using the latest prices and stores information about the position and current P&L into a new table in the database.

Create a process that stores all signals received from the black box and all trades executed with the broker into a database.

PHASE TWO

Create a process that calculates Max Drawdown for each position when the order to close the position is executed and stores the information into a new table in the database.

Create a one-page UI to monitor Bridge performance. The UI will include the following features:

  • Secure login
  • Kill switch – ability to turn the API Bridge on or off (when it is off, it will not process any signals and won't execute any trades)
  • Show a log of all incoming signals and orders submitted to the Futures Broker
  • Create a Daily Trading Recap report including drawdown and latency information (client will provide report design)
  • Implement additional monitoring and risk management functionality
  • Add two parameters:
    • Draw Down I (x%) – if the position is down x%, send out an alert email.
    • Draw Down II (y%) – if the position is down y%, close the open position and turn on Kill Switch (no new trades until Kill Switch is turned off manually)
  • Implement additional API routes:
    • Get list of orders based on symbol, date range, or status (open, executed, expired, etc.)
    • Get order status based on order Id