def GetContext(): try: settings = LoadSettings() except: print ("Could not load settings, exiting") exit() username = str(settings['username']) api_key = str(settings['key']) api_secret = str(settings['secret']) try: context = mapi.api(username, api_key, api_secret) except: print (context) return context
def main(): print ("======= MarketsBot version %s =======" % version) ParseArguments() try: settings = LoadSettings() except: print ("Could not load settings, exiting") exit() username = str(settings['username']) api_key = str(settings['key']) api_secret = str(settings['secret']) try: context = mapi.api(username, api_key, api_secret) balance = context.balance() print ("========================================") print ("Account : %s" % username) print ("KHS balance : %s" % balance['KHS']['available']) print ("========================================") except: print ("== !! ============================ !! ==") print ("Error:") try: ErrorMessage = balance['error'] except: ErrorMessage = ("Unkown") print(ErrorMessage) print ("") print ("Could not connect Markets.cx, exiting") print ("== !! ============================ !! ==") exit() while True: try: now = time.asctime( time.localtime(time.time()) ) print ("") print ("%s" % now) CancelOrder(context) ##balance = context.balance() KHSBalance = GetBalance(context, 'KHS') print ("KHS balance: %s" % KHSBalance) print ("") print ("") PrintBalance( context, "LTC") ReinvestCoin(context, "LTC", LTCThreshold, "KHS" ) except urllib2.HTTPError, err: print ("HTTPError :%s" % err) except: