1919 - same flow as ` create_modify_cancel_order_http.py `
2020 - sends TXs over WS instead of HTTP
2121
22+ - ` create_market_order_eth_buy.py `
23+ - creates a market buy order for 0.1 ETH @ market price
24+ - ` create_market_order_eth_sell.py `
25+ - creates a market sell order for 0.1 ETH @ market price
26+
2227- ` create_grouped_ioc_with_attached_sl_tp.py `
2328 - creates an ask (sell) IoC order for 0.1 ETH
2429 - along w/ the order, it sets up a Stop Loss (SL) and a Take Profit (TP) order for the whole size of the order
3136 - the orders will grow / shrink as you accumulate more position
3237 - the SL/TP orders are canceled when the sign of your position changes
3338
34- ### On SL/TP orders
39+ ## On SL/TP orders
3540SL/TP orders need to be configured beyond just setting the trigger price. When the trigger price is set,
3641the order will just be executed, like a normal order. This means that a market order, for example, might not have enough slippage! \
3742Let's say that you have a 1 BTC long position, and the current price is $110'000. \
@@ -43,7 +48,7 @@ What about the order types? Just as normal orders, SL/TP orders trigger an order
4348- market order
4449- limit IOC / GTC
4550
46- ### Modify leverage / Margin Mode (Cross, Isolated) / Add Collateral to isolated-only positions
51+ ## Modify leverage / Margin Mode (Cross, Isolated) / Add Collateral to isolated-only positions
4752- ` margin_eth_20x_cross_http `
4853 - sets ETH market to 20x leverage and cross-margin mode, using HTTP
4954- ` margin_eth_50x_isolate_ws `
@@ -53,14 +58,51 @@ What about the order types? Just as normal orders, SL/TP orders trigger an order
5358- ` margin_eth_remove_collateral_ws.py `
5459 - removes $5 USDC from the ETH position (must be opened and in isolated mode)
5560
56- ### Batch orders
61+ ## Batch orders
5762- ` send_batch_tx_http.py `
5863 - sends multiple orders in a single HTTP request
5964- ` send_batch_tx_ws.py `
6065 - sends multiple orders in a single WS request`
6166
6267Batch TXs will be executed back to back, without the possibility of other TXs interfering.
6368
69+ ## Spot Trading
70+ To trade spot markets, you need to have spot USDC. USDC used in your perpetual account will be used as collateral for your cross-positions.
71+ USDC deposited in the spot account can only be used to buy spot assets.
72+ To transfer USDC between spot <> perp balance, or vice verse, check out
73+ - ` spot_self_transfer_perp_spot.py `
74+ - ` spot_self_transfer_spot_perp.py `
75+
76+ Order placement / trades work in the same way as for perpetual markets.
77+ The fee will be paid in the received asset for premium spot trades.
78+ This means that if you sell ETH, you'll receive less USDC, and if you BUY 1 ETH, you'll receive slightly less than 1 ETH.
79+ You can check out the following examples, which should work on spot ETH by changing the market index to 2048 instead of 0.
80+ - ` create_modify_cancel_order_http.py `
81+ - ` create_modify_cancel_order_ws.py `
82+ - ` create_market_order_eth_buy.py `
83+ - ` create_market_order_eth_sell.py `
84+ - ` send_batch_tx_http.py `
85+ - ` send_batch_tx_ws.py `
86+
87+ Trading setup is very similar to perpetual markets.
88+ The only difference is that you'll need to hold USDC / ETH before placing an order.
89+ For example, on perp markets you can place an order to short (sell) ETH without having to worry that much.
90+ The limitation there would be to have enough available collateral to cover the order.
91+ On spot orders, you need to have enough assets in your spot account to cover all open orders.
92+ If you want to place two orders, to buy 1000 USDC worth of ETH and 1000 USDC worth of ZK, you'll need to have at least 2000 available USDC.
93+
94+ You can get the order book details (including symbol and market index) as well as quote asset id (ETH) and base asset id (USDC)
95+ by following the example below:
96+ - ` spot_get_order_books.py `
97+
98+ Note: you'll need the quote asset id and base asset id to check available balance.
99+ Available balance is not locked in open orders.
100+
101+ To keep track of your spot balance, you can use HTTP calls or a websocket subscription.
102+ Examples on how to do this can be found here:
103+ - ` spot_get_account_assets_http.py `
104+ - ` spot_get_account_assets_ws.py `
105+
64106## Setup steps for mainnet
65107- deposit money on Lighter to create an account first
66108- change the URL to ` mainnet.zklighter.elliot.ai `
0 commit comments