-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpolygon.py
More file actions
20 lines (18 loc) · 1001 Bytes
/
polygon.py
File metadata and controls
20 lines (18 loc) · 1001 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import datetime
import csv
if __name__ == '__main__':
polygon = open("input/polygon-in", "r")
output_lines = []
for line in polygon.readlines():
type, timestamp, out_amount, out_currency, in_amount, in_currency, size_usd = line.split(',')
timestamp2 = datetime.datetime.strptime(timestamp, "%b-%d-%Y %I:%M:%S %p +UTC").strftime("%Y-%m-%dT%H:%M:%S")
if in_currency == 'WETH':
in_currency = 'ETH'
if out_currency == 'WETH':
out_currency = 'ETH'
output_lines.append([timestamp2, 'Sell', float(size_usd), 'USD', float(out_amount), out_currency, '0', 'USD', 'POLYGON', 'US'])
output_lines.append([timestamp2, 'Buy', float(in_amount), in_currency, float(size_usd), 'USD', '0', 'USD', 'POLYGON', 'US'])
with open('output/poly-trades.csv', mode='w') as output:
output = csv.writer(output, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
for txn in output_lines:
output.writerow(txn)