This script demonstrates how to implement an auto lender that could programmatically update offered size in a subaccount for all coins. It also bound to a google sheet and could update lending history, total proceeds automatically.
This script implement a strategy to get best offer from favorite coin list and try to accumulate as much interest as possible. It also records convertion history in a google sheet for later reviewing if this strategy works well.
- In FTX website, go to Profile -> Api to "CREATE API KEY" for your account. You could get YOUR_FTX_API_KEY and YOUR_FTX_SECRET here.
- Create subaccount in your wallet with YOUR_SUBACCOUNT_NAME, e.g. AutoLend.
- Create a google sheet and add 4 sheets named them to "Dashboard", "History", "Convert History" and "Configuration" repectively.
- In google spreadsheet, go to Tool -> Script Editor, copy all scripts to the script project.
- Add a hourly trigger to execute one of below functions. Please don't run these 2 functions together.
- updateMaxOffering()
- convertToBestOffer()
- Add a hourly trigger to execute updateNewLendingHistory() function.
Replace below variables in configuration.gs.
FTX_API_KEY = 'YOUR_FTX_API_KEY';
FTX_SECRET = 'YOUR_FTX_SECRET';
FTX_SUBACCOUNT = 'YOUR_SUBACCOUNT_NAME';
MINIMUM_SIZE = 0.1;
UPDATE_OFFERING = 1;
MINIMUM_RATE = 0.049;
FAVORITE_COINS = ["BCH", "ETH", "BNB", "USDT"];
BUY_SIZE_FOR_BCH = 50;
Configuration sheet:
- B2 = BCH_THRESHOLD
- B3 = MINIMUM_SIZE
- B4 = UPDATE_OFFERING
- When BCH price drop below BCH_THRESHOLD, it will convert available balance of USDT to BCH. If you don't want this feature, simply change BCH_THRESHOLD to 0 to disable it. It will decrease BCH_THRESHOLD by 50 USDT evertime it bought the dip. You could manually adjust BCH_THRESHOLD in google sheet to adjust threshold.
- Set MINUMUM_SIZE to avoid buying size too small issue.
- Set UPDATE_OFFERING = 0 will stop updateMaxOffering() even the trigger is still on.