Created
July 28, 2022 13:40
-
-
Save rhettre/114eac7d372fdfebb7262ba79e9f37af to your computer and use it in GitHub Desktop.
FTX Limit Orders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ftx | |
import json | |
YOUR_API_KEY = "" | |
YOUR_API_SECRET = "" | |
#change SYMBOL to 'ETH/USD' for ETH (etc) | |
SYMBOL = 'BTC/USD' | |
#Change USD_AMOUNT to dollar/fiat amount you want to buy/sell | |
USD_AMOUNT = 20 | |
#change ORDER_TYPE to 'sell' for sells or 'buy' for buys | |
ORDER_TYPE = 'buy' | |
def lambda_handler(event, context): | |
client = ftx.FtxClient(api_key=YOUR_API_KEY, api_secret=YOUR_API_SECRET) | |
bid_price = client.get_orderbook(SYMBOL, 1)['bids'][0][0] | |
order_size = round(USD_AMOUNT/bid_price,4) | |
print(f"Bid Price: {bid_price}") | |
print(f"Order Size: {order_size}") | |
client.place_order(SYMBOL, ORDER_TYPE, bid_price, order_size) | |
return { | |
'statusCode': 200, | |
'body': json.dumps('Order sent!') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Buys/sells USD_AMOUNT of SYMBOL (20 USD of BTC in this case). Change symbol variable to ETH/USD (for example) to buy some other cryptocurrency. Needs your FTX US API key and FTX US API secret to run the code.