<commit_before>package com.jbooktrader.indicator.depth;

import com.jbooktrader.platform.indicator.*;
import java.util.*;

/**
 * This indicator computes the standard deviation of the last <period> prices.
 * 
 * To compute the Bollinger Bands, use this indicator, and take:
 *       getMean() + getValue() * NumStdDev for the upper band and 
 *       getMnea() - getValue() * NumStdDev for the lower band. 
 * 
 * @author mkoistinen
 */
public class DepthBalanceStrengthStdDev extends Indicator {

	private final int period;
	
	private LinkedList<Double> history = new LinkedList<Double>();
	private double strength, sum, mean, sum_sqr;
	
	public DepthBalanceStrengthStdDev(int period) {
		this.period = period;
		reset();
	}
	
	@Override
	public void reset() {
		value = sum = sum_sqr = mean = 0.0;
		history.clear();
	}

	@Override
	public void calculate() {
		strength = Math.abs(marketBook.getSnapshot().getBalance());
		
		history.addLast(strength);
		sum += strength;
		sum_sqr += strength*strength;
		
		if (history.size() > period) {
			strength = history.removeFirst();
			sum -= strength;
			sum_sqr -= strength*strength;
		}
		
		if (history.size() > 0) {
			mean = sum/history.size();
			value = Math.sqrt((sum_sqr - sum*mean)/(history.size()));
		}
	}
	
	public double getMean() {
		return mean;
	}

}<commit_msg>Minor update<commit_after>package com.jbooktrader.indicator.depth;

import com.jbooktrader.platform.indicator.*;
import java.util.*;

/**
 * This indicator computes the standard deviation of the last <period> prices.
 * 
 * To compute the Bollinger Bands, use this indicator, and take:
 *       getMean() + getValue() * NumStdDev for the upper band and 
 *       getMnea() - getValue() * NumStdDev for the lower band. 
 * 
 * @author mkoistinen
 */
public class DepthBalanceStrengthStdDev extends Indicator {

	private final int period;
	
	private LinkedList<Double> history = new LinkedList<Double>();
	private double strength, sum, mean, sum_sqr;
	
	public DepthBalanceStrengthStdDev(int period) {
		this.period = period;
		reset();
	}
	
	@Override
	public void reset() {
		value = sum = sum_sqr = mean = 0.0;
		history.clear();
	}

	@Override
	public void calculate() {
		strength = Math.abs(marketBook.getSnapshot().getBalance());
		
		history.addLast(strength);
		sum += strength;
		sum_sqr += strength * strength;
		
		if (history.size() > period) {
			strength = history.removeFirst();
			sum -= strength;
			sum_sqr -= strength * strength;
		}
		
		if (history.size() > 0) {
			mean = sum/history.size();
			value = Math.sqrt((sum_sqr - sum * mean)/history.size());
		}
	}
	
	public double getMean() {
		return mean;
	}

}
{'fraction_non_alphanumeric': 0.1272111403838916, 'fraction_numerical': 0.002258185923974407, 'mean_word_length': 3.5513698630136985, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7251020', 'n_tokens_mistral': 948, 'n_tokens_neox': 833, 'n_words': 230}