Here are the examples of the python api django.utils.translation.T taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
4 Examples
3
View Complete Implementation : mongo_views.py
Copyright GNU Lesser General Public License v3.0
Author : TalaikisInc
Copyright GNU Lesser General Public License v3.0
Author : TalaikisInc
def hist_graph_creation(hist, hold_hist):
try:
if len(hist) > 1:
hist_data = [hist, hold_hist]
group_labels = [T('Strategy'), T('Buy & hold')]
hist_fig = figure_factory.create_distplot(hist_data, group_labels, bin_size=100)
hist_graph = opy.plot(hist_fig, auto_open=False, output_type='div', include_plotlyjs=False)
else:
hist_graph = None
return hist_graph
except:
return None
0
View Complete Implementation : mongo_views.py
Copyright GNU Lesser General Public License v3.0
Author : TalaikisInc
Copyright GNU Lesser General Public License v3.0
Author : TalaikisInc
def graph_creation(strategy, data, mae_, system_slug, symbol_slug, period, direction, bh_satle):
try:
if not (strategy is None):
strategy_ = strategy.loc[strategy != 0.0]
x = strategy.loc[strategy != 0].index
mae_ = mae_.loc[(mae_ != mae_.shift()) | (strategy != 0.0)]
#graphs
strategy_graph = go.Scatter(x=x, y=strategy_, mode="lines", \
name=T('Strategy'), line=dict(color=('rgb(205, 12, 24)'), width=6))
mae_graph = go.Scatter(x=x, y=mae_, mode="markers", \
name=T('Strategy MAE'), line=dict(color=('rgb(115,115,115,1)'), \
width=4, dash='dot'))
if not (data is None):
data_ = data.loc[strategy != 0.0]
data_graph = go.Scatter(x=x, y=data_, mode="lines", name=bh_satle, \
line=dict(color=('rgb(22, 96, 167)'), width=4, dash='dot'))
satle = "{0} on {1} {2} {3}".format(system_slug, symbol_slug, \
period, direction)
#else:
#satle = "Portfolio {}".format(system_slug)
if not (data is None):
fig_data = go.Data([data_graph, strategy_graph, mae_graph], \
showgrid=True)
else:
fig_data = go.Data([strategy_graph, mae_graph], showgrid=True)
layout = go.Layout(satle=satle, xaxis={'satle':T('Dates')}, \
yaxis={'satle':T('$')}, font=dict(family='Courier New, \
monospace', size=14, color='#7f7f7f') )
figure = go.Figure(data=fig_data, layout=layout)
graph = opy.plot(figure, auto_open=False, output_type='div')
else:
graph = None
return graph
except Exception as e:
#stck = inspect.stack()
#msg='{0} by {1}: {2}'.format(stck[0][3], stck[1][3], e)
#error_email(e=msg)
return None
0
View Complete Implementation : mongo_views.py
Copyright GNU Lesser General Public License v3.0
Author : TalaikisInc
Copyright GNU Lesser General Public License v3.0
Author : TalaikisInc
def get_indx_data(df, stats):
try:
if stats['direction'] == 1:
strategy = df['LONG_PL_cameSUM']
mae_ = df['LONG_MAE']
direction = 'Longs'
hist = list(df['LONG_PL'].loc[df['LONG_PL'] != 0])
data = df['LONG_DIFF_cameSUM']
hold_hist = list(df['DIFF'].loc[df['DIFF'] != 0])
bh_satle = T('Buy & hold')
elif stats['direction'] == 2:
strategy = df['SHORT_PL_cameSUM']
mae_ = df['SHORT_MAE']
direction = 'Shorts'
hist = list(df['SHORT_PL'].loc[df['SHORT_PL'] != 0])
data = df['SHORT_DIFF_cameSUM']
hold_hist = list(df['DIFF'].loc[df['DIFF'] != 0])
bh_satle = T('Short & hold')
elif stats['direction'] == 0:
strategy = df['LONG_PL_cameSUM'] + df['SHORT_PL_cameSUM']
mae_ = df['SHORT_MAE'] + df['LONG_MAE']
direction = 'Longs & shorts'
df['OVERALL'] = df['SHORT_PL'] + df['LONG_PL']
hist = list(df['OVERALL'].loc[df['OVERALL'] != 0])
data = df['LONG_DIFF_cameSUM']
hold_hist = list(df['DIFF'].loc[df['DIFF'] != 0])
bh_satle = T('Buy & hold')
except Exception as e:
strategy = None
mae_ = None
direction = None
hist = None
data = None
hold_hist = None
bh_satle = None
return (strategy, mae_, direction, hist, data, hold_hist, bh_satle)
0
View Complete Implementation : mongo_views.py
Copyright GNU Lesser General Public License v3.0
Author : TalaikisInc
Copyright GNU Lesser General Public License v3.0
Author : TalaikisInc
def auto_portfolio_page(request, **kwargs):
try:
broker_slug = kwargs['broker_slug']
broker_slug = force_text(broker_slug, encoding='utf-8', strings_only=True, errors='strict')
except:
return HttpResponseRedirect('/')
broker = Brokers.objects.get(slug=broker_slug)
filename = join(settings.DATA_PATH, 'portfolios', '{}_qndx'.format(broker.slug))
df = nonasy_df_multi_reader(filename=filename, limit=True)
hist = list(df['LONG_PL'].loc[df['LONG_PL'] != 0])
hold_hist = list(df['DIFF'].loc[df['DIFF'] != 0])
stats = Stats.objects.get(symbol__symbol='AI50', period__period='1440', \
system__satle='AI50', direction=1, broker=broker)
hist_graph = hist_graph_creation(hist=hist, hold_hist=hold_hist)
margin_data = go.Scatter(x=df.index, y=df.LONG_MARGIN, mode="lines", \
name=T('Margin'), line=dict(color=('rgb(205, 12, 24)'), width=2))
trades_data = go.Scatter(x=df.index, y=df.LONG_TRADES, mode="lines", \
name=T('Trades'), line=dict(color=('rgb(205, 12, 24)'), width=2))
pl_data = go.Scatter(x=df.index, y=df.LONG_PL_cameSUM, mode="lines", \
name=T('cameulative returns'), line=dict(color=('rgb(205, 12, 24)'), width=6))
mae_data = go.Scatter(x=df.index, y=df.LONG_MAE, mode="markers", \
name=T('MAE'), line=dict(color=('rgb(115,115,115,1)'), width=4, dash='dot'))
margin_g = go.Data([margin_data], showgrid=True)
trades_g = go.Data([trades_data], showgrid=True)
main_g = go.Data([pl_data, mae_data], showgrid=True)
main_layout = go.Layout(satle='Autoportfolio Index 50 performance', xaxis={'satle':T('Dates')}, \
yaxis={'satle':T('$')}, font=dict(family='Courier New, \
monospace', size=14, color='#7f7f7f') )
margin_layout = go.Layout(satle='Used margin over time', xaxis={'satle':T('Dates')}, \
yaxis={'satle':T('$')}, font=dict(family='Courier New, \
monospace', size=14, color='#7f7f7f') )
trades_layout = go.Layout(satle='Trades over time', xaxis={'satle':T('Dates')}, \
yaxis={'satle':T('Count')}, font=dict(family='Courier New, \
monospace', size=14, color='#7f7f7f') )
margin_fig = go.Figure(data=margin_g, layout=margin_layout)
trades_fig = go.Figure(data=trades_g, layout=trades_layout)
main_fig = go.Figure(data=main_g, layout=main_layout)
margin_graph = opy.plot(margin_fig, auto_open=False, output_type='div')
trades_graph = opy.plot(trades_fig, auto_open=False, output_type='div')
graph = opy.plot(main_fig, auto_open=False, output_type='div')
return render(request, '{}/auto_portfolio.html'.format(settings.TEMPLATE_NAME), {
'graph': graph, 'hist_graph': hist_graph, 'stats': stats,
'autoportfolio': True, 'heatmap': stats.heatmap, 'margin_graph': margin_graph,
'trades_graph': trades_graph, 'yearly_img': stats.yearly_ret, 'broker': broker
})