Ejemplo n.º 1
0
 def _get_prices(self, target='USD'):
     prices = {}
     filename = config.get_price_filename(self.ticker, target=target)
     for row in utils.get_csvreader(filename):
         # Skip header
         if row[0] == 'year':
             continue
         date = datetime.strptime(' '.join(row[:3]), '%Y %m %d')
         key = self._time_to_key(date)
         prices[key] = float(row[3])
     return prices
Ejemplo n.º 2
0
 def _get_prices(self, target='USD'):
     prices = {}
     filename = config.get_price_filename(self.ticker, target=target)
     for row in utils.get_csvreader(filename):
         # Skip header
         if row[0] == 'year':
             continue
         date = datetime.strptime(' '.join(row[:3]), '%Y %m %d')
         key = self._time_to_key(date)
         prices[key] = float(row[3])
     return prices
Ejemplo n.º 3
0
import config
import utils

logging.basicConfig(level=logging.INFO)
INPUT_FILE = os.path.expanduser(sys.argv[1])

def log(msg):
    logging.info(msg)

log("Creating data structures")

# maintaining two dictionaries saves time by using more memory
clusters = {} #  cluster_id : list of pubkeys
cluster_directory = {} # pubkey : cluster_id

for row in utils.get_csvreader(INPUT_FILE):
    if len(row) < 2:
        continue
    clusters[row[1]] = [row[1]]
    cluster_directory[row[1]] = row[1]

    clusters[row[3]] = [row[3]]
    cluster_directory[row[3]] = row[3]

log("Generating clusters with Heuristic 1")
last_transaction_id = None
last_cluster_id = None
counter = 0
for row in utils.get_csvreader(INPUT_FILE):
    if len(row) < 2:
        continue
Ejemplo n.º 4
0
OUTPUT_COUNTS_FILE = os.path.expanduser(sys.argv[3])

OUTPUT_FILENAME = None
SHOULD_PRINT = False
if sys.argv[2] == "--print":
    SHOULD_PRINT = True
else:
    OUTPUT_FILENAME = os.path.expanduser(sys.argv[4])


def log(msg):
    logging.info(msg)

input_counts = defaultdict(int)
output_counts = defaultdict(int)
for row in utils.get_csvreader(INPUT_COUNTS_FILE):
    if len(row) > 1:
        input_counts[int(row[0])] = int(row[1])
for row in utils.get_csvreader(OUTPUT_COUNTS_FILE):
    if len(row) > 1:
        output_counts[int(row[0])] = int(row[1])


def update_balances(tx_inputs, tx_outputs, balances):
    # Correct for multiple counts
    input_set = set(tx_inputs.keys())
    output_set = set(tx_outputs.keys())

    for pubkey in tx_inputs.keys():
        tx_inputs[pubkey] /= output_counts[last_tx]
    for pubkey in tx_outputs.keys():
Ejemplo n.º 5
0
logging.basicConfig(level=logging.INFO)
INPUT_FILE = os.path.expanduser(sys.argv[1])


def log(msg):
    logging.info(msg)


log("Creating data structures")

# maintaining two dictionaries saves time by using more memory
clusters = {}  #  cluster_id : list of pubkeys
cluster_directory = {}  # pubkey : cluster_id

for row in utils.get_csvreader(INPUT_FILE):
    if len(row) < 2:
        continue
    clusters[row[1]] = [row[1]]
    cluster_directory[row[1]] = row[1]

    clusters[row[3]] = [row[3]]
    cluster_directory[row[3]] = row[3]

log("Generating clusters with Heuristic 1")
last_transaction_id = None
last_cluster_id = None
counter = 0
for row in utils.get_csvreader(INPUT_FILE):
    if len(row) < 2:
        continue
Ejemplo n.º 6
0
OUTPUT_FILENAME = None
SHOULD_PRINT = False
if sys.argv[2] == "--print":
    SHOULD_PRINT = True
else:
    OUTPUT_FILENAME = os.path.expanduser(sys.argv[4])


def log(msg):
    logging.info(msg)


input_counts = defaultdict(int)
output_counts = defaultdict(int)
for row in utils.get_csvreader(INPUT_COUNTS_FILE):
    if len(row) > 1:
        input_counts[int(row[0])] = int(row[1])
for row in utils.get_csvreader(OUTPUT_COUNTS_FILE):
    if len(row) > 1:
        output_counts[int(row[0])] = int(row[1])


def update_balances(tx_inputs, tx_outputs, balances):
    # Correct for multiple counts
    input_set = set(tx_inputs.keys())
    output_set = set(tx_outputs.keys())

    for pubkey in tx_inputs.keys():
        tx_inputs[pubkey] /= output_counts[last_tx]
    for pubkey in tx_outputs.keys():