本文整理匯總了Python中models.Stock.wkn方法的典型用法代碼示例。如果您正苦於以下問題:Python Stock.wkn方法的具體用法?Python Stock.wkn怎麽用?Python Stock.wkn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.Stock
的用法示例。
在下文中一共展示了Stock.wkn方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: stock_add
# 需要導入模塊: from models import Stock [as 別名]
# 或者: from models.Stock import wkn [as 別名]
def stock_add(request):
from app.remote.stocks import StockHistoryClient
from app.forms import StockWizardForm
from app.models import Company, Stock
if request.method == "POST":
form = StockWizardForm(request.POST)
pprint(form.is_valid())
if form.is_valid():
# save
company = Company()
company.name = form.cleaned_data['company_name']
company.country = form.cleaned_data['company_country']
company.save()
stock = Stock()
stock.company = company
stock.name = form.cleaned_data['name']
stock.wkn = form.cleaned_data['wkn']
stock.isin = form.cleaned_data['isin']
stock.symbol = form.cleaned_data['symbol']
stock.type = form.cleaned_data['type']
stock.default_stock_exchange = form.cleaned_data['default_stock_exchange']
stock.save()
return HttpResponseRedirect(reverse('stock', args=(stock.symbol,)))
else:
pprint(form.errors)
else:
data = None
if 'wkn_or_isin' in request.GET:
shc = StockHistoryClient()
data = shc.get_basics_by_wkn_or_isin(wkn_or_isin=request.GET['wkn_or_isin'])
data['company_country'] = data['country']
data['company_name'] = data['name']
form = StockWizardForm(initial=data)
return render_to_response(
'stock_wizard_add.html',
{
'form': form
},
context_instance=RequestContext(request)
)