# The Light Price Index

## Introduction

Light options are settled by referencing our final index price.  This index price is carefully calculated to make cheating or price manipulation very very difficult.  Furthermore, in the interest of full transparency, we publish both our algorithm and all the historical data.

## The Index Price Algorithm

In order to make price manipulation difficult, we introduce the concept of  a “clipped average”.  For any give set of numbers, the highest and lowest values are removed, and then we average the remaining middle values.

Our price index is calculated by looking at the completed transactions of multiple exchanges.  For each exchange we calculated the clipped average of the trade price.  Then we calculated the clipped average of those exchange averages.

## Raw Data

Every hour, we upload the raw data, used to calculate our index price, to the Amazon cloud. This data is publicly available to anyone. You may access our raw index price data files here:

proof.light.cx

Below is a sample of Python code to calculate our index price:

```#!/usr/bin/python
import json
with open(data.json) as f:
for row in data:
# First calculate the clipped mean for each exchange
exchange_prices = []
for exchange in row['components'].keys():
temp = row['components'][exchange]
temp = sorted(temp)
del temp[-1]
del temp
exchange_mean = sum(temp) / len(temp)
exchange_prices.append(exchange_mean)

# Now take the clipped mean of each exchanges mean
temp = sorted(exchange_prices)
del temp[-1]
del temp
price = sum(temp) / len(temp)
price = round(price * 100) / 100 # Round to cents
print(Price is: {}.format(price))

```