Technical MACD
Get Moving Average Convergence Divergence (MACD) for a specific stock within a specified time range
technical/macd/{symbol}
Version Info.
Available since v2.2.6
Parameters
| Name | Type | Description |
|---|---|---|
symbol* | string | Stock symbol |
from* | string | Start date (format: yyyy-MM-dd) |
to* | string | End date (format: yyyy-MM-dd) |
timeframe* | string | K-line period, options: 1 1-min K; 5 5-min K; 10 10-min K; 15 15-min K; 30 30-min K; 60 60-min K; D daily K; W weekly K; M monthly K |
fast* | number | Fast line period |
slow* | number | Slow line period |
signal* | number | Signal line period |
caution
Currently, minute K-lines cannot specify start date (from) and end date (to), and will always return the most recent 30 days of data.
Response
| Name | Type | Description |
|---|---|---|
symbol* | string | Stock symbol |
from* | string | Start date |
to* | string | End date |
timeframe* | string | K-line period |
fast* | number | Fast line period |
slow* | number | Slow line period |
signal* | number | Signal line period |
data | Object | RSI data |
>> data[0].date | string | Data date |
>> data[0].macdLine | number | MACD line |
>> data[0].signalLine | number | Signal line |
info
'*' indicates required fields.
Example
- Python
- Node.js
- C#
from fubon_neo.sdk import FubonSDK, Order
sdk = FubonSDK()
accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # Login required to obtain market data permissions
sdk.init_realtime() # Establish market data connection
reststock = sdk.marketdata.rest_client.stock
## Version 2.2.6 and later use simplified approach (using Exception for error handling)
from fubon_neo.sdk import FugleAPIError
try:
reststock.technical.macd(**{"symbol": "2330", "from": "2024-08-01", "to": "2024-08-10","timeframe":"D", "fast": 12, "slow":26, "signal":9})
except FugleAPIError as e:
print(f"Error: {e}")
print("------------")
print(f"Status Code: {e.status_code}") # Example: 429
print(f"Response Text: {e.response_text}") # Example: {"statusCode":429,"message":"Rate limit exceeded"}
const { FubonSDK } = require('fubon-neo');
const sdk = new FubonSDK();
const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password");
sdk.initRealtime(); // Establish market data connection
const client = sdk.marketdata.restClient
client.stock.technical.macd({ symbol: '2330', from: '2024-08-01', to: '2024-08-10', timeframe: 'D', fast: 12, slow: 26, signal: 9, dPeriod: 3 })
.then(data => console.log(data));
using FubonNeo.Sdk;
using FugleMarketData.QueryModels.Stock.History; // Import HistoryTimeFrame
using FugleMarketData.QueryModels; // Import FieldsType
var sdk = new FubonSDK();
var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password");
sdk.InitRealtime(); // Establish market data connection
var rest = sdk.MarketData.RestClient.Stock;
DateTime fromDate = new DateTime(2024, 8, 1);
DateTime toDate = new DateTime(2024, 8, 10);
var macd = await rest.Technical.Macd("2330" ,new( 12, 26, 9, fromDate, oDate, HistoryTimeFrame.Day));
//MacdRequest parameters (fast, slow, signal DateTime, DateTime, HistoryTimeFrame)
var macd_con = macd.Content.ReadAsStringAsync().Result;
Console.WriteLine(macd_con);
Response Body:
{
"symbol": "2330",
"from": "2024-08-01",
"to": "2024-08-10",
"timeframe": "D",
"fast": 12,
"slow": 26,
"signal": 9,
"data": [
{
"date": "2024-08-01",
"macdLine": -8.888098865883194,
"signalLine": 1.1835714956164298
},
{
"date": "2024-08-02",
"macdLine": -13.342205320023709,
"signalLine": -1.721583867511598
},
{
"date": "2024-08-05",
"macdLine": -23.69978495993405,
"signalLine": -6.117224085996089
},
{
"date": "2024-08-06",
"macdLine": -26.359429578554114,
"signalLine": -10.165665184507695
},
{
"date": "2024-08-07",
"macdLine": -24.951921179141777,
"signalLine": -13.12291638343451
},
{
"date": "2024-08-08",
"macdLine": -25.47934996958338,
"signalLine": -15.594203100664284
},
{
"date": "2024-08-09",
"macdLine": -22.570875660446973,
"signalLine": -16.989537612620822
}
]
}