Пример #1
0
 def add_stock_gradient(self, stock_code, gradient, b, k):
     stocks=StockList.objects.filter(stock_code=stock_code)
     trend=StockTrend.objects.filter(stock_code=stock_code)
     if trend.exists():
        trend=trend[0]
        trend.a=gradient
        trend.b=b
        trend.k=k
        trend.save()
     else:
        trend=StockTrend(stock_code=stock_code, a=gradient, b=b, k=k)
        trend.save()
      
     if stocks.count():
        x=stocks[0]
        x.gradient=gradient
        x.trend=trend
        x.save()
Пример #2
0
 def add_stock_name(self, stock_code, stock_name):
     trend=StockTrend(stock_code=stock_code, a=0, b=0, k=0)
     trend.save()
     stock=StockList(stock_code=stock_code, stock_name=stock_name, gradient=0, trend=trend)
     stock.save()