예제 #1
0
 def setUp(self):
     '''
     Set up method to run before each test cases.
     '''
     self.new_account = Account("polla", "123")  # create account object
예제 #2
0
파일: tester.py 프로젝트: ivanbb/tester
        bal.append([
            objects.market.account.account_info('ACCOUNT_BALANCE'),
            objects.market.account.account_info('ACCOUNT_EQUITY')
        ])

        bot.on_tick()
        objects.market.account.calc()
        objects.market.open_position()

    plt.plot(bal)
    plt.show()


if __name__ == '__main__':
    """Tester starting from command line with parameters start datetime, 
    end datetime, time frame, initial balance, leverage, symbol"""
    # init(sys.argv)  # initialise tester

    account = Account(objects.balance, objects.currency,
                      objects.leverage)  # создаем аккаунт
    for sym in objects.symbols_list:
        objects.symbols[sym[0]] = Symbol(sym[0], sym[1], sym[2], sym[3],
                                         sym[4], sym[5], sym[6],
                                         sym[7])  # создаем символы
        objects.candles[sym[0]] = SymbolPrices(sym[0])  # создаем символы
    objects.market = Market(objects.start, account, objects.symbols,
                            objects.candles)
    objects.market.set_price()
    bot.init()
    run()
예제 #3
0
def create_account(fname, lname, phone, email, username, password):
    '''
    Function to create a new account
    '''
    new_account = Account(fname, lname, phone, email, username, password)
    return new_account
예제 #4
0
#!/usr/local/bin/python

from account import Account
from savingsaccount import SavingsAccount

account1 = Account(1000.00)
account1.deposit(550.23)
print(account1.getbalance())

another = SavingsAccount(0, 3)

print('objects:', Account.numCreated)
print("object another is class", another.__class__.__name__)
예제 #5
0
def create_account(account_name, account_userName, account_password):
    new_account = Account(account_name, account_userName, account_password)
    return new_account
예제 #6
0
파일: main.py 프로젝트: Den2is/POO
from car import Car
from account import Account

if __name__ == "__main__":
    print("Hola mundo")

    car = Car("AMD322", Account("Marco Aurelio", "BNE433"))
    print(vars(car))
    print(vars(car.driver))
예제 #7
0
import sys
import csv
from account import Account

if __name__ == "__main__":

    if len(sys.argv) < 3:
        print("ERROR: missing arguments")
        exit()

    with open(sys.argv[1]) as csv_savings:
        savings_reader = csv.reader(csv_savings, delimiter=',')
        accounts = dict(
            (int(x[0]), Account(int(x[0]), int(x[1]))) for x in savings_reader)

    with open(sys.argv[2]) as csv_transactions:
        transactions_reader = csv.reader(csv_transactions, delimiter=',')
        for transaction in transactions_reader:
            value = int(transaction[1])
            account = accounts.get(int(transaction[0]))
            if account is not None:
                if value < 0:
                    account.withdraw(value * -1)
                else:
                    account.deposit(value)
            else:
                print("ERROR: inexistent account [" + transaction[0] + "]")

    for keys, account in accounts.items():
        print(account.id, account.balance)
예제 #8
0
# importar clase car
from car import Car
from account import Account

if __name__ == "__main__":
    print("Hola Mundo")
    # declarando metodos
    car = Car("AMS234", Account("Andres Herrera", "ANDA876"))
    print(vars(car))
    print(vars(car.driver))
    # car = Car()
    # car.license = "AMS234"
    # car.driver = "Andres Herrera"
    # # no necesita metodo como java solo pasando el objeto como parametro
    # print(vars(car))

    # car2 = Car()
    # car2.license = "QWE567"
    # car2.driver = "Matha"
    # print(vars(car2))
예제 #9
0
 def test_magic_method_not_eq(self):
     acc = Account("Pesho", 30)
     self.assertTrue(acc != self.a)
     self.assertFalse(self.a != self.a)
     self.assertNotEqual(acc, self.a)
예제 #10
0
from car import Car  #importando clase del archivo
from account import Account
from UberX import UberX
from Driver import Driver

