Skip to main content

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

NameTypeDescription
symbol*stringStock symbol
from*stringStart date (format: yyyy-MM-dd)
to*stringEnd date (format: yyyy-MM-dd)
timeframe*stringK-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*numberFast line period
slow*numberSlow line period
signal*numberSignal 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

NameTypeDescription
symbol*stringStock symbol
from*stringStart date
to*stringEnd date
timeframe*stringK-line period
fast*numberFast line period
slow*numberSlow line period
signal*numberSignal line period
dataObjectRSI data
>> data[0].datestringData date
>> data[0].macdLinenumberMACD line
>> data[0].signalLinenumberSignal line
info

'*' indicates required fields.

Example

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"}

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
}
]
}