Hasm

How Hasm works

The whole method: where every number comes from, how we test, how we separate skill from luck, and how the guard protects your orders. Everything here is what the site does today.

The data and its sources

  • Daily stock closes from EODHD (a licensed vendor), adjusted for splits and dividends, and checked for unexplained jumps and missing values.
  • Options levels: OPRA via ThetaData, no delay. Every page writes each snapshot's time and source next to it.
  • Minute candles on the chart from Cboe, about 15 minutes delayed, and the chart says so.
  • Crypto from Binance's public data.
  • Minute prices for intraday tests from Alpaca (all US exchanges, through the previous session).
  • Financial statements (revenue, earnings, debt) from the official SEC EDGAR filings (XBRL), each figure with its report date.
  • Option history for tests and model checks: daily contract closes from OPRA via ThetaData.
  • Each source's state is on the status page, from a repeated real check, not a fixed value.
  • Every number carries a tag: backtest (computed on the past, never traded), paper (trades at real prices, no money) or live (real trades).

How a test runs

  • No peeking ahead: a decision is made at a session's close and filled at the next session's open. Every result is also re-run cut at an earlier date: if anything before that date changes, the result is flagged.
  • Survivorship: named lists (such as the S&P 500) are read as they were on each date. If today’s list is applied to the past, the result says so plainly and cannot get a «go».
  • Costs: the broker’s actual commission schedule (Interactive Brokers tiered by default; Binance and Coinbase schedules for crypto) and slippage set by the trade’s share of the volume. The test is then re-run at twice the costs.
  • The result is written in dollars on the amount you choose, after every cost.

How we measure luck

  • We count every version you tried: try twenty versions of an idea and one wins by chance. The bar rises with every version.
  • Deflated Sharpe ratio (DSR): the probability that the return over cash is real after discounting what luck makes with that many tries.
  • SPA test (Hansen): does the best version really beat chance after counting them all? And the overfitting screen (PBO): does the best in-sample stay best out of sample?
  • 1,000 bootstrap resamples, six sub-periods, and every possible one-year start: does the idea hold whatever day you start?

The seven rules

  • 1. At least 30 trades
  • 2. Beats holding the market, with a bar that rises with the number of tries
  • 3. Probability the return over cash is real after the luck discount (DSR) ≥ 95%
  • 4. Half the sub-periods or more profitable
  • 5. The best version beats chance after counting every version (SPA, 5% or less)
  • 6. 60% of one-year starts profitable
  • 7. Still profitable at twice the costs
  • The verdict: all seven pass → «start on paper». Otherwise the result names the rule that failed, by how much, and what might change it.

The guard and the brokers

  • Brokers: Alpaca and Hasm’s built-in paper account. Interactive Brokers is in testing.
  • The stop at the broker: every entry goes out as a linked order (bracket or OTO) with a stop leg — a stop-market order, not stop-limit. It lives on the broker’s servers, so it works even if ours stops, and it is put back if it goes missing.
  • An honest caveat: a stop-market order fills at the next available price; across a price gap it can fill worse than the stop.
  • No duplicates: each order has one id, journaled before it is sent; a retry reuses it, so the broker refuses a second copy. No new order on a symbol while one is pending.
  • Limits before every order: market hours, symbol list, minimum price, price collar, size caps, buying power, open positions and orders per day. A kill switch by hand, and on its own at the daily loss limit, on repeated rejections or when the broker is unreachable.
  • Paper first: no live trading before 5 sessions on paper.
  • The guard never touches your manual orders or positions: it only sees what it created.

Sharia screening of stocks

  • We apply AAOIFI Standard No. 21 in numbers: interest-bearing debt ≤ 30% of market cap, interest-bearing cash and securities ≤ 30% of it, impermissible income ≤ 5% of revenue.
  • Debt, cash, revenue and interest income come from the latest SEC EDGAR filings; market cap = last close × shares. Each ratio states its period.
  • The business comes from EDGAR's SIC code: conventional finance, insurance, alcohol and tobacco fail; hotels, amusement and media are marked «needs a review».
  • Alongside, the MSCI Islamic index standard for comparison: the denominator is total assets, not market cap, with 33.33% limits on debt, on cash and securities, on receivables plus cash, and 5% on income.
  • Purification = the impermissible-income ratio × the dividend, in dollars.
  • This is a numeric screen, not a religious ruling. When a figure is missing we say «not enough data» and give no verdict.

Performance attribution (Brinson)

  • BHB (1986): allocation = (portfolio − benchmark weight) × the sector’s benchmark return; selection = benchmark weight × (portfolio − benchmark return) in the sector; interaction = weight difference × return difference.
  • Brinson–Fachler (1985): allocation is measured on the sector’s return minus the whole benchmark’s; selection and interaction as in BHB. The total is unchanged; its split across sectors changes.
  • Top-down (two factors): the interaction goes into selection = portfolio weight × return difference.
  • References: Morningstar «Equity Performance Attribution Methodology» (2011) pp. 8–10; P. Clauss, Université Paris-Dauphine, eq. 1.5–1.15.

What leaves Saudi Arabia

  • The server is in Jeddah (Oracle, me-jeddah-1): accounts, portfolios, runs, the audit log and the backups stay there.
  • Data vendors (ThetaData, EODHD, Alpaca, SEC, treasury.gov) receive a symbol and a date, nothing about the client.
  • The language-engine provider (US) receives only what a user writes to a language tool. Each institution can turn it off entirely, or limit it to aggregated numbers with no tickers or positions. Details for banks are in the data-flow document.
  • Every calculation (pricing, stress, tail, hedging) runs on the server and needs no language engine.

Security and your data

  • Passwords are hashed with scrypt and cannot be read.
  • Broker keys are stored encrypted and used only to send and follow your bots’ orders. We cannot see or move your money, and you can revoke the link at your broker at any time.
  • Payments go through Moyasar (mada, Apple Pay, Visa/Mastercard); we store no card data.
  • Connections are encrypted (HTTPS); servers run in Oracle Cloud’s Jeddah region with daily backups.
  • Details in the privacy policy and the terms; live service health on the status page.

What we do not promise

  • We give no buy or sell recommendations and hold none of your money.
  • The past does not guarantee the future. A backtest is a simulation; the seven rules reduce the risk of fooling yourself, they do not remove it.