36
Follow
12
Followers
| head1 | head2 | head3 |
|---|---|---|
| column1 | column2 | column3 |
| column1 | column2 | column3 |
| head1 | head2 | head3 |
| ------ | ------ | ------ |
| column1 | column2 | column3 |
\[ a+b= c \]
asdasd
#123
1123123
javascript
/*backtest
start: 2023-01-01 00:00:00
end: 2024-01-01 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"OKX","currency":"BTC_USD"}]
*/
// 线性回归函数
function linearRegression(y) {
var n = y.length;
var sum_x = 0;
var sum_y = 0;
var sum_xy = 0;
var sum_x2 = 0;
for (var i = 0; i < n; i++) {
sum_x += i;
sum_y += y[i];
sum_xy += i * y[i];
sum_x2 += i * i;
}
var slope = (n * sum_xy - sum_x * sum_y) / (n * sum_x2 - sum_x * sum_x);
var intercept = (sum_y - slope * sum_x) / n;
return {
slope: slope,
intercept: intercept
};
}
function main() {
var records = exchange.GetRecords();
if (!records || records.length < 30) {
Log("数据不足, 等待数据...");
return;
}
var closePrices = [];
for (var i = 0; i < 30; i++) {
closePrices.push(records[records.length - 30 + i].Close);
}
var regression = linearRegression(closePrices);
Log("斜率:", regression.slope, " 截距:", regression.intercept);
Log("线性回归预测值:", regression.slope * 30 + regression.intercept);
}
Related Recommendations
How to Specify Different Versions of Data for the Rented Strategy by Its Rental Code MetadataAdvanced Tutorial for FMZ Quant platform Strategy WritingElementary Tutorial for FMZ Quant platform Strategy WritingGet Started with FMZ Quant PlatformSECURITY BUGI keep getting error: Exchange_GetAccount: Invalid ContractTypeWe have an incredibly profitable market making algorithm for sideways markets on Bitmex - but need expert to help eliminate wait times during downward volatility in the marketError with deribitLimitations of the backtesting engineHow to install ta-lib on linux docker?
Comment
All comments (24)
- 1





