# Trading Halts

`WS` `wss://socket.vantafin.com/v1/stocks`

Subscribe to NASDAQ trading halt and resumption events. Channel H.{ticker} targets one ticker; H.* receives every halt market-wide. Messages include halt status, reason codes, human-readable reasons and expected resumption times in US/Eastern. Events are pushed when halt status changes - use for risk controls, trading halts boards and compliance monitoring.

## Use cases

- Real-time halt monitors and trading risk dashboards
- Blocking or flagging orders on halted tickers
- Market-wide halt feeds for ops and compliance teams
- Event-driven alerts when a watched ticker is halted or resumes

## Subscribe

Subscribe to `H.{ticker}` (e.g. `H.AAPL`) for a single ticker, or `H.*` for every ticker:

```json
{"action":"subscribe","params":"H.AAPL"}
```

## Message fields

| Field | Type | Description |
| --- | --- | --- |
| `type` | string | Always 'halt'. |
| `ticker` | string | Halted/resumed ticker. |
| `halted` | boolean | true when currently halted, false on resume. |
| `reason_code` | string | NASDAQ halt reason code, e.g. T1, LUDP. |
| `reason` | string | Human-readable halt reason. |
| `halt_date` | string | Halt date (MM/DD/YYYY, US/Eastern). |
| `halt_time` | string | Halt time (HH:MM:SS, US/Eastern). |
| `resumption_date` | string | Expected resumption date, if known. |
| `resumption_quote_time` | string | Expected quote resumption time. |
| `resumption_trade_time` | string | Expected trade resumption time. |
| `pause_threshold_price` | string | LULD pause threshold price, if applicable. |

## Example output

```json
{
  "type": "halt",
  "ticker": "AAPL",
  "halted": true,
  "reason_code": "T1",
  "reason": "Halt - News Pending",
  "halt_date": "06/16/2026",
  "halt_time": "09:45:00",
  "resumption_date": "06/16/2026",
  "resumption_quote_time": "09:55:00",
  "resumption_trade_time": "10:00:00"
}
```

## Connection examples

### cURL

```bash
# install websocat: https://github.com/vi/websocat
echo '{"action":"subscribe","params":"H.AAPL"}' \
  | websocat "wss://socket.vantafin.com/v1/stocks?apiKey=$VANTAFIN_API_KEY"
```

### Python

```python
from vantafin import WebSocketClient

ws = WebSocketClient("vf-live-your_api_key")
ws.connect()
ws.subscribe(["H.AAPL"])

for message in ws:
    print(message)
```

### JavaScript

```javascript
import { WebSocketClient } from "vantafin";

const ws = new WebSocketClient("vf-live-your_api_key");
ws.on("message", (msg) => console.log(msg));

await ws.connect();
ws.subscribe(["H.AAPL"]);
```

### Go

```go
package main

import (
	"fmt"
	"log"

	"github.com/vantafin/vantafin-go"
)

func main() {
	ws := vantafin.NewWebSocketClient("vf-live-your_api_key")
	conn, err := ws.Connect()
	if err != nil {
		log.Fatal(err)
	}
	defer conn.Close()

	conn.Subscribe("H.AAPL")
	for {
		msg, err := conn.Read()
		if err != nil {
			break
		}
		fmt.Println(msg)
	}
}
```

### Java

```java
import com.vantafin.WebSocketClient;

public class Example {
    public static void main(String[] args) throws Exception {
        WebSocketClient ws = new WebSocketClient("vf-live-your_api_key");
        ws.connect(message -> System.out.println(message));
        ws.subscribe("H.AAPL");
    }
}
```

### Ruby

```ruby
require "vantafin"

ws = Vantafin::WebSocketClient.new("vf-live-your_api_key")
ws.on(:message) { |msg| pp msg }
ws.connect
ws.subscribe("H.AAPL")
sleep
```
