-
Notifications
You must be signed in to change notification settings - Fork 4
/
db_populate.py
72 lines (63 loc) · 1.62 KB
/
db_populate.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
60
61
62
63
64
65
66
67
68
69
70
71
72
from binance import enums
from datetime import datetime, timedelta
from src.repository.ohlc_repository import OhlcRepository
from src.service.klines import KLines
# Variables
# ------------------------------------------------------------------------
end_at = datetime.utcnow()
start_at = end_at - timedelta(days=365 * 10)
exchange = 'binance'
interval = '1m'
groups = [
{
"market": 'USDT',
"assets": [
'BTC',
],
"type": enums.HistoricalKlinesType.SPOT
},
{
"market": 'USDC',
"assets": [
'BTC',
],
"type": enums.HistoricalKlinesType.SPOT
},
{
"market": 'BUSD',
"assets": [
'BTC',
],
"type": enums.HistoricalKlinesType.SPOT
},
{
"market": 'DAI',
"assets": [
'BTC',
],
"type": enums.HistoricalKlinesType.SPOT
},
]
# Population of data
# ------------------------------------------------------------------------
repository = OhlcRepository()
klines = KLines()
for group in groups:
for asset in group["assets"]:
print(f'processing: {asset} {group["market"]} {interval}')
collection = klines.build_klines(
group["market"],
asset,
group["type"],
interval,
start_at.timestamp(),
end_at.timestamp(),
)
print(len(collection))
repository.create_many(
exchange,
"USDT",
f'{asset}{group["market"]}', # rename hack to get mode balanced data(BTC)
interval,
collection
)