MCPcopy Create free account
hub / github.com/IrakliXYZ/ARBOT / open_position_limit

Function open_position_limit

controller.py:125–140  ·  view source on GitHub ↗
(exchange, coin, amount, leverage, price)

Source from the content-addressed store, hash-verified

123# Limits
124# Open limit position on FTX
125def open_position_limit(exchange, coin, amount, leverage, price):
126 # Set variables
127 spot_pair = coin + '/USD'
128 futures_pair = coin + '-PERP'
129
130 # Buy on spot
131 try:
132 exchange.create_order(spot_pair, 'limit', 'buy', amount, {'price': price}) # make post only, fill or kill (IOC)
133 except ccxt.ExchangeError as e:
134 print("While trying to limit buy:", e)
135
136 # Short on futures
137 try:
138 exchange.create_order(futures_pair, 'limit', 'sell', amount, {'price': price, 'leverage': leverage}) # make post only, fill or kill (IOC)
139 except ccxt.ExchangeError as e:
140 print("While trying to limit short:", e)
141
142
143# Close limit position on FTX

Callers 1

take_actionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected