Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- entrySpread = 2.05
- exitSpread = -1.68
- lotSize = 0.2
- ###############################################
- ##########################################################
- ######################################################
- bitFinexAccount = BitFinexAccount(bitFinexCore)
- BitFinexHistoricalData = BitFinexHistoricalData(bitFinexCore)
- PublicEndpoints = bitfinex_client.PublicEndpoints()
- bitFinexOrders = bitfinex_client.BitFinexOrders(bitFinexCore)
- #print publicClient.getProductOrderBook(level=2)
- finexTicker = PublicEndpoints.tickers('tLTCUSD')
- bitfinexBid = float(finexTicker['BID'])
- bitfinexAsk = float(finexTicker['ASK'])
- #print authClient.getAccounts()
- #print publicClient.getProductOrderBook(level=2)['asks']
- def GDAXbidDepth(x):
- depth =0
- GDAXbidBook = publicClient.getProductOrderBook(level=2)['bids']
- for orders in GDAXbidBook:
- if float(orders[0]) > float(x):
- depth = float(orders[1]) + float(depth)
- #print "bid", orders[1]
- #print depth
- print depth
- return depth
- def GDAXaskDepth(x):
- depth = 0
- GDAXaskBook = publicClient.getProductOrderBook(level=2)['asks']
- for orders in GDAXaskBook:
- if float(orders[0]) < float(x):
- depth = float(orders[1]) + float(depth)
- #print "ask", orders[1]
- #print depth
- print depth
- return depth
- def BFXbidDepth(x):
- depth =0
- BFXbids = PublicEndpoints.books("LTCUSD")['bids']
- for orders in BFXbids:
- if float(orders['price']) > float(x):
- depth = float(orders['amount']) + float(depth)
- #print "bid", orders[1]
- #print depth
- print depth
- return depth
- def BFXaskDepth(x):
- depth = 0
- BFXasks = PublicEndpoints.books("LTCUSD")['asks']
- for orders in BFXasks:
- if float(orders['price']) < float(x):
- depth = float(orders['amount']) + float(depth)
- #print "ask", orders[1]
- #print depth
- print depth
- return depth
- def BFXfindBid(x):
- depth =0
- global BFXleanBid
- BFXbids = PublicEndpoints.books("LTCUSD")['bids']
- for orders in BFXbids:
- if depth < float(x):
- depth = float(orders['amount']) + float(depth)
- BFXleanBid = orders['price']
- #print "bid", orders[1]
- #print depth
- #print BFXleanBid
- #print depth
- return float(BFXleanBid)
- def BFXfindAsk(x):
- depth =0
- global BFXleanAsk
- BFXbids = PublicEndpoints.books("LTCUSD")['asks']
- for orders in BFXbids:
- if depth < float(x):
- depth = float(orders['amount']) + float(depth)
- BFXleanAsk = orders['price']
- #print "bid", orders[1]
- #print depth
- #print BFXleanAsk
- #print depth
- return float(BFXleanAsk)
- def GDAXfindBid(x):
- depth =0
- global GDAXleanBid
- GDAXbidBook = publicClient.getProductOrderBook(level=2)['bids']
- for orders in GDAXbidBook:
- if depth < float(x):
- depth = float(orders[1]) + float(depth)
- GDAXleanBid = orders[0]
- #print "bid", orders[1]
- #print depth
- #print BFXleanBid
- #print depth
- return float(GDAXleanBid)
- def GDAXfindAsk(x):
- depth =0
- global GDAXleanAsk
- GDAXaskBook = publicClient.getProductOrderBook(level=2)['asks']
- for orders in GDAXaskBook:
- if depth < float(x):
- depth = float(orders[1]) + float(depth)
- GDAXleanAsk = orders[0]
- #print "bid", orders[1]
- #print depth
- #print BFXleanBid
- #print depth
- return float(GDAXleanAsk)
- print GDAXfindBid(500)
- print GDAXfindAsk(500)
- print BFXfindBid(500)
- print BFXfindAsk(500)
- GDAXusd = authClient.getAccount("56ad7ec2-d1d8-4864-bd33-17a93df99001")['available']
- GDAXltc = authClient.getAccount("671c3517-deb8-48f8-b3a4-21eadf2ae403")['available']
- BFXltc = bitFinexAccount.wallet_balance()[9]['available'] #available btc balance
- BFXusd = bitFinexAccount.wallet_balance()[10]['available']#available usd balance
- spreads = 35
- while True:
- try:
- print BFXusd, BFXltc, GDAXusd, GDAXltc
- time.sleep(3)
- BFXgetBid = float(BFXfindBid(10))
- BFXgetAsk = float(BFXfindAsk(10))
- GDAXgetBid= float(GDAXfindBid(10))
- GDAXgetAsk = float(GDAXfindAsk(10))
- print (float(GDAXgetBid) - float(BFXgetAsk))
- print (float(BFXgetBid) - float(GDAXgetAsk))
- if float(GDAXgetBid) - float(BFXgetAsk) > float(entrySpread) and float(GDAXltc) > float(1) and float(BFXusd) > float(BFXgetAsk):
- sellParams = {
- 'price': "%.2f"%float(GDAXfindBid(100)), #USD
- 'size': str(lotSize), #BTC
- "product_id": "LTC-USD",
- "time_in_force": "GTT",
- "cancel_after" : 'min',
- #product_id not needed if default is desired
- }
- print authClient.sell(sellParams)
- print bitFinexOrders.new_order("LTCUSD", str(lotSize), '0.01', "buy", 'exchange market', 'bitfinex', False, True, 0, False, False)
- spreads = spreads + 1
- print "buy, Buy buy buy buy"
- print "buy, Buy buy buy buy"
- print "buy, Buy buy buy buy"
- print "buy, Buy buy buy buy"
- print "buy, Buy buy buy buy"
- print "buy, Buy buy buy buy"
- print "buy, Buy buy buy buy"
- print "buy, Buy buy buy buy"
- print "buy, Buy buy buy buy"
- print "buy, Buy buy buy buy"
- GDAXusd = authClient.getAccount("56ad7ec2-d1d8-4864-bd33-17a93df99001")['available']
- GDAXltc = authClient.getAccount("671c3517-deb8-48f8-b3a4-21eadf2ae403")['available']
- BFXltc = bitFinexAccount.wallet_balance()[9]['available'] #available btc balance
- BFXusd = bitFinexAccount.wallet_balance()[10]['available']#available usd balance
- if spreads > 0 and float(BFXgetBid) - float(GDAXgetAsk) > float(exitSpread) and float(BFXltc) > float(1) and float(GDAXusd) > float(GDAXgetAsk):
- buyParams = {
- 'price': "%.2f"%float(GDAXfindAsk(100)), #USD
- 'size': str(lotSize), #BTC
- "product_id": "LTC-USD",
- "time_in_force": "GTT",
- "cancel_after" : 'min',
- #product_id not needed if default is desired
- }
- print authClient.buy(buyParams)
- print bitFinexOrders.new_order("LTCUSD", str(lotSize), '0.01', "sell", 'exchange market', 'bitfinex', False, True, 0, False, False)
- print GDAXltc, BFXusd
- spreads = spreads -1
- print "SELL, SELL, SELL"
- print "SELL, SELL, SELL"
- print "SELL, SELL, SELL"
- print "SELL, SELL, SELL"
- print "SELL, SELL, SELL"
- print "SELL, SELL, SELL"
- print "SELL, SELL, SELL"
- print "SELL, SELL, SELL"
- print "SELL, SELL, SELL"
- GDAXusd = authClient.getAccount("56ad7ec2-d1d8-4864-bd33-17a93df99001")['available']
- GDAXltc = authClient.getAccount("671c3517-deb8-48f8-b3a4-21eadf2ae403")['available']
- BFXltc = bitFinexAccount.wallet_balance()[9]['available'] #available btc balance
- BFXusd = bitFinexAccount.wallet_balance()[10]['available']#available usd balance
- except:
- print "error"
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement