Advertisement
Guest User

Untitled

a guest
Jan 13th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. from decimal import *
  2.  
  3. def f(a, b):
  4. from binance.client import Client
  5. #import decimal
  6. getcontext().prec = 8
  7. liczbaA = Decimal(0.8)
  8. liczbaB = Decimal(0.999)
  9. bottomLimitMnoznik = Decimal(0.95)
  10. client = Client(a, b)
  11. amount = Decimal(input("Ilosc: "))
  12. str = input("Coin: ")
  13. str = str + "BTC"
  14. order={'executedQty': '0.1','price': '0.1'}
  15. info = client.get_symbol_info(str)
  16. liczbaC = Decimal(info['filters'][1]['stepSize'])
  17. old = Decimal(client.get_orderbook_ticker(symbol=str)['askPrice'])
  18. amount = amount / old
  19. amount = amount - amount % liczbaC
  20.  
  21. test = True
  22. last = "sell"
  23. while test:
  24. #new = 0
  25. #for i in range(1, 4):
  26. # new += Decimal(client.get_symbol_ticker(symbol=str)['price'])
  27. #new = new / 3
  28. new = Decimal(client.get_symbol_ticker(symbol=str)['price'])
  29. print(new/old)
  30. print(new / old < liczbaB)
  31. print(last == "buy")
  32. if new / old > 1 / liczbaB and last == "sell":
  33. order2 = client.order_market_buy(
  34. symbol=str,
  35. quantity=amount)
  36. print("Buy:")
  37. print(order2)
  38. amount = order2['executedQty']
  39. last = "buy"
  40. #new = 0
  41. #for i in range(1, 4):
  42. # new += Decimal(client.get_symbol_ticker(symbol=str)['price'])
  43. #new = new / 3
  44. old = new
  45. if new / old < liczbaB and last == "buy":
  46. order2 = client.order_market_sell(
  47. symbol=str,
  48. quantity=amount)
  49. print("Sell")
  50. print(order2)
  51. amount = order2['executedQty']
  52. last = "sell"
  53. old = new
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement