MCPcopy Create free account
hub / github.com/ccxt/ccxt / example_4

Function example_4

examples/py/bybit-updated.py:131–162  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

129
130# Example 4 :: Future : fetch balance, create stop-order and check open stop-orders
131async def example_4():
132 exchange.options['defaultType'] = 'future'; # very important set future as default type
133 markets = await exchange.load_markets(True)
134
135 # fetch future balance
136 balance = await exchange.fetch_balance()
137 print(balance)
138
139 # create stop-order
140 symbol = 'ETH/USD:ETH-220930'
141 amount = 10 # in USD for inverse futures
142 price = 1200
143 side = 'buy'
144 type = 'limit'
145 stop_order_params = {
146 'position_idx': 0, # 0 One-Way Mode, 1 Buy-side, 2 Sell-side, default = 0
147 'stopPrice': 1000, # mandatory for stop orders
148 'basePrice': 1100 # mandatory for stop orders
149 }
150 stop_order = await exchange.create_order(symbol, type, side, amount, price, stop_order_params)
151 print('Create order id:', stop_order['id'])
152
153 # check opened stop-order
154 open_order_params = {
155 'stop': True
156 }
157 openOrders = await exchange.fetch_open_orders(symbol, None, None, open_order_params)
158 print(openOrders)
159
160 # cancell all open stop-orders
161 cancelOrder = await exchange.cancel_all_orders(symbol, open_order_params)
162 print(cancelOrder)
163
164# -------------------------------------------------------------------------------------------
165

Callers 1

mainFunction · 0.85

Calls 5

load_marketsMethod · 0.45
fetch_balanceMethod · 0.45
create_orderMethod · 0.45
fetch_open_ordersMethod · 0.45
cancel_all_ordersMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…