Advertisement
hackbyte

stuff.......

Dec 12th, 2018
632
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.71 KB | None | 0 0
  1. #!/usr/bin/env python3.6
  2. # -*- coding: utf-8 -*-
  3. import os, sys, inspect
  4.  
  5. scriptpath  = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
  6.  
  7. scriptname  = os.path.basename(inspect.getfile(inspect.currentframe()))
  8.  
  9. ################################################################################
  10. from pudb import set_trace #; set_trace()
  11. ################################################################################
  12. import shutil, time, datetime, locale, logging, logging.handlers, argparse
  13. ################################################################################
  14. log = logging.getLogger()
  15. log.setLevel(logging.INFO)
  16. logformatter_main = logging.Formatter(
  17.     '%(asctime)s.%(msecs)03d ' +
  18.     '%(levelname)-8s ' + '%(filename)-16s ' +
  19.     '%(funcName)-12s ' + '%(lineno)04d ' +
  20.     '%(message)s',
  21.     '%Y%m%d%H%M%S')
  22. logformatter_syslog = logging.Formatter(
  23.     '%(levelname)-8s ' +
  24.     '%(filename)-16s ' + '%(funcName)-12s ' +
  25.     '%(lineno)04d ' + '%(message)s')
  26. logcons = logging.StreamHandler()
  27. logcons.setLevel(logging.DEBUG)
  28. logcons.setFormatter(logformatter_main)
  29. log.addHandler(logcons)
  30.  
  31. #logfile = logging.FileHandler(scriptpath+'/'+scriptname+'.log')
  32. #logfile.setLevel(logging.DEBUG)
  33. #logfile.setFormatter(logformatter_main)
  34. #log.addHandler(logfile)
  35.  
  36. #logsys = logging.handlers.SysLogHandler(address = '/dev/log')
  37. #logsys.setLevel(logging.INFO)
  38. #logsys.setFormatter(logformatter_syslog)
  39. #log.addHandler(logsys)
  40.  
  41. ################################################################################
  42.  
  43.  
  44.  
  45. parser = argparse.ArgumentParser(description=scriptname + ' commandline parameters.')
  46. parser.add_argument(
  47.     "-d", "--debug", dest="debug",
  48.     action="store_true", default=False,
  49.     help="show heavy masses(!!) of debug output.")
  50. parser.add_argument(
  51.     "-t", "--test", dest="test",
  52.     action="store_true", default=False,
  53.     help="for testing environment")
  54. cmdline = parser.parse_args()
  55.  
  56. ################################################################################
  57. if cmdline.debug:
  58.     log.setLevel(logging.DEBUG)
  59.  
  60. ################################################################################
  61. log.debug("python version "        + str(sys.version).replace('\n', ''))
  62. log.debug(scriptname+" START "     + '{:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now()))
  63. log.debug("cmdline.debug = "       + str(cmdline.debug))
  64. log.debug("cmdline.test = "        + str(cmdline.test))
  65. ################################################################################
  66.  
  67. # your space here
  68.  
  69. ################################################################################
  70. # exchanges
  71.  
  72. ################################################################################
  73. #  binance
  74. ################################################################################
  75. def show_portfolio_binance(binance_api_key, binance_secret_key):
  76. #    set_trace()
  77.  
  78.     from binance.client import BinanceRESTAPI, BinanceWebSocketAPI
  79.  
  80.     rest_client = BinanceRESTAPI(binance_api_key, binance_secret_key)
  81.     rest_client.server_time().server_time
  82.     account = rest_client.account()
  83.  
  84.     ws_client = BinanceWebSocketAPI(binance_api_key)
  85.    
  86.     # balance information
  87.     for balance in account.balances:
  88.         free = float(balance.free)
  89.         locked = float(balance.locked)
  90.         if (free+locked) > 0:
  91.             print("%-8s %-20s %-020s = %-20f" % (balance.asset, balance.free, balance.locked,(free+locked)))
  92. #            print(balance.asset, balance.free, balance.locked)
  93. #            set_trace()
  94.  
  95. ################################################################################
  96. binance_api_key="192387456192834792183476019324"
  97. binance_secret_key="aklsdfhlaksfdhvakbx"
  98. show_portfolio_binance(binance_api_key,binance_secret_key)
  99.  
  100. ################################################################################
  101. #  bitcoin.de
  102. ################################################################################
  103.  
  104. ################################################################################
  105. #  bitfinex
  106. ################################################################################
  107. ################################################################################
  108. #  bitstamp
  109. ################################################################################
  110. ################################################################################
  111. #  bittrex
  112. ################################################################################
  113. ################################################################################
  114. #  bleutrade
  115. ################################################################################
  116. ################################################################################
  117. #  coinbase pro
  118. ################################################################################
  119. ################################################################################
  120. #  hitbtc
  121. ################################################################################
  122. ################################################################################
  123. #  huobipro
  124. ################################################################################
  125. ################################################################################
  126. #  kraken
  127. ################################################################################
  128. ################################################################################
  129. #  okkcoin
  130. ################################################################################
  131. ################################################################################
  132. #  poloniex
  133. ################################################################################
  134.  
  135.  
  136.  
  137. log.debug("program end...")
  138. sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement