Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import time
- # defining the api-endpoint
- API_ENDPOINT = "https://www.binance.com/gateway-api/v1/public/future/data/global-long-short-account-ratio"
- OI_URL = "https://www.binance.com/gateway-api/v1/public/future/data/open-interest-stats"
- # data to be sent to api
- data = {"name":"BTCUSDT","periodMinutes":5}
- while True:
- print('trying')
- # sending post request and saving response as response object
- r = requests.post(url = API_ENDPOINT, json = data)
- resp = r.text
- print(f"resp: {resp}")
- r = requests.post(url = OI_URL, json = data)
- oi_resp = r.text
- print(f"resp: {oi_resp}")
- try:
- with open('ls_data.csv', 'a') as ls_data:
- ls_data.write(resp+'\n')
- with open('oi_data.csv', 'a') as oi_data:
- oi_data.write(oi_resp+'\n')
- print('here')
- except Exception as e:
- print(e)
- time.sleep(300)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement