Пример #1
0
    def withdraw(self, public_key):
        """
        提取质押金
        :param public_key:
        :return:
        """
        # 是否有质押金冻结记录
        require(public_key in self.deregister_list)

        lock_stake_block_count = 5
        return_stake_infos = []

        for info in self.deregister_list[public_key]:
            if (block.number() - info["deregisterBlockNumber"] >
                    lock_stake_block_count and info["owner"] == msg.sender):
                return_stake_infos.append(info)

        # 是否有已解冻质押金未提取,并且检查owner
        require(len(return_stake_infos) > 0)

        for info in return_stake_infos:
            self.deregister_list[public_key].remove(info)
        # 删除空KEY
        if len(self.deregister_list[public_key]) <= 0:
            self.deregister_list.pop(public_key)

        return_stake = 0
        for info in return_stake_infos:
            return_stake += info["stake"]

        # 转账
        assert return_stake > 0
        assert account.get_balance(this) > return_stake
        account.transfer(msg.sender, return_stake)
Пример #2
0
print('after', numbers)
numbers = sorted(numbers)
print('after2', numbers)

numbers.clear()
for i in range(10):
    numbers.append(randint(1, 100))


print('unsorted', numbers)
numbers.sort()
print('after', numbers)


print(sorted('Donald Trump'))

print(sorted(['Z', 'a'], key=str.lower))

account1 = account.Account('Alice', 2000)
account2 = account.Account('Bob', 1000)
account3 = account.Account('Charlie', 3000)

print(account1.__repr__())

accounts = [account3, account2, account1]
print('before', accounts)
print('sorted by name', sorted(
    accounts, key=lambda account: account.get_account_holder()))
print('sorted by balance', sorted(
    accounts, key=lambda account: account.get_balance()))
Пример #3
0
 def failed(self):
     if not self.on_sale and self.funding < self.funding_goal and self.funding >= account.get_balance(
             this):
         for k, v in self.vote_dict.items():
             account.transfer(k, v)
Пример #4
0
from binance.client import Client
from binance.enums import *
from binance.websockets import BinanceSocketManager
from account import get_balance
from ma_generator import MAGenerator
from secrets import API_KEY
from secrets import API_SECRET

SYMBOL = "EOSETH"
INTERVAL = KLINE_INTERVAL_15MINUTE
BALANCE = 0.03716156
ma_durations = [7, 25, 99]
client = Client(API_KEY, API_SECRET)
print get_balance(client, "ETH")

ma_generator = MAGenerator(client, SYMBOL, ma_durations, INTERVAL)
print ma_generator.get_mas()

# # place market buy order
# from binance.enums import *


def create_order(price):
    qty = 0
    order = client.get_account()
    for balance in order['balances']:
        if balance["asset"] == "ETH":
            qty = float(balance["free"])
    if qty == 0:
        return
    order_qty = "{:0.2f}".format(str(qty / price))
Пример #5
0
import os
import sys
sys.path.append(os.getenv('ACCOUNT_MODULE_PATH'))

import account  # isort: skip

account1 = account.new()

account.deposit(account1, 100.0)
account.deposit(account1, 100.0)

account2 = account.new()

account.deposit(account2, 200.0)
account.deposit(account2, 200.0)

account.withdraw(account1, 50.0)

assert account.get_balance(account1) == 150.0
account.free(account1)

assert account.get_balance(account2) == 400.0
account.free(account2)
Пример #6
0
 def ckeckbalance(self, addr):
     return account.get_balance(addr)