-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathx_factor.py
59 lines (46 loc) · 1.25 KB
/
x_factor.py
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import exchanges
import pandas as pd
import data_class as dc
import futures_pairs as coin
def pair_list():
"""Lists futures pairs by exchange."""
exchange = exchanges.exchange_selector()
pair_object = coin.Futures_Pairs(exchange)
futures_pairs = pair_object.token_collector()
return futures_pairs
def x_factor(pages: int):
"""Calculates vol/mktCap & returns a DataFrame."""
data = dc.Data(pages)
df = pd.DataFrame(data.instant_data())
df = df[
[
"market_cap_rank",
"id",
"symbol",
"current_price",
"total_volume",
"market_cap",
]
]
volume = df["total_volume"]
mktCap = df["market_cap"]
x_factor = volume / mktCap
df["X Factor"] = x_factor
# -- collects futures pairs
futures_pairs = pair_list()
for _ in df.symbol:
if _ not in futures_pairs:
df = df[df["symbol"] != _]
watchlist = df[
[
"market_cap_rank",
"id",
"symbol",
"X Factor",
]
]
# -- index editing block
watchlist.reset_index(inplace=True, drop=True)
watchlist.index += 1
return watchlist
# TODO - pd.options.display.float_format = "{:.2f}".format