当前位置: 首页>>代码示例>>Python>>正文


Python Transaction.this_transaction方法代码示例

本文整理汇总了Python中transaction.Transaction.this_transaction方法的典型用法代码示例。如果您正苦于以下问题:Python Transaction.this_transaction方法的具体用法?Python Transaction.this_transaction怎么用?Python Transaction.this_transaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在transaction.Transaction的用法示例。


在下文中一共展示了Transaction.this_transaction方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: transfer_required_deposits

# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import this_transaction [as 别名]
	def transfer_required_deposits(self):
		from transaction import Transaction
		
		transaction = Transaction()
		value = round(float(self.r*self.get_account("D")), 4)
		transaction.this_transaction("rD",  self.identifier,  -3,  value,  self.rb,  0,  -1)
		self.accounts.append(transaction)
		
		return  -1.0*value
开发者ID:B-Leslie,项目名称:systemshock,代码行数:11,代码来源:bank.py

示例2: transfer_excess_reserves

# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import this_transaction [as 别名]
	def transfer_excess_reserves(self):
		from transaction import Transaction
		availableVolume = self.Q
		plannedVolume = self.gamma*(1.0-self.lamb)*self.V
		transactionVolume = round(min(plannedVolume,  availableVolume), 4)
		self.Q = round(self.Q - transactionVolume, 4)
		if (self.Q < 0.0):
			logging.info("ERROR: Q negative in transfer_excess_reserves")
		transaction = Transaction()
		transaction.this_transaction("E",  self.identifier, -2,  transactionVolume,  self.rb,  0,  -1)
		self.accounts.append(transaction)
		del transaction
开发者ID:B-Leslie,项目名称:systemshock,代码行数:14,代码来源:bank.py

示例3: add_transaction

# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import this_transaction [as 别名]
	def add_transaction(self,  type,  fromID,  toID,  value,  interest,  maturity, timeOfDefault):
		from transaction import Transaction
		transaction = Transaction()
		transaction.this_transaction(type,  fromID,  toID,  value,  interest,  maturity,  timeOfDefault)
		self.accounts.append(transaction)
		del transaction
开发者ID:B-Leslie,项目名称:systemshock,代码行数:8,代码来源:bank.py

示例4: initialize_transactions

# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import this_transaction [as 别名]
	def initialize_transactions(self, state):
		from transaction import Transaction
		from random import Random
		random = Random()
		
		value = 0.0
		
		# first, calculate number of transactions for investments
		numTransactions = int(round(self.assetNumber / self.numBanks))
		if (numTransactions == 0): # we want some error message if there are two few assets in the economy
			logging.info("  ERROR: number of  assets in the economy has to be at least half the number of banks")
		# now, calculate value of each transaction and note that the *product* of all individual transactions
		# is supposed to have precision 4. Hence, each individual transaction should have precision 5
		value = round(float(self.gamma*self.lamb*self.V / numTransactions), 5)
		
		# finally, put them on the transaction stack
		for i in range(numTransactions):
			transaction = Transaction()
			# 
			# account for different maturities
			#
			maturity = int(round(random.random()*state.firmLoanMaturity, 1)) # this is done very roughly and implies loans are up to 3 years
			# and determine whether the loan will default
			if (random.random() >= state.successProbabilityFirms):
				# the loan defaults: determine timeOfDefault
				timeOfDefault = int(round(random.random()*maturity))
			else:
				timeOfDefault = -1
			# then, generate the transaction, append it to the accounts, and delete it from memory
			transaction.this_transaction("I",  self.identifier, -2,  value,  self.rho,  maturity, timeOfDefault)
			self.accounts.append(transaction)
			del transaction
		# store averageTransactionSize
		self.averageTransactionSize = value
		
		# then, calculate excess reserves
		value = round(float(self.gamma*(1.0-self.lamb)*self.V),  4)
		transaction = Transaction()
		transaction.this_transaction("E",  self.identifier,  -3,  value,  self.rb,  0, -1)
		self.accounts.append(transaction)
		del transaction
		
		# on the liabilities side, banks are endowed with banking capital
		# (see comments in get_initial_banking_capital() for further details)
		value = round(float(self.get_initial_banking_capital(state.requiredCapitalRatio)), 4)
		transaction = Transaction()
		transaction.this_transaction("BC",  self.identifier,  self.identifier,  value,  0.0,  0, -1)
		self.accounts.append(transaction)
		del transaction
		
		# now, transfer deposits from households to banks
		value = round(float(self.gamma*self.V-self.get_account("BC")), 4)
		transaction = Transaction()
		transaction.this_transaction("D",  -1,  self.identifier,  value,  self.rd,  0, -1)
		self.accounts.append(transaction)
		del transaction
		
		# as well as required deposits to the central bank
		value = round(float(self.r*self.get_account("D")), 4)
		transaction = Transaction()
		transaction.this_transaction("rD",  self.identifier,  -3,  value,  self.rb,  0, -1)
		self.accounts.append(transaction)
		del transaction
		
		# finally, determine central bank loans
		value = round(float (self.get_account("I") + self.get_account("E") + self.get_account("rD") - self.get_account("D") - self.get_account("BC") ), 4)
		transaction = Transaction()
		transaction.this_transaction("LC",  self.identifier,  -3,  value,  self.rb,  0, -1)
		self.accounts.append(transaction)
		del transaction
