| 123 | # Limits |
| 124 | # Open limit position on FTX |
| 125 | def 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 |