-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsortData.py
More file actions
35 lines (35 loc) · 1.41 KB
/
sortData.py
File metadata and controls
35 lines (35 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
def sortData(tickers):
sortedData = []
for markets in tickers:
# identify and define what the base markets are for each market. All of the base markets have symbols with three letters other than
# USDT and TUSD
# this is what the raw data looks like from hitbtc
# {
# "ask": "0.050043",
# "bid": "0.050042",
# "last": "0.050042",
# "open": "0.047800",
# "low": "0.047052",
# "high": "0.051679",
# "volume": "36456.720",
# "volumeQuote": "1782.625000",
# "timestamp": "2017-05-12T14:57:19.999Z",
# "symbol": "ETHBTC"
# }
#
if markets['symbol'][-4:] == "USDT" or markets['symbol'][-4:] == "TUSD":
baseMarket = markets['symbol'][-4:]
altMarket = markets['symbol'][:len(markets['symbol']) - 4]
else:
baseMarket = markets['symbol'][-3:]
altMarket = markets['symbol'][:len(markets['symbol']) - 3]
# append each market to the table. This takes only the most basic information, the bid/ask prices, and the market names
marketLog = {
"symbol": markets['symbol'],
"base": baseMarket,
"alt": altMarket,
"bid": float(markets['bid']),
"ask": float(markets['ask'])
}
sortedData.append(marketLog)
return(sortedData)