if __name__ == "__main__":
    print("Hola todos")
    car = Car("AMS234", Account("Andres Herrera",
                                "AND1234"))  #Creando instancia de la clase
    """ car.license = "AMS234"
    car.driver = "Andres Herrera" """
    car.passengers = 4
    # print(vars(car))
    # print(vars(car.driver))
    car.printDataCar()
    """ car2 = Car("QWE564", Account("Andrea Herrera", "ANDA876"))
    car2.license = "QWE564"
    car2.driver = "Andrea Herrera"
    car2.passengers = 3
    print(vars(car2))
    print(vars(car2.driver)) """

    uberX1 = UberX("UBN342", Account("Miguel Khan", "MKN321"), "Chevrolet",
                   "Spark")
    uberX1.printDataCar()

    conductor = Driver("Juan Salgado", "JUAN841")
    conductor.printUserData()
예제 #11
0
def create_account(account_name, user_name, password, email):
    '''
    Function to create a new account
    '''
    new_account = Account(account_name, user_name, password, email)
    return new_account
예제 #12
0
from account import Account
from bank_db_mysql import create_account, list_accounts, get_account, update_account, delete_account, AccountNotFound, \
    init_db, transfer_money
from money import Monetary

a1 = Account("Jan", "Kowalski", "ul. Kasztanowa 12, 31-092 Kraków",
             "1234-1234-1234-1234")
a2 = Account("Adam", "Kowalski", "ul. Opolska 100, 31-201 Kraków",
             "1234-5678-9012-3456")

init_db()
create_account(a1)
create_account(a2)
print(list_accounts())

print(get_account("1234-1234-1234-1234"))

a1.owner_last_name = "Nowak"
a1.balance.amount = 11.00
update_account(a1)
print(get_account("1234-1234-1234-1234"))

# test transfer
transfer_money(a1, a2, Monetary(1, "PLN"))
assert a1.balance.amount == 10.00
assert a2.balance.amount == 1.00

delete_account(a1.ban)
delete_account(a2.ban)
try:
    print(get_account("1234-1234-1234-1234"))
예제 #13
0
    return "{:>3}. {:20} {:65} {:8.2f} {:8.2f} {:8.2f} {:8.2f}/day".format(
        i, a.get_name(), bar_str, reached_total / 100, budget_total / 100,
        remain_total / 100, ideal_pace / 100)


# Testing
if __name__ == "__main__":
    from account import Budget
    t0 = Transaction(2015, 0, 12, "Fast Food", "Cash", "In-n-Out", 100)
    t1 = Transaction(2015, 1, 24, "Fast Food", "Cash", 'McDonald\'s', 200)
    t2 = Transaction(2015, 2, 24, "Fast Food", "Debit", "McDonald's", 300)
    t3 = Transaction(2015, 3, 24, "Fast Food", "Cash", "Wendy's", 400)
    t4 = Transaction(2015, 4, 23, "Fast Food", "Gifts", "Wendy's", 500)
    t5 = Transaction(2015, 5, 22, "Fast Food", "Savings", "Coffee", 600)
    t6 = Transaction(2015, 6, 12, "Fast Food", "Cash", "In-n-Out", 700)
    t7 = Transaction(2015, 7, 24, "Fast Food", "Cash", 'McDonald\'s', 800)
    t8 = Transaction(2015, 8, 24, "Fast Food", "Debit", "McDonald's", 900)
    t9 = Transaction(2015, 9, 24, "Fast Food", "Cash", "Wendy's", 1000)
    t10 = Transaction(2015, 10, 23, "Fast Food", "Gifts", "Wendy's", 1100)
    t11 = Transaction(2015, 11, 22, "Fast Food", "Savings", "Coffee", 1200)
    t12 = Transaction(2016, 11, 22, "Fast Food", "Savings", "Coffee", 1300)
    t13 = Transaction(2016, 10, 22, "Fast Food", "Savings", "Coffee", 1300)
    t14 = Transaction(2016, 10, 22, "Drinks", "Savings", "Coffee", 1200)

    a1 = Account("Drinks", 0, [t14], {2016: {10: Budget(1500, 1200, 1)}})
    a2 = Account("Fast Food", 0,
                 [t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13],
                 {})

    main([a1, a2])
