Esempio n. 1
0
 def __register_account(strategy_id):
     manager = AccountManager()
     randomid = str(uuid.uuid4())
     account_id = "test" + randomid[:6]
     manager.register_new_account(account_id, "ToneyTesting", 500000,
                                  strategy_id)
     return account_id
Esempio n. 2
0
    def update_account_test():
        print("Staring update_account_test.")
        account_id = BVTTests.__register_account("EightImmortals_Classic")

        manager = AccountManager()
        account = manager.get_account_data(account_id)
        account.change_strategy("EightImmortals_Nine")
        account.save_to_file()

        BVTTests.__decommission_account(account_id)
        print("Passed.")
Esempio n. 3
0
    def __strategy_test(strategy_id):
        account_id = BVTTests.__register_account(strategy_id)

        manager = AccountManager()
        account = manager.get_account_data(account_id)
        transactions, portfolio, portfolio_percentage = account.make_decision()
        if (transactions != None):
            print(
                "New transactions count:{}. Portfolio:[{} Cash={}]. Percentage:{}"
                .format(len(transactions), portfolio.get_coin_positions(),
                        portfolio.get_cash_balance(), portfolio_percentage))
        else:
            print("Empty transactions. Portfolio:[{} Cash={}]. Percentage:{}".
                  format(portfolio.get_coin_positions(),
                         portfolio.get_cash_balance(), portfolio_percentage))

        BVTTests.__decommission_account(account_id)
Esempio n. 4
0
    def account_make_decision_test():
        print("Staring account_make_decision_test.")
        account_id = BVTTests.__register_account("EightImmortals_Classic")

        manager = AccountManager()
        account = manager.get_account_data(account_id)
        transactions, portfolio, portfolio_percentage = account.make_decision()
        if (transactions != None):
            print(
                "New transactions count:{}. Portfolio:[{} Cash={}]. Percentage:{}"
                .format(len(transactions), portfolio.get_coin_positions(),
                        portfolio.get_cash_balance(), portfolio_percentage))
        else:
            print("Empty transactions. Portfolio:[{} Cash={}]. Percentage:{}".
                  format(portfolio.get_coin_positions(),
                         portfolio.get_cash_balance(), portfolio_percentage))

        BVTTests.__decommission_account(account_id)
        print("Passed.")
Esempio n. 5
0
 def _initvars(self):
     YobotServiceBase._initvars(self)
     #should eventually be something that lets us hook up with libpurple
     self.prpl_server = PurpleQueue()
     #clients[cid] = <YobotServer>
     self.clients = {}
     self.requests = {} # requests[reqid] -> client_object
     self.accounts = AccountManager()
     self.logger = MessageLogger()
     self._purple_initvars()
Esempio n. 6
0
def trigger_all_strategies():

    manager = AccountManager()
    #user_eight_classic
    #user_eight_nine
    #user_wheeling_btceth
    #user_wheeling_btcusdt
    #user_wheeling_btcusdtltcxrpzec
    #user_gridding_btc
    #user_gridding_btceth
    #user_gridding_btcethltcxrpzec

    stras = {}
    stras["user_eight_classic"] = 532
    stras["user_eight_nine"] = 533
    stras["user_wheeling_btceth"] = 534
    stras["user_wheeling_btcusdt"] = 535
    stras["user_wheeling_btcusdtltcxrpzec"] = 536
    stras["user_gridding_btc"] = 537
    stras["user_gridding_btceth"] = 538
    stras["user_gridding_btcethltcxrpzec"] = 539
    #manager.register_new_account(account_id, "ccscreener_stras", 500000, "EightImmortals_Classic")

    for k in stras:
        stra_id = stras[k]
        print("## ", stra_id)
        account = manager.get_account_data(k)
        _, portfolio, portfolio_percentage = account.make_decision()
        print("## ", portfolio_percentage)
        tmp = portfolio_percentage
        for k in tmp:
            tmp[k] = tmp[k] * 100
        if (portfolio != None):
            args = {}
            args["id"] = stra_id
            args["detail"] = tmp
            try:
                requests.post(url, json=args)
            except:
                traceback.print_exc()
Esempio n. 7
0
class YobotServerService(YobotServiceBase):
    def _initvars(self):
        YobotServiceBase._initvars(self)
        #should eventually be something that lets us hook up with libpurple
        self.prpl_server = PurpleQueue()
        #clients[cid] = <YobotServer>
        self.clients = {}
        self.requests = {} # requests[reqid] -> client_object
        self.accounts = AccountManager()
        self.logger = MessageLogger()
        self._purple_initvars()
        
    def __init__(self):
        self._initvars()
        def logTimer():
            self.logger.commit()
            reactor.callLater(45, logTimer)
        reactor.callLater(45, logTimer)
    """
    Common data available to all instances and services.
    What this actually means is that the IPC connection to libpurple as
    well as the individual clients connected to our server will be able to
    use a single pool of data defined here
    """
    
    def logHelper(self, obj):
        msg = obj.msg
        who, txt = (msg.who, msg.txt)
        txt = txt if txt else ""
        who = who if who else msg.name
        
        msgtype = None
        if msg.commflags &  yobotproto.YOBOT_MSG_TYPE_CHAT:
            msgtype = CONV_TYPE_CHAT
        elif msg.commflags & yobotproto.YOBOT_MSG_TYPE_IM:
            msgtype = CONV_TYPE_IM
        if not msgtype:
            return #system message, don't need to log it...
        
        #get account info:
        #FIXME: hack.. might want to see what purple does with its usersplit thingy
        acct, _ = self.accounts.byId(msg.acctid)
        if acct.improto == yobotproto.YOBOT_JABBER:
            name = msg.name.split("/", 1)[0]
        else:
            name = msg.name
        
        try:
            self.logger.logMsg(msgtype, acct.user, yobotops.imprototostr(acct.improto),
                               name, msg.txt, who, msg.time)
        except msglogger.IntegrityError, e:
            log_err(e)
Esempio n. 8
0
 def __init__(self):
     self.account_mgr = AccountManager()
     self.board = Board()
     self.task_mgr = TaskManager()
     self.pixels = []
Esempio n. 9
0
def account_loop(client):
    AM = AccountManager()
    while True:
        print(f"\nCurrently logged user: {client.login}")
        choice = input("-- [L]ist accounts, "
                       "[C]reate new account, "
                       "[A]rchive or [D]earchive existing account, "
                       "Logout[x]: ")

        if choice.lower().strip() not in ACCOUNT_CHOICES:
            print(f"I do not recognize '{choice}' command.")

        elif choice.lower().strip() == ACCOUNT_CHOICES[0]:
            client.account_list()

        elif choice.lower().strip() == ACCOUNT_CHOICES[1]:
            ac = Account(client.login, AM)
            print(
                f"Successfully created new {ac.mode} with ID '{ac.account_id}'."
            )
            client.append_created_account(ac.account_id)
            if AM.ensure_client_existence(client.login):
                AM.save_account(client.login, ac)

        elif choice.lower().strip() == ACCOUNT_CHOICES[2]:
            client.account_list()
            w = int(
                input("Which of the following accounts you want to archive? ")
            ) - 1
            AM.archive(client.login, w)

        elif choice.lower().strip() == ACCOUNT_CHOICES[3]:
            client.account_list()
            w = int(
                input("Which of the following accounts you want to dearchive? "
                      )) - 1
            AM.dearchive(client, w)

        elif choice.lower().strip() == ACCOUNT_CHOICES[4]:
            print(f"\n'{client.login}' has log out\n")
            break

        AM.save_file()