0bps

Strategy vault / Tools & templates

SMS Notification Class Library

Support gateway SMS Bao http://www.smsbao.com/ SUBMAIL http://submail.cn/ example

Author
Zero
Complexity
Intermediate · 38 lines
Parameters
8

Support gateway

example

$.SMSNotify("abc SMS test");

Parameters

NameDefaultWhat it controls
PhoneNum138XXXXXXXXMobile number
SMSGate0SMS gateway: SMSBao | SUBMAIL
SMSBaoUserNameusernameUsername
SMSBaoPWD$$$__enc__$$$passwordPassword
AppId11111APPID
AppKey$$$__enc__$$$11111APPKEY
VarNamecontentVariable name
Project5x1X03Project Tag

Source JavaScript

$.SMSNotify = function(content) {
    if (IsVirtual()) {
        throw "This template only supports live trading";
    }
    if (SMSGate === 0) {
        var retCode = HttpQuery("http://api.smsbao.com/sms?u="+SMSBaoUserName+"&p="+MD5(SMSBaoPWD)+"&m="+PhoneNum+"&c="+encodeURIComponent(content));
        var retDict = {
            '30': 'Incorrect Password',
            '40': 'Account does not exist',
            '41': 'Insufficient Balance',
            '42': 'Account Expired',
            '43': 'IPAddress Restriction',
            '50': 'content contains sensitive words',
            '51': 'incorrect mobile phone number'
        };
        if (typeof(retCode) === 'string' && typeof(retDict[retCode]) === 'string') {
            Log('SMS notification response:', retDict[retCode]);
        } else if (retCode === '0') {
            Log('SMS notification successful:', content);
        } else {
            Log('SMS notification failed:', content, '#ff0000');
        }
    } else if (SMSGate == 1) {
        var vars = {};
        vars[VarName] = content;
        var ret = HttpQuery('https://api.submail.cn/message/xsend.json', 'appid='+AppId+'&to='+PhoneNum+'&project='+Project+'&signature='+AppKey+'&vars='+encodeURIComponent(JSON.stringify(vars)));
        if (ret && ret.indexOf('"status"') != -1) {
            var obj = JSON.parse(ret);
            Log("SMS Notification:", obj.status, typeof(obj.msg) != 'undefined' ? obj.msg : '');
        } else {
            Log("SMS notification failed");
        }
    }
}

function main() {
    $.SMSNotify("abc SMS test");
}

Published by Zero on the FMZ strategy square · last modified 2016-12-05. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.

Build this with AgenKit

A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a tested, production-ready module from strategies/SMS-Notification-Class-Library.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. Get tests, backtest, risk controls and a paper-trading switch

Understand it first

Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.

Related specs

esc

Try , , or .

↑↓ move↵ open