예제 #14
0
def process_income():
    income_processor = Account()
    income_processor.process_all()
예제 #15
0
파일: main.py 프로젝트: maurogome/platzi
from car import Car
from account import Account

if __name__ == "__main__":
    print("Hola Mundo")
    """
    car = Car()
    car.license = "ANN321"
    car.driver = "Anahi Salgado"
    print(vars(car))

    car2 = Car()
    car2.license = "MAU777"
    car2.driver = "Mauro Gomez"
    print(vars(car2))
    """

    car = Car("ANN123", Account("Anahi Salgado", "AN465"))
    print(vars(car))
    print(vars(car.driver))
예제 #16
0
 def test_magic_method_gt(self):
     acc = Account("Pesho", 30)
     self.assertFalse(self.a > acc)
     self.assertTrue(acc > self.a)
     self.assertGreater(acc, self.a)
예제 #17
0
            else:
                transaction = self.transactions[i]
                base_leafs.append(transaction.hash)

        leafs = [base_leafs]

        while len(leafs[-1]) > 1:
            next_leafs = []
            for i in range(0, len(leafs[-1]), 2):
                combined_hashes = leafs[-1][i] + leafs[-1][i+1]
                next_hash = '0x'+hashlib.sha256(combined_hashes.encode('utf-8')).hexdigest()
                next_leafs.append(next_hash)
            leafs.append(next_leafs)

        self.leafs = leafs
        self.root = leafs[-1][-1]

if __name__ == '__main__':
    from account import Account

    alice = Account()
    bob = Account()
    block = Block()

    # next block of transactions
    transaction = Transaction(bob.address, alice.address, 50)
    signature = bob.sign(transaction.hash)
    block.add_transaction(transaction, bob.pub_key, signature)

    print(block.serialize())
예제 #18
0
 def test_magic_method_ge(self):
     acc = Account("Pesho", 30)
     self.assertTrue(acc >= self.a)
     self.assertTrue(self.a >= self.a)
     self.assertFalse(self.a >= acc)
     self.assertGreaterEqual(acc, self.a)
예제 #19
0
def generate_fake_account():
    account = Account(account_number=generate_account_number(),
                      pin=generate_pin_number(),
                      balance=generate_balance())
예제 #20
0
 def test_magic_method_lt(self):
     acc = Account("Pesho", 30)
     self.assertFalse(acc < self.a)
     self.assertTrue(self.a < acc)
     self.assertLess(self.a, acc)
예제 #21
0
deploy_node = getFromJsonOrEnv("networks.json", "DEPLOYNODE")
web3 = Web3(HTTPProvider(deploy_node))
proxy_address = web3.toChecksumAddress(
    getFromJsonOrEnv("addresses.json", "PROXY"))

with open("deploy_config.json") as deploy_config:
    deploy_config = json.load(deploy_config)

with open(getenv("KEYFILE")) as keyfile_c:
    keyfile = json.load(keyfile_c)

decrypt_pass = getenv("DECRYPTPASS")

deployer_decrypted_key = web3.eth.account.decrypt(keyfile, decrypt_pass)
deployer = Account(web3, deploy_config["build_path"],
                   web3.toChecksumAddress(keyfile["address"]),
                   deployer_decrypted_key)

proxy = deployer.instantiate_contract("Proxy", proxy_address)

WonderERC20_code_hash, WonderERC20_code = deployer.deploy(
    "WonderfulERC20", tx_args(gas=3000000,
                              gasPrice=deploy_config["gas_price"]))
assert web3.eth.waitForTransactionReceipt(
    WonderERC20_code_hash).status == 1, "Error deploying WonderERC20 code."

upgrade_data = proxy.functions.upgradeTo(
    WonderERC20_code.address).buildTransaction(
        tx_args(gas=3000000, gasPrice=deploy_config["gas_price"]))
