Estadísticas de rentabilidad

El autor:¿Qué es eso?, fecha: 2016-08-01 00:29:26
Las etiquetas:Herramienta

Rentabilidad estadística

Las estadísticas de ganancias de BotVS solo registran una curva. No se puede realizar análisis técnicos. Esta plantilla puede realizar estadísticas automáticas de ganancias, ganancias, ganancias mensuales, ganancias mensuales, ganancias mensuales, ganancias mensuales y retiros máximos de los últimos días, últimos días, últimos días, últimos días, últimos días, últimos días, últimos días, últimos días y todos los tiempos.

Utilización: Introduce esta plantilla para reemplazar la función LogProfit de la política original por $.LogProfit. Y añade la cadena de retorno de $.ProfitSummary ((capital inicial) en el lugar de LogStatus.

Por ejemplo: La función principal (() { mientras (true) { Var t = exchange.GetTicker (((); el valor de las acciones es el valor de las acciones. Los usuarios de los sitios web de los usuarios de los sitios web de los usuarios de los sitios web. LogStatus (($.ProfitSummary ((10000))); y el sitio web de la empresa. ¿Qué es lo que está pasando? ¿Por qué no? ¿Por qué no?

Muestra los resultados:

1er día: recaudación de 78,44 yuanes ((-0,537%), mensual de 16,781%, anual de 204,169%, retiro de 1,106% En el último día: recaudación de 176.08 yuanes ((1.221%), menstruación de 38.226%, anualización de 465.087%, retiro de 1.236% 7 de enero: 771.74 yuanes (5,599%), 24,141% en el mes, 293,719 en el año y 1,517% en el retiro. El 7 de julio: 223.15 yuanes (~1.64%), 7.071 por ciento mensual, 86.039 por ciento anual y 0.9% retroactivo. 30 de enero: recaudación de 1570.31 yuanes ((12.094%), mensual 12.111%, anual 147.352%, retiro 3.251% En el último 30 días: recaudación de 200.12 yuanes ((1.565%), mensual 1.567%, anual 19.076%, retirada de 1.521% Total: 4554.11 yuanes ((45.541%), máximo retiro 3.251%, tiempo estadístico de 74 días y 23 horas


$.LogProfit = function(profit) {
    var args = Array.prototype.slice.call(arguments);
    if (SYS_LOGPROFIT) {
        LogProfit.apply(this, args);
    } else {
        args.unshift('收益');
        Log.apply(this,args);
    }

    var _history = $.GetAllProfit();
    _history.push([ Math.floor(new Date().getTime()/1000), profit]);
    _G('profit_history', JSON.stringify(_history));
};

$.GetAllProfit = function() {
	var old = _G('profit_history') || '[]';
    try {
    	var _history = JSON.parse(old);
    	return _history;
    } catch(e) {
    	_G('profit_history', null);
    	return [];
    }
};

function filterProfit(from, to) {
	var arr = $.GetAllProfit();
	if (!arr || arr.length === 0) return;
	var re, maxdrawback=0, lastProfit=0, maxProfit=false, maxdrawbackProfit=0;
	var earlest, latest;
	for(var i=0;i<arr.length;i++) {
		if (!arr[i]) continue;
		if (arr[i][0] > from && arr[i][0] <= to) {
			var profit = arr[i][1];
			if (!earlest) earlest = arr[i];
			latest = arr[i];
			if (!lastProfit) lastProfit = profit;
			if (maxProfit === false || maxProfit < profit) maxProfit = profit;
			var drawback = maxProfit - profit;
			if (drawback > maxdrawback) {
				maxdrawback = drawback;
				maxdrawbackProfit = maxProfit;
			}
		}
	}
	if (!earlest || !latest) return;
	return [earlest, latest, maxdrawback, maxdrawbackProfit];
}

function daysProfit(offset, days) {
	var from = getDaySecond( -offset+days);
	var to = getDaySecond(-offset);
	var arr = filterProfit( from, to );
	if (!arr || !arr[0] || !arr[1]) return;
	var profitTime = arr[1][0] - arr[0][0];
	if (!profitTime) return;
	var periodTime = to - from;
	var profit = arr[1][1] - arr[0][1];
	var realPercent = profitTime*100 / periodTime;
	var expectedProfit = profit * 100 / realPercent;
	return {
		profit:profit, 
		expectedProfit:expectedProfit,
		profitTime:profitTime,
		periodTime:periodTime,
		open: arr[0][1],
		close: arr[1][1],
		drawback: arr[2],
		drawbackProfit: arr[3]
	};
}

function getDaySecond(days) {
	var d = new Date();
	var now = d.getTime();
	now -= days*86400000;
	d.setTime(now);
	return Math.floor(d.getTime() / 1000);
} 

$.DaysProfit = function(days) {
	return filterProfit(days)[2];
};

$.ProfitSummary = function(initialBalance) {
	if (!initialBalance) return '没有传入初始资金';

	var day = daysProfit(0, 1);
	var lastDay = daysProfit(-1, 1);
	var week = daysProfit(0,7);
	var lastWeek = daysProfit(-7,7);
	var month = daysProfit(0,30);
	var lastMonth = daysProfit(-30,30);
	var all = daysProfit(0, 10000);
	if (!all) return '';
	var _days = Math.floor(all.profitTime / 86400);

	var text = [];
	var t = profitSummary(day, initialBalance);
	if (t) text.push('1日: '+t);
	t = profitSummary(lastDay, initialBalance);
	if (t) text.push('上1日: '+t);
	t = profitSummary(week, initialBalance);
	if (t && _days >= 7) text.push('7日: '+t);
	t = profitSummary(lastWeek, initialBalance);
	if (t) text.push('上7日: '+t);
	t = profitSummary(month, initialBalance);
	if (t && _days>=30) text.push('30日: '+t);
	t = profitSummary(lastMonth, initialBalance);
	if (t) text.push('上30日: '+t);
	
	if (all) {
		var _days = Math.floor(all.profitTime / 86400);
		all.profitTime %= 86400;
		var _hours = Math.floor(all.profitTime / 3600);
		var drawback = _N( all.drawback*100/(all.drawbackProfit+initialBalance), 3 )+'%';
		text.push('总: 收'+_N(all.close,2)+'元('+_N(all.close*100/initialBalance,3)+'%),最大回撤'+drawback+',统计时间'+_days+'天'+_hours+'小时');
	}
	return text.join('\n');
};

function profitSummary(p, base) {
	if (!p) return '';
	var text = [];
	text.push('收'+_N(p.profit,2)+'元('+_N(p.profit*100/(base+p.open), 3)+'%)');
	var month = expectProfit(p, 30, base);
	if (month) {
		text.push('月化'+month.percent+'%');
	}
	var year = expectProfit(p, 365, base);
	if (year) {
		text.push('年化'+year.percent+'%');
	}
	text.push('回撤'+ _N( p.drawback*100/(p.drawbackProfit+base), 3 )+'%' );
	return text.join(',');
}


function expectProfit(p, days, base) {
	var expectSeconds = days*86400;
	if (expectSeconds < p.profitTime) return;
	return {
		profit: _N(p.profit * expectSeconds / p.profitTime, 2),
		percent: _N(p.profit * expectSeconds *100 / (p.profitTime * (base+p.open)),3)
	};
}

function main() {
    while(true) {
        var t = exchange.GetTicker();
        $.LogProfit(t.Last);
        LogStatus($.ProfitSummary(10000));
        Sleep(3600000);
    }
}

Relacionados

Más.

¿Qué es esto?Con esta plantilla, la velocidad de repetición es muy lenta.

NxtplayerMuchas gracias.

Loga¿Puede usar el enlace de contacto?

YWXGracias, es lo que necesitaba.

el momoxApoyo