Beispiel #1
0
def run(fileName, logger):
    logger.info('Executing sequence...')
    for command in load(fileName):
        if command['operation'] == 'init':
            monetaryModelState, monetaryModel = init(logger,
                                                     command['timeout'])
        elif command['operation'] == 'buy':
            Contract.jump(command['elapsed'])
            sdrAmount = dec2wei(command['amount'])
            sgaAmount = Contract.decode(monetaryModel.setter().buy(sdrAmount),
                                        0, eventParams)['output']
            logger.debug('buy: {:.2f} SDR ==> {:.2f} SGA'.format(
                wei2dec(sdrAmount), wei2dec(sgaAmount)))
        elif command['operation'] == 'sell':
            Contract.jump(command['elapsed'])
            sgaAmount = dec2wei(command['amount'])
            sdrAmount = Contract.decode(monetaryModel.setter().sell(sgaAmount),
                                        0, eventParams)['output']
            logger.debug('sell: {:.2f} SGA ==> {:.2f} SDR'.format(
                wei2dec(sgaAmount), wei2dec(sdrAmount)))
        elif command['operation'] == 'info':
            logger.debug('SDR = {:.2f}'.format(
                wei2dec(monetaryModelState.getter().getSdrTotal())))
            logger.debug('SGA = {:.2f}'.format(
                wei2dec(monetaryModelState.getter().getSgaTotal())))
        else:
            logger.debug('Undefined operation')
    logger.info('Done')
def run(fileName, logger, modelCalculator, priceBandCalculator,
        ReconciliationAdjuster, ETHConverter):
    logger.info('Executing sequence...')
    for command in load(fileName):
        if command['operation'] == 'init':
            mintingPointTimersManager, sgrToken = init(logger, modelCalculator,
                                                       priceBandCalculator,
                                                       ReconciliationAdjuster,
                                                       ETHConverter,
                                                       command['timeout'])
        elif command['operation'] == 'buy':
            mintingPointTimersManager.now += command['elapsed']
            ethAmount = dec2wei(command['amount'])
            sgrAmount = sgrToken.buy(ethAmount)
            logger.debug('buy: {:.2f} ETH ==> {:.2f} SGR'.format(
                wei2dec(ethAmount), wei2dec(sgrAmount)))
        elif command['operation'] == 'sell':
            mintingPointTimersManager.now += command['elapsed']
            sgrAmount = dec2wei(command['amount'])
            ethAmount = sgrToken.sell(sgrAmount)
            logger.debug('sell: {:.2f} SGR ==> {:.2f} ETH'.format(
                wei2dec(sgrAmount), wei2dec(ethAmount)))
        elif command['operation'] == 'info':
            logger.debug('ETH = {:.2f}'.format(wei2dec(sgrToken.ethTotal)))
            logger.debug('SGR = {:.2f}'.format(wei2dec(sgrToken.sgrTotal)))
        else:
            logger.debug('Undefined operation')
    logger.info('Done')
Beispiel #3
0
def run(fileName, logger, modelCalculator, priceBandCalculator):
    logger.info('Executing sequence...')
    for command in load(fileName):
        if command['operation'] == 'init':
            mintingPointTimersManager, monetaryModelState, monetaryModel = init(
                logger, modelCalculator, priceBandCalculator,
                command['timeout'])
        elif command['operation'] == 'buy':
            mintingPointTimersManager.now += command['elapsed']
            sdrAmount = dec2wei(command['amount'])
            sgaAmount = monetaryModel.buy(sdrAmount)
            logger.debug('buy: {:.2f} SDR ==> {:.2f} SGA'.format(
                wei2dec(sdrAmount), wei2dec(sgaAmount)))
        elif command['operation'] == 'sell':
            mintingPointTimersManager.now += command['elapsed']
            sgaAmount = dec2wei(command['amount'])
            sdrAmount = monetaryModel.sell(sgaAmount)
            logger.debug('sell: {:.2f} SGA ==> {:.2f} SDR'.format(
                wei2dec(sgaAmount), wei2dec(sdrAmount)))
        elif command['operation'] == 'info':
            logger.debug('SDR = {:.2f}'.format(
                wei2dec(monetaryModelState.getSdrTotal())))
            logger.debug('SGA = {:.2f}'.format(
                wei2dec(monetaryModelState.getSgaTotal())))
        else:
            logger.debug('Undefined operation')
    logger.info('Done')
Beispiel #4
0
def run(fileName, logger):
    logger.info('Executing sequence...')
    for command in load(fileName):
        if command['operation'] == 'init':
            sgaToken = init(logger, command['timeout'])
        elif command['operation'] == 'buy':
            Contract.jump(command['elapsed'])
            ethAmount = dec2wei(command['amount'])
            sgaAmount = Contract.decode(
                sgaToken.setter({
                    'value': ethAmount
                }).exchange(), 2, eventParams)['output']
            logger.debug('buy: {:.2f} ETH ==> {:.2f} SGA'.format(
                wei2dec(ethAmount), wei2dec(sgaAmount)))
        elif command['operation'] == 'sell':
            Contract.jump(command['elapsed'])
            sgaAmount = dec2wei(command['amount'])
            ethAmount = Contract.decode(
                sgaToken.setter().transfer(sgaToken.address, sgaAmount), 2,
                eventParams)['output']
            logger.debug('sell: {:.2f} SGA ==> {:.2f} ETH'.format(
                wei2dec(sgaAmount), wei2dec(ethAmount)))
        elif command['operation'] == 'info':
            logger.debug('ETH = {:.2f}'.format(wei2dec(sgaToken.balance())))
            logger.debug('SGA = {:.2f}'.format(
                wei2dec(sgaToken.getter().totalSupply())))
        else:
            logger.debug('Undefined operation')
    logger.info('Done')