You can calculate TA off of any candle set you have. Using this method requires sending a simple post including the candle data for which to calculate an indicator value.
Pro’s
- Calculate TA for any market / exchange / symbol / time frame, stock-market, crypto-market, OTC, etc…
- Run backtesting on your strategy if you have the historical data.
Con’s
- You need to have / get the candle data ready yourself.
Getting started
Simply post your candles, along with your API Secret to the API:
[POST] https://api.taapi.io/rsi
Include a post parameter: ‘candles’ containing the candles in JSON. The candles must be sent as objects with below keys in an array:
- timestamp: An integer containing the timestamp of the candle in microseconds (not milliseconds)
- open: A float, containing the open price of the candle
- high: A float, containing the high price of the candle
- low: A float, containing the low price of the candle
- close: A float, containing the close price of the candle
- volume: A float, containing the volume of the candle
Example:
[
{
'timestamp': 83293829,
'open': 238.32,
'high': 343.12,
'low': 125.94,
'close': 243.48,
'volume': 84342.84823
},
{
'timestamp': 83293829,
'open': 238.32,
'high': 343.12,
'low': 125.94,
'close': 243.48,
'volume': 84342.84823
},
... n candles
]
The amount of candles depends on which indicator is used. If not sure, then send 300 candles. This amount will work for more or less all indicators.
Mandatory Parameters
Below a list of mandatory post parameters, needed to query the API “manually”:
Parameter | Type | Description | |
---|---|---|---|
secret | String | The secret which is emailed to you when you Request an API key. | |
candles | JSON (array with candle objects) | A JSON encoded array of objects containing candle information (as described above) |
Optional Parameters
There are no optional paramters for this integration method, other than the ones stated for each indicator on the Indicator endpoints page.
Note: You cannot use the ‘backtrack’ option with this method. If you need to calculate back in time, then remove candles from your dataset yourself.
Examples
NodeJS
// Require axios: npm i axios
const axios = require('axios');
axios.post('https://api.taapi.io/rsi', { // Replace rsi with any other indicator
params: {
secret: MY_SECRET,
candles: [{...}]
}
})
.then(function (response) {
console.log(response.data);
})
.catch(function (error) {
console.log(error);
});
PHP
<?php
$candles = [{...}]; // Candles json encoded
// Prepare new cURL resource
$ch = curl_init('https://api.taapi.io/rsi');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $canldes);
// Set HTTP Header for POST request
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($canldes))
);
// Submit the POST request
$result = curl_exec($ch);
// Close cURL session handle
curl_close($ch);
// View result
print_r(json_decode($result));