This repository was archived by the owner on Jul 16, 2026. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 128
Expand file tree
/
Copy pathapp.py
More file actions
Latest commit
46 lines (38 loc) · 1.46 KB
/
Copy pathapp.py
File metadata and controls
46 lines (38 loc) · 1.46 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# !/usr/bin/env python
# coding: utf-8
importlogging
fromargparseimportArgumentParser
fromconfigimportRunConfig
fromfuturesimportfutures_demo
frommarginimportmargin_demo
fromspotimportspot_demo
logging.basicConfig(format="%(asctime)s: %(message)s", level=logging.DEBUG)
logger=logging.getLogger(__name__)
defmain():
parser=ArgumentParser(description="Run Gate APIv4 demo application")
parser.add_argument("-k", "--key", required=True, help="Gate APIv4 Key")
parser.add_argument("-s", "--secret", required=True, help="Gate APIv4 Secret")
parser.add_argument("-u", "--url", required=False, help="API base URL used to test")
parser.add_argument("tests", nargs='+', help="tests to run")
options=parser.parse_args()
host_used=options.url
ifnothost_used:
host_used="https://api.gateio.ws/api/v4"
ifnothost_used.startswith("http"):
host_used="https://"+host_used
host_used=host_used.rstrip("/")
ifnothost_used.endswith("/api/v4"):
host_used+='/api/v4'
run_config=RunConfig(options.key, options.secret, host_used)
fortinoptions.tests:
logger.info("run %s API demo", t)
ift=='spot':
spot_demo(run_config)
elift=='margin':
margin_demo(run_config)
elift=='futures':
futures_demo(run_config)
else:
logger.warning("ignore unknown test %s", t)
if__name__=='__main__':
main()