Created
January 26, 2022 23:31
-
-
Save Henelik/074b862e29e5d82cef942f6e4d8ab169 to your computer and use it in GitHub Desktop.
Scrape your entire trade history from qTrade
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from qtrade_client.api import QtradeAPI | |
import json | |
def scrape_trades(api): | |
trades = api.get('/v1/user/trades')["trades"] | |
while True: | |
new_trades = api.get('/v1/user/trades', newer_than=trades[-1]["id"])["trades"] | |
if len(new_trades) == 0: | |
break | |
trades += new_trades | |
return trades | |
if __name__ == "__main__": | |
hmac = open("hmac.txt").read().strip() | |
api = QtradeAPI("https://api.qtrade.io", key=hmac) | |
trades = scrape_trades(api) | |
f = open("trades.json", "w") | |
f.write(json.dumps(trades)) | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment