Flash Queries

Instead of your code asking the model every few seconds, the model reads your data as it lands and sends you the answers. Register your questions once; after every data update LayerScale answers them again in the background and pushes the fresh answers to your client over SSE.

Normally your code asks, then waits while the model works out the answer. With Flash Queries that work is already done when you ask. A trading desk might register questions like these.

"Is momentum accelerating or decelerating?"
"Is volatility expanding or contracting?"
"Is price near support or resistance?"
"Is volume confirming the trend?"
"Is a reversal likely?"
"Is the move confirmed?"
flash-queries
import { LayerScale } from '@layerscale/layerscale';

const client = new LayerScale('http://127.0.0.1:8080', {
    apiKey: 'your-api-key',
});

// Create session with flash queries
const session = await client.createSession({
    prompt: 'You are a quantitative trading strategist '
    + 'analyzing live market microstructure.',
    flash: [
        'Is momentum accelerating or decelerating?',
        'Is volatility expanding or contracting?',
        'Is price near support or resistance?',
        'Is volume confirming the trend?',
        'Is a reversal likely?',
    ],
});

// Push price data
await client.streamPush(session.session_id, [{
    ts: Math.floor(Date.now() / 1000),
    sym: 'AAPL',
    o: 150.25, h: 151.00, l: 149.80, c: 150.90, v: 100000,
}]);

// Answers arrive automatically via SSE
for await (const event of client.events(session.session_id)) {
    if (event.type === 'flash_ready') {
        console.log(event.answer, event.confidence);
    }
}
from layerscale import LayerScale

client = LayerScale("http://127.0.0.1:8080", api_key="your-api-key")

# Create session with flash queries
session = client.create_session(
    prompt="You are a quantitative trading strategist "
    "analyzing live market microstructure.",
    flash=[
        "Is momentum accelerating or decelerating?",
        "Is volatility expanding or contracting?",
        "Is price near support or resistance?",
        "Is volume confirming the trend?",
        "Is a reversal likely?",
    ],
)

# Push price data
client.stream_push(session.session_id, [{
    "ts": int(time()),
    "sym": "AAPL",
    "o": 150.25, "h": 151.00, "l": 149.80, "c": 150.90, "v": 100000,
}])

# Answers arrive automatically via SSE
for event in client.events(session.session_id):
    if event.type == "flash_ready":
        print(event.answer, event.confidence)

See Flash Queries
in Action

If you're at a hedge fund or financial institution and want to see a live demo, book a call with us.