开发者ID:B-Leslie,项目名称:systemshock,代码行数:72,代码来源:bank.py

示例5: transfer_investments

# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import this_transaction [as 别名]
	def transfer_investments(self,  state):
		from random import Random
		from transaction import Transaction
		
		random = Random()
		
		currentVolume = 0.0
		optimalVolume = 0.0
		plannedVolume = 0.0
		availableVolume = 0.0
		transactionVolume = 0.0
		
		transaction = Transaction()
		
		# calculate the optimal investment volume and compare to current volume
		self.calculate_optimal_investment_volume()
		optimalVolume = round(float(self.gamma*self.lamb*self.V), 4)
		currentVolume = round(self.get_account("I"), 4)
		# add new transactions of average size
		plannedVolume = optimalVolume - currentVolume
		availableVolume = self.lamb*self.Q # we can only spend a fraction of the available Q
		transactionVolume = min(plannedVolume,  availableVolume)
		
		while ((transactionVolume >= self.averageTransactionSize) and (self.averageTransactionSize > 0.0)):
			
			transactionVolume = round(transactionVolume - self.averageTransactionSize, 5) # reduce remaining transactionVolume
			self.Q = self.Q - self.averageTransactionSize # reduce available liquidity
			
			# account for different maturities of investments
			maturity = int(round(random.random()*state.firmLoanMaturity, 1)) # this is done very roughly and implies loans are up to 3 years
			
			# and determine whether the loan will default
			if (random.random() >= state.successProbabilityFirms):
				# the loan defaults: determine timeOfDefault
				timeOfDefault = int(round(random.random()*maturity))
			else:
				timeOfDefault = -1
			
			# and add transaction to the stack
			transaction = Transaction()
			transaction.this_transaction("I",  self.identifier, -2,  self.averageTransactionSize,  self.rho,  maturity,  timeOfDefault)
			self.accounts.append(transaction)
			del transaction
		
		transactionVolume = round(transactionVolume, 5)
		# finally, add the remaining transaction to the stack if the transactionVolume was positive in the first place
		if (transactionVolume > 0.0):
			self.Q = round(self.Q - transactionVolume, 4)
			
			# account for different maturities of investments
			maturity = int(round(random.random()*state.firmLoanMaturity, 1)) # this is done very roughly and implies loans are up to 3 years
			
			# and determine whether the loan will default
			if (random.random() >= state.successProbabilityFirms):
				# the loan defaults: determine timeOfDefault
				timeOfDefault = int(round(random.random()*maturity))
			else:
				timeOfDefault = -1
			
			transaction = Transaction()
			transaction.this_transaction("I",  self.identifier, -2,  transactionVolume,  self.rho,  maturity,  timeOfDefault)
			self.accounts.append(transaction)
			del transaction
开发者ID:B-Leslie,项目名称:systemshock,代码行数:65,代码来源:bank.py


注:本文中的transaction.Transaction.this_transaction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。