Skip to content

Commit d022481

Browse files
authored
Create CLI_Python_Script.mdx
1 parent e342b43 commit d022481

1 file changed

Lines changed: 147 additions & 0 deletions

File tree

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# CLI Python Script
2+
3+
Table of Contents
4+
5+
Command syntax 1
6+
Command: balance 2
7+
Command: buyquantity 3
8+
Command: sellquantity 4
9+
Command: buyusdc 5
10+
Command: sellusdc 6
11+
Command: positions 7
12+
Command: buyquantitylimit 8
13+
Command: sellquantitylimit 9
14+
Command: getorder 10
15+
Command: getorderid 12
16+
Command: cancelorder 13
17+
18+
## Command syntax
19+
Run the script like this:
20+
21+
Syntax
22+
23+
python3 v4dydxcli.py <apikeyfile> <command> <parameters>
24+
where:
25+
<apikeyfile> is the apikeyfile, and
26+
<command> is the command, and
27+
<parameters> are any parameters required by the command
28+
Command: balance
29+
This command gets the balance of all of your subaccounts or a specific subaccount.
30+
Parameters: None required. May optionally specify a single subaccount to only display the balance for that subaccount.
31+
Syntax
32+
python3 v4dydxcli.py <apikeyfile> balance <optional: subaccount>
33+
Examples
34+
python3 v4dydxcli.py testnet.py balance
35+
python3 v4dydxcli.py testnet.py balance 0
36+
Screenshot
37+
38+
39+
Command: buyquantity
40+
This command buys a specific amount of crypto using MARKET order.
41+
Parameters: Must specify the market and amount.
42+
Syntax
43+
python3 v4dydxcli.py <apikeyfile> buyquantity <market> <quantity>
44+
Example
45+
python3 v4dydxcli.py testnet.py buyquantity BTC-USD 0.001
46+
Screenshot
47+
48+
49+
Command: sellquantity
50+
This command sells a specific amount of crypto using MARKET order.
51+
Parameters: Must specify the market and amount.
52+
Syntax
53+
python3 v4dydxcli.py <apikeyfile> sellquantity <market> <quantity>
54+
Example
55+
python3 v4dydxcli.py testnet.py sellquantity ETH-USD 0.01
56+
Screenshot
57+
58+
59+
Command: buyusdc
60+
This command buys a specific USD-amount of crypto using MARKET order.
61+
Parameters: Must specify the market and USD-amount.
62+
Syntax
63+
python3 v4dydxcli.py <apikeyfile> buyusdc <market> <USD-amount>
64+
Example
65+
python3 v4dydxcli.py testnet.py buyusdc SOL-USD 200
66+
Screenshot
67+
68+
69+
Command: sellusdc
70+
This command sells a specific USD-amount of crypto using MARKET order.
71+
Parameters: Must specify the market and USD-amount.
72+
Syntax
73+
python3 v4dydxcli.py <apikeyfile> sellusdc <market> <USD-amount>
74+
Example
75+
python3 v4dydxcli.py testnet.py sellusdc LINK-USD 200
76+
Screenshot
77+
78+
79+
Command: positions
80+
This command shows open positions. If no open positions, it returns nothing. If you have been following the examples so far, we have opened 4 positions and this is displayed below.
81+
Parameters: None.
82+
Syntax
83+
python3 v4dydxcli.py <apikeyfile> positions
84+
Example
85+
python3 v4dydxcli.py testnet.py positions
86+
Screenshot
87+
88+
89+
Command: buyquantitylimit
90+
This command buys a specific amount of crypto using LIMIT order.
91+
Parameters: Must specify the market, quantity, limit-price, and expiration (in seconds).
92+
Syntax
93+
python3 v4dydxcli.py <apikeyfile> buyquantitylimit <market> <quantity> <limitprice> <expiration>
94+
Example
95+
python3 v4dydxcli.py testnet.py buyquantitylimit BTC-USD 0.002 30000 3600
96+
Screenshot
97+
98+
99+
Command: sellquantitylimit
100+
This command sells a specific amount of crypto using LIMIT order.
101+
Parameters: Must specify the market, quantity, limit-price, and expiration (in seconds).
102+
Syntax
103+
python3 v4dydxcli.py <apikeyfile> sellquantitylimit <market> <quantity> <limitprice> <expiration>
104+
Example
105+
python3 v4dydxcli.py testnet.py sellquantitylimit ETH-USD 0.02 4000 3600
106+
Screenshot
107+
108+
109+
Command: getorder
110+
This command gets the data on an order with a specific client-id. Alternatively, you can specify a status to find all orders with that status.
111+
Parameters: Must specify the client-id or a status.
112+
Syntax
113+
python3 v4dydxcli.py <apikeyfile> getorder <clientid or status>
114+
Example
115+
python3 v4dydxcli.py testnet.py getorder 525086946
116+
Screenshot
117+
118+
119+
Example
120+
python3 v4dydxcli.py testnet.py getorder OPEN
121+
Screenshot
122+
123+
124+
Command: getorderid
125+
This command gets the data on an order with a specific order-id.
126+
Parameters: Must specify the order-id.
127+
Syntax
128+
python3 v4dydxcli.py <apikeyfile> getorderid <orderid>
129+
Example
130+
python3 v4dydxcli.py testnet.py getorderid e7474df1-669c-5c06-a331-889d91b0306b
131+
Screenshot
132+
133+
134+
Command: cancelorder
135+
This command cancels an order with a specific client-id. Alternatively, you can specify a status to cancel all orders with that status.
136+
Parameters: Must specify the client-id or a status.
137+
Syntax
138+
python3 v4dydxcli.py <apikeyfile> cancelorder <client-id or status>
139+
Example
140+
python3 v4dydxcli.py testnet.py cancelorder 314604016
141+
142+
Screenshot
143+
144+
145+
Example
146+
python3 v4dydxcli.py testnet.py cancelorder OPEN
147+
Screenshot

0 commit comments

Comments
 (0)