# Introduction

The Scanner API works along side the Backtest API. You will use the same JSON input payload as the backtest API to get option trade results. The difference is you will get real-time or delayed trades for your scan using the backtest parameters.

Examples shown use curl (opens new window).

You can download the latest version of curl here (opens new window) and see instructions of how to use curl here (opens new window).

Please use the latest version of curl (opens new window) in order for all the request examples to work.

# Authentication

All requests must be sent with a valid Authorization header with your private token.

Get your API token here (opens new window).

If you need help with your token, email us at support@orats.com.

# Quick Start

If you have already ran a backtest, copy and paste your backtest ID in the payload below:

# Payload Example

{
	"backtest" : "yourBacktestID",
	"totalTrades" : 10,
	"tradesPerSymbol" : 4,
	"dataSource" : "delayed"
}

# Scan for trades

  1. Scan by submitting the JSON Payload with a POST request using endpoint https://api.orats.io/scanner/scan.

  2. Response will be an array of array objects. The first parent array represents the list of trades and the 2nd array represents a list of option legs in the trade. So in this example, you will see 4 single leg call option trades.

# Example using curl

  1. Create a file called IBM_LongCall_Scan.json and add the following JSON input:
{
	"backtest" : "1DMYYa3AcBcBhTahmZ4iDAnMhJPLQE81CN",
	"totalTrades" : 10,
	"tradesPerSymbol" : 4,
	"dataSource" : "delayed"
}
  1. Run the curl command below with your private authorization token:
curl -d "@IBM_LongCall_Scan.json" -H "Authorization: your-private-token" -X POST "https://api.orats.io/scanner/scan"
  1. Output Example below:
[
    [
        {
            "date": "2019-06-18",
            "ticker": "IBM",
            "leg": 1,
            "ratio": 1,
            "optionType": "call",
            "expirDate": "2019-07-12",
            "strike": 140,
            "dte": 25,
            "stockPx": 136.34,
            "optionBid": 0.92,
            "optionAsk": 0.97,
            "tradeOptPx": 0.958,
            "iVolBid": 0.157357,
            "iVolAsk": 0.161607,
            "tradeVol": 16.1,
            "theoVol": 15.9,
            "fcstRatio": 1.36,
            "delta": 0.28,
            "gamma": 0.0607008,
            "vega": 0.117676,
            "ivr": 21.96,
            "updatedAt": "2019-06-18 17:28:40"
        }
    ],
    [
        {
            "date": "2019-06-18",
            "ticker": "IBM",
            "leg": 1,
            "ratio": 1,
            "optionType": "call",
            "expirDate": "2019-07-12",
            "strike": 139,
            "dte": 25,
            "stockPx": 136.34,
            "optionBid": 1.25,
            "optionAsk": 1.3,
            "tradeOptPx": 1.287,
            "iVolBid": 0.160294,
            "iVolAsk": 0.16415,
            "tradeVol": 16.3,
            "theoVol": 16.2,
            "fcstRatio": 1.29,
            "delta": 0.34,
            "gamma": 0.0653831,
            "vega": 0.129682,
            "ivr": 21.96,
            "updatedAt": "2019-06-18 17:28:40"
        }
    ],
    [
        {
            "date": "2019-06-18",
            "ticker": "IBM",
            "leg": 1,
            "ratio": 1,
            "optionType": "call",
            "expirDate": "2019-07-19",
            "strike": 140,
            "dte": 32,
            "stockPx": 136.34,
            "optionBid": 2.57,
            "optionAsk": 2.61,
            "tradeOptPx": 2.6,
            "iVolBid": 0.250108,
            "iVolAsk": 0.252728,
            "tradeVol": 25.2,
            "theoVol": 25.3,
            "fcstRatio": 0.74,
            "delta": 0.39,
            "gamma": 0.0382206,
            "vega": 0.152649,
            "ivr": 21.96,
            "updatedAt": "2019-06-18 17:28:40"
        }
    ],
    [
        {
            "date": "2019-06-18",
            "ticker": "IBM",
            "leg": 1,
            "ratio": 1,
            "optionType": "call",
            "expirDate": "2019-07-19",
            "strike": 145,
            "dte": 32,
            "stockPx": 136.34,
            "optionBid": 1.03,
            "optionAsk": 1.06,
            "tradeOptPx": 1.052,
            "iVolBid": 0.2349,
            "iVolAsk": 0.237556,
            "tradeVol": 23.7,
            "theoVol": 24.1,
            "fcstRatio": 0.62,
            "delta": 0.21,
            "gamma": 0.0302014,
            "vega": 0.117624,
            "ivr": 21.96,
            "updatedAt": "2019-06-18 17:28:40"
        }
    ]
]

# Scanning without backtesting

You can scan without backtesting by replacing the backtestID with the full backtest JSON payload.

TIP

The scanner only requires the general and entry section of the backtest input.

{
	"backtest" : {
		"general": {
			"startDate": "2007-01-03",
			"endDate": "2019-06-18",
			"symbols": [{
				"symbol": "IBM",
				"weight": null,
				"signals": null
			}]
		},
		"entry": {
			"options": [{
				"ratio": 1,
				"optionType": "call",
				"leg": 1,
				"opening": {
					"dte": {
						"target": 40,
						"min": 30,
						"max": 50
					},
					"strikeSelection": {
						"type": "absDelta",
						"value": {
							"target": 0.35,
							"min": 0.25,
							"max": 0.45
						}
					}
				}
			}]
		}
	},
	"totalTrades" : 10,
	"tradesPerSymbol" : 4,
	"dataSource" : "delayed"
}