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


Python Activity.date方法代码示例

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


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

示例1: fund

# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import date [as 别名]
def fund(row):
  ''' A funding of a new individual Takes in a list of a row in CSV.'''
  port_indi = Port_Indi()
  act = Activity()
  
  # Creating the new portfolio/individual    
  port_indi.cash = row[2]
  port_indi.networth = row[2]
  port_indi.name = row[1]
  
  # Check to see if its an Individual or a Porfolio
  if row[0] == 'fund':
    port_indi.is_individual = False
  else:
    port_indi.is_individual = True
  #port_indi.last_quote = Quote()
  port_indi.last_activity = act
  port_indi.save()
  
  # Activity
  act = Activity()
  act.amount = row[2]
  act.act_type = "fund"
  act.port_indi1 = port_indi
  act.date = row[3].replace('-', '')
  act.save()
  
  # Referencing activity
  port_indi.last_activity = act
  port_indi.save()
  print str(port_indi) + ' HAS BEEN FUNDED'
开发者ID:zinglax,项目名称:cmsc424Site,代码行数:33,代码来源:investment_manager.py

示例2: buy

# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import date [as 别名]
def buy(row):
  ''' buying into a portfolio or company. Takes in a list of a row in CSV. 
  buy,fund_1,MMM,233780,2005-01-20
  buy,ind_2,fund_2,6671,2005-01-18
  '''
  buying_port = Port_Indi.objects.get(name=row[1])
  
  # Activity
  act = Activity()
  act.amount = row[3]
  act.act_type = "buy"
  act.port_indi1 = buying_port
  act.date = row[4].replace('-', '')
  
  # Stakehold
  stake = StakeHold()
  stake.last_modified = row[4].replace('-', '')
  stake.fund = buying_port  
  tickers = yahooDataRetriever.get_top_500_tickers(ticker_file)

  # check whether buying company or portfolio  
  if row[2] not in tickers: # Buying Portfolio
    purchase_port = Port_Indi.objects.get(name=row[2])
    act.port_indi2 = purchase_port
    stake.fund2 = purchase_port

    # Check cash amount    
    #if cash >= float(act.amount):
      #purchase_port.c
    
    # Calculate Percentage
    
    # Update other investors percenages
    
    # Calculate networths
    
  else: # Buying Company
    act.company = Company.objects.get(ticker=row[2])
    stake.company = Company.objects.get(ticker=row[2])
    stakes = list(StakeHold.objects.filter(fund=buying_port,company=stake.company))
    print len(stakes)
    cash = act.port_indi1.cash
    
    print row[4].replace('-', '')
    print stake.company
    
    
    hist_data = list(Historical_Data.objects.filter(date=row[4].replace('-', ''), company=Company.objects.get(ticker=row[2])))
    hist_data_record = hist_data[0]
    
    # check if stakehold exists already
    if stakes == []:
      #stake.save()
      #stake.shares = float(row[3])
      stake.shares = float(row[3]) / hist_data_record.closing
    else:
      stake = StakeHold.objects.get(fund=buying_port,company=stake.company)
      #stake.shares = float(row[3])
      stake.shares += float(row[3]) / hist_data_record.closing
    
    # Checking funds
    if cash >= float(act.amount):
      stake.save()
      act.save()
      buying_port.cash = cash - int(act.amount)
      buying_port.save()
      print "## BUY TRANSACTION COMPLETED"
    else:
      print "### INSUFFICIENT FUNDS: TRANSACTION NOT COMPLETED"
开发者ID:zinglax,项目名称:cmsc424Site,代码行数:71,代码来源:investment_manager.py


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