Files
Chan/web/static/js/app/api_client.js
T
jackyu66gitandCursor c22cd48f36 Web 加上资金面/情绪叠图,并收紧默认图面。
默认主/次/次次改为 45m/15m/5m、开始时间一周;SD/CD 按 hist 摆位置和箭头;去掉笔线段背驰与第四类勾选。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-12 02:25:44 +08:00

49 lines
1.6 KiB
JavaScript

/* Chan web API client helpers */
window.ChanApi = {
analyze: function(params) {
const q = new URLSearchParams(params);
return fetch('/api/analyze?' + q.toString()).then(r => r.json());
},
chartMetadata: function() {
return fetch('/api/chart_metadata').then(r => r.json());
},
symbols: function() {
return fetch('/api/symbols').then(r => r.json());
},
derivatives: function(params) {
const q = new URLSearchParams(params || {});
return fetch('/api/derivatives?' + q.toString()).then(function(r) {
return r.json().then(function(body) {
if (!r.ok) throw new Error((body && body.error) || r.statusText);
return body;
});
});
},
sentimentLatest: function(params) {
const q = new URLSearchParams(params || {});
return fetch('/api/sentiment/latest?' + q.toString()).then(function(r) {
return r.json().then(function(body) {
if (!r.ok) throw new Error((body && body.error) || r.statusText);
return body;
});
});
},
sentimentMetrics: function(params) {
const q = new URLSearchParams(params || {});
return fetch('/api/sentiment/metrics?' + q.toString()).then(function(r) {
return r.json().then(function(body) {
if (!r.ok) throw new Error((body && body.error) || r.statusText);
return body;
});
});
},
macdConfig: function(body) {
if (body === undefined) return fetch('/api/macd_config').then(r => r.json());
return fetch('/api/macd_config', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify(body)
}).then(r => r.json());
}
};