Last active
November 2, 2021 16:09
-
-
Save JTraversa/fd1c3d4d14e1c73bf74f1e12b336f7e0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from time import sleep | |
from sys import exit | |
import time | |
import datetime | |
import math | |
import swivel-py | |
def truncate(number, digits) -> float: | |
stepper = 10.0 ** digits | |
return math.trunc(stepper * number) / stepper | |
def fetchPrice(underlying, maturity) -> float: | |
url = "https://api-dev.swivel.exchange/v2/fills?underlying=" + underlying + "&maturity=" + maturity + "&depth=" + "1" | |
response = requests.get(url= url) | |
r = response.json() | |
price = r[0]['price'] | |
return price | |
def limitOrder(underlying, maturity, exit, vault, price, amount, expiry): | |
signedOrder = swivel.vendor.... | |
url = "x" | |
params = "y" | |
r = requests.post(url = url, params = y data = signedOrder) | |
def simplestMarketMake(underlying, maturity, range, amount, expiryLength): | |
price = fetchPrice(underlying, maturity) | |
upperBound = price + (price*(range/100)) | |
lowerBound = price - (price*(range/100)) | |
safeAmount = amount * .95 | |
lowerAmount = truncate((safeAmount / 2), 4) | |
upperAmount = truncate((safeAmount / 2), 4) | |
expiry = datetime.datetime.now() + expiryLength | |
#what unit is this in again | |
limitOrder(underlying, maturity, true, false, lowerBound, lowerAmount, expiry) | |
limitOrder(underlying, maturity, true, true, upperBound, upperAmount, expiry) | |
underlying = input('what is the underlying token: ') | |
maturity = input('what is the market\'s maturity: ') | |
amount = input('how many zcTokens and nTokens do you want to use') | |
orderRange = input('how far from market price do you want to quote (in %): ') | |
expiryLength = input('how often should orders refresh: ') | |
PRIVATE_KEY = input('what is your private key') #or env | |
PROVIDER_KEY = input('what is your Infura or other provider key: ') | |
swivel = swivel-py(PRIVATE_KEY, PROVIDER_KEY) | |
loop = true | |
while loop = true: | |
simplestMarketMake(underlying, maturity, orderRange, amount, expiryLength) | |
time.sleep(expiryLength) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment