I will do my best to explain what IS built already built and the ultimate goal… the functionality is VERY complex, so my apologies for any confusion. If something is unclear, please feel free to ask for clarification.
The quick description of the software is “Distributed Workload Signal Monitoring and Algo Trade Execution”
The software works on multiple (up to 28) vps servers behind a firewall hosted with linode. To simplify the architecture I have named the servers WSRelay, Hub, and Shards.
Basic responsibilites of servers:
WSRelay - relays all alpaca websocket messages to subscribed shard servers
Hub - alpaca websocket auth, final trade decisions, trade execution
Shards - distributed workload tick data crunching (5 second intervals)
Hub Server has UI for monitoring (see more at bottom)
proficiencies:
NodeJS
PHP
redis
mysql
The goal is to consume ALL trade data and apply algo trading workflows. Here are the CURRENTLY FUNCTIONAL steps the servers perform on init: (medium detail overview, some saftey check steps have been left out)
- Hub Server
- connects and auths with WSRelay,
- sends message to handshake, auth, and subscribe with alpaca marketdata websocket
- upon confirmation queries Alpaca’s (or other trading platform) Account API
- initializes shard servers and delegates symbols to be monitored
- Shard Servers (each up to 26)
- connect and auth with WSRelay to recieve relayed alpaca websocket marketdata messages
- WSRelay
- validates auth from shard servers
- Begins relaying all messages to subscribed Shard Servers
- Shard Servers (each, up to 26)
- filter messages for designated symbols
(distribution is one, or a subset of symbol first letters, ie. “Shard A” handles all “A” like AAPL) - collects ticks for each symbol, and builds 5 second buckets, stores data in reddis server
- analyzes 5 second buckets (bars) with primary focus on Acceleration Oscillator
- when AO thresholds are met for a symbol, the past 3 minutes of rolling data is sent to Hub Server every 5 seconds while AO magnitude remains positive.
- filter messages for designated symbols
- Hub Server
- Consumes “potential trade candidate” messages
- Checks “Confidence Data’” (Market Gravity, Futures Trend, Spread Liquidity, VWAPAllignment)
- depending on “concurrent trading” being enabled or disbaled
- disabled
- Checks to see if a trade is currently active (more info later)
- If not, determines a stop loss/ take profit bracket
- prepares to execute trade
- *****trade API execution is not yet written*****
- Alerts designated Shard Server of bracketing
- if enabled…
- to be decided…
- disabled
- Updates Accounting tables
- Shard Server
- Receives “Active Trade” Message
- Watches for stop loss/ take profit threshold to be passed
- alerts Hub Server of position exit signal
- Hub Server
- Validates position exit. (to be written)
The area that i need help in is sorting out the logic regarding when to pull the trigger in step 5.
- Live montioring of each “potential trade candidate” are shown in Web UI with AO magnitude on a sparkline chart.
-UI has error and activity logs
-All parmeters are currently set as variables and can be changed in the web UI interface
partial list includes:
- alpaca_trading_mode
- ao_accel_lookback
- ao_accel_rate
- aoHistoryBuckets
- bucket_ttl
- fast_period
- flatline_ratio
- letters_per_shard
- max_vwap_stretch_percent
- min_5s_flatline_ao_buckets
- min_cumulative_ao_volume
- slow_period
- smooth_period
- use_market_gravity
- use_spread_liquidity
- use_vwap_alignment
- vol_floor
- vol_surge_multiplier
If it was not clear, this system is built to be able to make decisions based on 5 second windows. As I am an inexperienced trader, the intention is to minimize risk by setting take profit and stop loss in advance. I have not yet given any consideration to an increase position functionality will exist or not. Simple plan… watch ALL stocks, pick the strongest accelerators, take profit at 3% to 5% and be out for the day. (open to suggestions…lol)
If you would like to see more, reach out to me.