-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
52 lines (37 loc) · 1.39 KB
/
main.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
from common import util
from common.FtxClientRest import FtxClient
from dateutil import parser
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import numpy as np
api_key = ''
api_secret = ''
client = FtxClient(api_key, api_secret, 'Funding')
def historic_funding_rates():
start_timestmap = util.date_to_timestamp(2021, 6, 1, 0)
end_timestmap = util.date_to_timestamp(2021, 6, 29, 0)
fundings_history = client.get_funding_rates(future='MEDIA-PERP', start_time=start_timestmap, end_time=end_timestmap)
times = [parser.parse(i['time']) for i in fundings_history]
rates = [i['rate'] for i in fundings_history]
plt.figure()
plt.plot(times, rates)
plt.xticks(rotation=45)
plt.grid()
plt.show()
def search_funding_rates():
fr = client.get_all_funding_rates()
def analyze_funding_payments():
start_timestamp = util.date_to_timestamp(2022, 6, 29, 0)
end_timestamp = util.timestamp_now()
funding_payments = client.get_funding_payments(start_timestamp, end_timestamp)
instrument_payments = {} # instrument: tot_payment
for fp in funding_payments:
name = fp['future']
if name in instrument_payments:
instrument_payments[name] += fp['payment']
else:
instrument_payments[name] = 0
return instrument_payments
# historic_funding_rates()
# pt = analyze_funding_payments()
print('done')