Shannons Demon
JavaScript strategy by FawkesPan.
The original spec has no written description. Read the source below.
Parameters
| Name | Default | What it controls |
|---|---|---|
| DELAY | 30 | Balance interval |
| DS | 1.04 | Sell |
| DB | 1.08 | Buy |
| RSIB | 80 | RSI Buy |
| RSIS | 20 | RSI Sell |
Source JavaScript
/*
Shannon's Demon Demo Code
Copyright 2018 FawkesPan
Contact : [email protected] / Telegram@FawkesPan
Do What the Fuck You Want To Public License
*/
function onTick(){
var Account = exchange.GetAccount();
var Depth = exchange.GetDepth();
var Buy = Depth.Asks[1].Price;
var Sell = Depth.Bids[1].Price;
var StockValue = Account.Stocks * Buy;
var TotalValue = Account.Balance + StockValue;
var Half = TotalValue / 2;
var Records = exchange.GetRecords(PERIOD_M1);
var RSI = TA.RSI(Records, 14);
//Log("StockValue:", StockValue ," TotalValue:", TotalValue);
var LastRSI = RSI[RSI.length -1];
//Log(LastRSI);
if (StockValue / Half > DS && LastRSI > RSIS) {
Log("StockValue:", StockValue ," TotalValue:", TotalValue);
Log("StockValue Too High. Re Balancing...");
var ToBeSold = (Account.Stocks * Buy - Account.Balance) / 2 / Buy;
Log(exchange.Sell(Buy,ToBeSold));
Sleep(DELAY*1000*5);
}
if (Half / StockValue > DB && LastRSI < RSIB) {
Log("StockValue:", StockValue ," TotalValue:", TotalValue);
Log("StockValue Too Low. Re Balancing...");
var ToBeBought = (Account.Balance - Account.Stocks * Buy) / 2 / Sell;
Log(exchange.Buy(Sell,ToBeBought));
Sleep(DELAY*1000*5);
}
}
function main(){
while(true){
onTick();
Sleep(DELAY*1000);
}
}Published by FawkesPan on the FMZ strategy square · last modified 2018-08-30. 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.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Shannons-Demon.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- 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.