|
@@ -28,43 +28,67 @@ def compile_prices(ticker):
|
|
|
|
|
|
return prices
|
|
return prices
|
|
|
|
|
|
-
|
|
|
|
-def compile_stable_ins(t):
|
|
|
|
-
|
|
|
|
|
|
+def aggregate_stable_outs():
|
|
txs_db = {}
|
|
txs_db = {}
|
|
txs_objs = {}
|
|
txs_objs = {}
|
|
for ticker in stable_tickers:
|
|
for ticker in stable_tickers:
|
|
txs_db[ticker] = open('dbs/crypto-txs-'+ticker+'.db.json', 'r')
|
|
txs_db[ticker] = open('dbs/crypto-txs-'+ticker+'.db.json', 'r')
|
|
txs_objs[ticker] = json.load(txs_db[ticker])
|
|
txs_objs[ticker] = json.load(txs_db[ticker])
|
|
txs_db[ticker].close()
|
|
txs_db[ticker].close()
|
|
- ins = {'timestamps': [], 'values': []}
|
|
|
|
|
|
|
|
- #TODO
|
|
|
|
|
|
+ aggregated_outs = {} # [timestamp] = net_val
|
|
|
|
+ for ticker in stable_tickers:
|
|
|
|
+ for timestamp in txs_objs[ticker]:
|
|
|
|
+ aggregated_outs[timestamp] = 0
|
|
|
|
+ for ticker in stable_tickers:
|
|
|
|
+ for timestamp, accumulator in txs_objs[ticker].items():
|
|
|
|
+ aggregated_outs[timestamp] += accumulator['out']
|
|
|
|
|
|
- return ins
|
|
|
|
-
|
|
|
|
|
|
+ return aggregated_outs
|
|
|
|
|
|
-def compile_stable_net(t):
|
|
|
|
-
|
|
|
|
|
|
+def aggregate_stable_ins():
|
|
txs_db = {}
|
|
txs_db = {}
|
|
txs_objs = {}
|
|
txs_objs = {}
|
|
for ticker in stable_tickers:
|
|
for ticker in stable_tickers:
|
|
txs_db[ticker] = open('dbs/crypto-txs-'+ticker+'.db.json', 'r')
|
|
txs_db[ticker] = open('dbs/crypto-txs-'+ticker+'.db.json', 'r')
|
|
txs_objs[ticker] = json.load(txs_db[ticker])
|
|
txs_objs[ticker] = json.load(txs_db[ticker])
|
|
txs_db[ticker].close()
|
|
txs_db[ticker].close()
|
|
- nets = {'timestamps': [], 'values': []}
|
|
|
|
|
|
|
|
- stable_nets = {} # [timestamp] = net_val
|
|
|
|
|
|
+ aggregated_ins = {} # [timestamp] = net_val
|
|
for ticker in stable_tickers:
|
|
for ticker in stable_tickers:
|
|
for timestamp in txs_objs[ticker]:
|
|
for timestamp in txs_objs[ticker]:
|
|
- stable_nets[timestamp] = 0
|
|
|
|
|
|
+ aggregated_ins[timestamp] = 0
|
|
for ticker in stable_tickers:
|
|
for ticker in stable_tickers:
|
|
for timestamp, accumulator in txs_objs[ticker].items():
|
|
for timestamp, accumulator in txs_objs[ticker].items():
|
|
- stable_nets[timestamp] += accumulator['in'] - accumulator['out']
|
|
|
|
|
|
+ aggregated_ins[timestamp] += accumulator['in']
|
|
|
|
+
|
|
|
|
+ return aggregated_ins
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+def compile_stable_ins(t):
|
|
|
|
+
|
|
|
|
+ txs_db = {}
|
|
|
|
+ txs_objs = {}
|
|
|
|
+ for ticker in stable_tickers:
|
|
|
|
+ txs_db[ticker] = open('dbs/crypto-txs-'+ticker+'.db.json', 'r')
|
|
|
|
+ txs_objs[ticker] = json.load(txs_db[ticker])
|
|
|
|
+ txs_db[ticker].close()
|
|
|
|
+ ins = {'timestamps': [], 'values': []}
|
|
|
|
+
|
|
|
|
+ #TODO
|
|
|
|
+
|
|
|
|
+ return ins
|
|
|
|
+
|
|
|
|
+def compile_stable_net(t):
|
|
|
|
+
|
|
|
|
+ ins = aggregate_stable_ins()
|
|
|
|
+ outs = aggregate_stable_outs()
|
|
|
|
+
|
|
|
|
+ nets = {'timestamps': [], 'values': []}
|
|
|
|
|
|
- for timestamp, net in stable_nets.items():
|
|
|
|
|
|
+ for timestamp in ins:
|
|
nets['timestamps'].append( int(timestamp)//3600 )
|
|
nets['timestamps'].append( int(timestamp)//3600 )
|
|
- nets['values'].append( net )
|
|
|
|
|
|
+ nets['values'].append( ins[timestamp] - outs[timestamp] )
|
|
|
|
|
|
return nets
|
|
return nets
|
|
|
|
|
|
@@ -107,11 +131,11 @@ def compile_dif_net(ticker):
|
|
#TODO
|
|
#TODO
|
|
|
|
|
|
|
|
|
|
-functions = { '--i': compile_ins, '--n': compile_net, '--di': compile_dif_ins, '--dn': compile_dif_net, '--si': compile_stable_ins, '--sn': compile_stable_net }
|
|
|
|
|
|
+functions = { '--i': compile_ins, '--n': compile_net, '--di': compile_dif_ins, '--dn': compile_dif_net, '--si': compile_stable_ins, '--sn': compile_stable_net, '--sn2': compile_stable_net2 }
|
|
|
|
|
|
def main():
|
|
def main():
|
|
argv = sys.argv[1:]
|
|
argv = sys.argv[1:]
|
|
- opts, args = getopt.getopt(argv, '', longopts=['i','n','di','dn','si','sn'])
|
|
|
|
|
|
+ opts, args = getopt.getopt(argv, '', longopts=['i','n','di','dn','si','sn', 'sn2'])
|
|
print(opts)
|
|
print(opts)
|
|
if len(args) < 1:
|
|
if len(args) < 1:
|
|
print("error: no ticker")
|
|
print("error: no ticker")
|