-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkline_cli.py
More file actions
28 lines (23 loc) · 1.07 KB
/
Copy pathkline_cli.py
File metadata and controls
28 lines (23 loc) · 1.07 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
#!/usr/bin/env python
# encoding: utf-8
import json
import requests
from enumeration import KLineSymbol, KLineInterval
def get_previous_klines(kline_provider: str, symbol: KLineSymbol, interval: KLineInterval, end_time: int,
limit: int, proxies: dict = None) -> list:
assert limit <= 1000
url = '{}/api/kline/{}/{}/previous?endTime={}&&limit={}' \
.format(kline_provider, symbol.value, interval.value, end_time * 1000, limit)
session = requests.Session()
session.trust_env = False
resp = session.get(url=url, proxies=proxies)
return json.loads(resp.text)
def get_next_klines(kline_provider: str, symbol: KLineSymbol, interval: KLineInterval, from_time: int,
limit: int, proxies: dict = None) -> list:
assert limit <= 1000
url = '{}/api/kline/{}/{}/next?fromTime={}&&limit={}' \
.format(kline_provider, symbol.value, interval.value, from_time * 1000, limit)
session = requests.Session()
session.trust_env = False
resp = session.get(url=url, proxies=proxies)
return json.loads(resp.text)