# Live Quotes (Per Minute)

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

Subscribe to per-minute live quotes over the same WebSocket connection. Use channel LM.{ticker} or LM.* for all tickers. Each message delivers one minute quote per subscribed ticker during regular and extended hours on trading days. Lower message volume than per-second streams - a good default for charts, alerts and most real-time apps.

## Use cases

- Live candlestick charts and intraday performance trackers
- Streaming watchlists with minute-level updates
- Alerting on minute closes or volume spikes
- Streaming dashboards that need lower message volume than per-second quotes

## Subscribe

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

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

## Message fields

| Field | Type | Description |
| --- | --- | --- |
| `type` | string | Message type discriminator. |
| `ticker` | string | Ticker. |
| `open` | float | Opening price of the window. |
| `high` | float | Highest trade price in the window. |
| `low` | float | Lowest trade price in the window. |
| `close` | float | Closing price of the window. |
| `volume` | integer | Traded volume in the window. |
| `timestamp` | integer | Window timestamp, epoch milliseconds. |

## Example output

```json
{
  "type": "live_quote_minute",
  "ticker": "AAPL",
  "open": 189.02,
  "high": 189.45,
  "low": 188.9,
  "close": 189.31,
  "volume": 845000,
  "timestamp": 1700000060000
}
```

## Connection examples

### cURL

```bash
# install websocat: https://github.com/vi/websocat
echo '{"action":"subscribe","params":"LM.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(["LM.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(["LM.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("LM.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("LM.AAPL");
    }
}
```

### Ruby

```ruby
require "vantafin"

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