upgrade_hash = deployer.send_transaction(upgrade_data)
print(
예제 #22
0
 def test_magic_method_le(self):
     acc = Account("Pesho", 30)
     self.assertTrue(self.a <= acc)
     self.assertFalse(acc <= self.a)
     self.assertLessEqual(self.a, acc)
예제 #23
0
def main():
    """
    Create an API context, and use it to fetch an Account state and then
    continually poll for changes to it.

    The configuration for the context and Account to fetch is parsed from the
    config file provided as an argument.
    """

    parser = argparse.ArgumentParser()

    #
    # The config object is initialized by the argument parser, and contains
    # the REST APID host, port, accountID, etc.
    #
    common.config.add_argument(parser)

    parser.add_argument(
        "--poll-interval",
        type=int,
        default=5,
        help="The number of seconds between polls for Account changes")

    args = parser.parse_args()

    account_id = args.config.active_account

    #
    # The v20 config object creates the v20.Context for us based on the
    # contents of the config file.
    #
    api = args.config.create_context()

    #
    # Fetch the details of the Account found in the config file
    #
    response = api.account.get(account_id)

    #
    # Extract the Account representation from the response and use
    # it to create an Account wrapper
    #
    account = Account(response.get("account", "200"))

    def dump():
        account.dump()

        print("Press <ENTER> to see current state for Account {}".format(
            account.details.id))

    dump()

    while True:
        i, o, e = select.select([sys.stdin], [], [], args.poll_interval)

        if i:
            sys.stdin.readline()
            dump()

        #
        # Poll for all changes to the account since the last
        # Account Transaction ID that was seen
        #
        response = api.account.changes(
            account_id, sinceTransactionID=account.details.lastTransactionID)

        account.apply_changes(response.get("changes", "200"))

        account.apply_state(response.get("state", "200"))

        account.details.lastTransactionID = response.get(
            "lastTransactionID", "200")
예제 #24
0
 def test_add_accounts(self):
     acc = Account("Pesho", 30)
     acc_total = acc + self.a
     string = str(acc_total)
     self.assertEqual('Account of Pesho&George with starting amount: 30', string)
     self.assertEqual(list(acc_total), [])
예제 #25
0
from car import Car
from account import Account

if __name__ == "__main__":
    print("Hola mundo")

car = Car("AMS523", Account("Andrés Herrera", "El INE"))
print(vars(car))
print(vars(car.driver))
"""
Sin el método constructor de python

car2 = Car()
car2.license="PWD2539"
car2.driver="Anita Platzi"
print(vars(car2))
"""
예제 #26
0
 def test_init_with_amount(self):
     account = Account('bob', 10)
     self.assertEqual(account.amount, 10)
     self.assertEqual(account.owner, 'bob')
 def setUp(self):
     self.superAccount = Account('SuperUser', 'SuperPass', 'SuperName',
                                 'SuperAdd', 'SuperEmail', "1234567980", 0)
예제 #28
0
 def setUp(self):
     self.a = Account('George')
예제 #29
0
""" One object of class SavingsAccount represents one
    savings account with a customer, a balance, and an interest rate
"""

from account import Account


class SavingsAccount(Account):
    # syntax above shows that SavingsAccount is a subclass of the superclass Account

    def __init__(self):
        Account.__init__(
            self
        )  # calls the Account constructor to initialize that part of the object
        print("SavingsAccount constructor")
        self.interestRate = 0.05

    def __str__(self):
        return Account.__str__(self) + ", and the interest rate is " + str(
            self.interestRate)


""" This is the test program to see how these two types of objects are constructed """

if __name__ == "__main__":
    account = Account()
    print(account)
    savingsAccount = SavingsAccount()
    print(savingsAccount)
예제 #30
0
 def createAccount(self, accountId, firstName, lastName, accountType, email , password):
     #The Account details must be validated at Sign Up class, before entering this point.
     newUser = Account(accountId, firstName, lastName, accountType, email , password)
     self.__accounts.append(newUser)