Skip to main content

Market regime-aware risk firewall for algorithmic trading bots

Project description

VGM Risk Engine

A real-time market risk scoring API for algorithmic trading bots.

VGM is not a prediction system. It is a Risk Firewall — a safety layer that evaluates market conditions before any trade is executed.


What It Does

Submit market features в†’ receive a structured risk assessment:

{
  "action":     "BUY",
  "score":      0.6397,
  "confidence": 0.6603,
  "risk":       0.0205,
  "regime":     "LOW_VOL",
  "optimizer":  "MEAN_VARIANCE"
}

Fields:

  • action — BUY / SELL / HOLD
  • score — signal strength (0–1)
  • confidence — model certainty (0–1)
  • risk — estimated position risk (0–1)
  • regime — market regime classification (LOW_VOL, HIGH_VOL, TRENDING, etc.)
  • optimizer — active portfolio optimization mode

Quickstart

Start the server

python server/vgm_v13_api.py
# Listens on http://127.0.0.1:8010

Test with curl

curl -X POST http://127.0.0.1:8010/predict \
  -H "Content-Type: application/json" \
  -d '{"features":[1,2,3,4,5],"returns":[0.01,-0.02,0.03]}'

Test with PowerShell

Invoke-RestMethod -Method POST `
  -Uri "http://127.0.0.1:8010/predict" `
  -ContentType "application/json" `
  -Body '{"features":[1,2,3,4,5],"returns":[0.01,-0.02,0.03]}'

Request Schema

{
  "features": [float, ...],   // OHLCV-derived feature vector
  "returns":  [float, ...]    // recent return series
}

Freqtrade Integration

See freqtrade/vgm_strategy.py for a ready-to-use strategy that calls the VGM API before placing any order.

from freqtrade.strategy import IStrategy
import requests

class VGMStrategy(IStrategy):
    def confirm_trade_entry(self, pair, order_type, amount, rate, ...):
        payload = {
            "features": self.get_features(pair),
            "returns":  self.get_returns(pair)
        }
        r = requests.post("http://127.0.0.1:8010/predict", json=payload, timeout=1)
        result = r.json()

        if result["action"] == "BUY" and result["risk"] < 0.05:
            return True
        return False

Architecture

Market Data
    в”‚
    в–ј
Feature Engine  в”Ђв”Ђв–є  VGM Neural Net  в”Ђв”Ђв–є  Risk Firewall
                                               в”‚
                          ┌────────────────────┤
                          в–ј                    в–ј
                     Action Signal        Risk Score
                    (BUY/SELL/HOLD)     + Regime + Confidence

Stack

  • Python 3.10 / FastAPI
  • PyTorch neural network (ONNX exportable)
  • Freqtrade compatible strategy module
  • MT5 bridge (mt5/mt5_risk_bridge.py)
  • Docker support (docker-compose.yml)

Beta Testing

Looking for Freqtrade / crypto bot users to test the live risk scoring API.

Contact: kretski1@gmail.com GitHub: https://github.com/Kretski/VGM-Risk-Engine

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vgm_risk-1.0.0.tar.gz (20.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vgm_risk-1.0.0-py3-none-any.whl (31.0 kB view details)

Uploaded Python 3

File details

Details for the file vgm_risk-1.0.0.tar.gz.

File metadata

  • Download URL: vgm_risk-1.0.0.tar.gz
  • Upload date:
  • Size: 20.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for vgm_risk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2f316f189ea814e4d61812ba3cb5cf9ab9827ff4697ce8468541be6639a9da4f
MD5 17fabc7b2428e7b03775865c8ddbb032
BLAKE2b-256 dc6c506f115507473f1d4a227cd8d4fdb33fe8932eb66e5b8fb92acc26121a7e

See more details on using hashes here.

File details

Details for the file vgm_risk-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: vgm_risk-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 31.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for vgm_risk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cc0844f96d732ca307fbe1b395d4d0b3b84af9e8e6ccd0f2ae2966443184b800
MD5 b138f8ae197bd7c281d67e52d72d661a
BLAKE2b-256 6c2ebff42b8e24b5a970bc9eededc9c9de4ee651e513a6dbd4c09a324d883f1f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page