Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions history/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ def algo(self,obj):
if trs.count:
tr = trs[0]
if tr.clf:
html += "<a href='/admin/history/classifiertest/{}'>{}</a>".format(tr.clf.pk,tr.clf)
html += "<a href='/admin/history/classifiertest/{}'>{}</a>".format(tr.clf.pk,tr.clf)
if tr.made_by:
html += "<a href='/admin/history/predictiontest/{}'>{}</a>".format(tr.made_by.pk,tr.made_by)
html += "<a href='/admin/history/predictiontest/{}'>{}</a>".format(tr.made_by.pk,tr.made_by)
return html

algo.allow_tags = True
Expand Down Expand Up @@ -82,6 +82,3 @@ def view_link(obj):
list_display = ['pk', 'type','symbol', 'name', 'created_on', 'percent_correct', 'score', 'prediction_size', view_link]

admin.site.register(ClassifierTest, ClassifierTestAdmin)



4 changes: 2 additions & 2 deletions history/management/commands/alert_fail_cases.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.core.management.base import BaseCommand
import datetime
from history.models import PredictionTest, TradeRecommendation, get_time
from django.conf import settings
from django.core.management.base import BaseCommand
from history.models import PredictionTest, TradeRecommendation, get_time

class Command(BaseCommand):

Expand Down
8 changes: 4 additions & 4 deletions history/management/commands/pull_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import time

import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)
warnings.filterwarnings("ignore", category=RuntimeWarning)
warnings.filterwarnings("ignore", category=DeprecationWarning)
warnings.filterwarnings("ignore", category=RuntimeWarning)


class Command(BaseCommand):
Expand All @@ -36,8 +36,8 @@ def handle(self, *args, **options):
exchange_rate_coin_to_btc = get_exchange_rate_to_btc(ticker)
exchange_rate_btc_to_usd = get_exchange_rate_btc_to_usd()
exchange_rate_coin_to_usd = exchange_rate_btc_to_usd * exchange_rate_coin_to_btc
btc_val = exchange_rate_coin_to_btc * val
usd_val = exchange_rate_btc_to_usd * btc_val
btc_val = exchange_rate_coin_to_btc * val
usd_val = exchange_rate_btc_to_usd * btc_val
b = Balance(symbol=ticker,coin_balance=val,btc_balance=btc_val,exchange_to_btc_rate=exchange_rate_coin_to_btc,usd_balance=usd_val,exchange_to_usd_rate=exchange_rate_coin_to_btc,deposited_amount_btc=deposited_amount_btc if ticker =='BTC' else 0.00, deposited_amount_usd=deposited_amount_usd if ticker =='BTC' else 0.00)
b.save()

Expand Down
6 changes: 3 additions & 3 deletions history/management/commands/scheduled_trades.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import time

import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)
warnings.filterwarnings("ignore", category=RuntimeWarning)
warnings.filterwarnings("ignore", category=DeprecationWarning)
warnings.filterwarnings("ignore", category=RuntimeWarning)


class Command(BaseCommand):
Expand All @@ -30,7 +30,7 @@ def handle(self, *args, **options):

for t in Trade.objects.filter(created_on__lt=datetime.datetime.now(),status='scheduled'):

#bid right below the lowest ask, or right above the highest bid so that our orders get filled
#bid right below the lowest ask, or right above the highest bid so that our orders get filled
action = t.type
price = Price.objects.filter(symbol=t.symbol).order_by('-created_on').first()
if action == 'sell':
Expand Down
100 changes: 50 additions & 50 deletions history/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def get_line_chart(pts, symbol, parameter):
'tot_items':Count(parameter)}}])

pivcht = PivotChart(
datasource = ds,
datasource = ds,
series_options = [
{'options': {
'type': 'column'},
Expand Down Expand Up @@ -125,11 +125,11 @@ def get_balance_breakdown_chart(bs,denom,symbol,start_time):
'total_value':Sum(denom)}}])

pivcht = PivotChart(
datasource = ds,
datasource = ds,
series_options = [
{'options': {
'type': 'column',
'stacking': True,
'stacking': True,
'xAxis': 0,
'yAxis': 0},
'terms': ['total_value']}],
Expand Down Expand Up @@ -160,7 +160,7 @@ def get_balance_chart(bs,denom,symbol,start_time):
}}])

pivcht = PivotChart(
datasource = ds,
datasource = ds,
series_options = [
{'options': {
'type': 'line',
Expand Down Expand Up @@ -195,11 +195,11 @@ def get_trade_chart(bs,denom,symbol,start_time):
'total_value':Sum('net_amount')}}])

pivcht = PivotChart(
datasource = ds,
datasource = ds,
series_options = [
{'options': {
'type': 'column',
'stacking': True,
'stacking': True,
'xAxis': 0,
'yAxis': 0},
'terms': ['total_value']}],
Expand Down Expand Up @@ -232,11 +232,11 @@ def get_trade_profitability_chart(bs,denom,symbol,start_time):
'total_value':Sum('btc_net_profit')}}])

pivcht = PivotChart(
datasource = ds,
datasource = ds,
series_options = [
{'options': {
'type': 'column',
'stacking': True,
'stacking': True,
'xAxis': 0,
'yAxis': 0},
'terms': ['total_value']}],
Expand Down Expand Up @@ -268,15 +268,15 @@ def get_performance_comps_chart(bs,denom,symbol,start_time):
])

cht = Chart(
datasource = ds,
series_options =
datasource = ds,
series_options =
[{'options':{
'type': 'line',
'stacking': False},
'terms':{
'created_on_str': ['delta', 'actual_movement', 'nn_rec','pct_buy','pct_sell','weighted_avg_nn_rec' ]
}}],
chart_options =
chart_options =
{'title': {
'text': 'Algorithm vs Reality: Debug'},
'xAxis': {
Expand All @@ -303,7 +303,7 @@ def get_directional_change_chart(bs,denom,symbol,start_time):
'total_value':Sum('directionally_same_int')}}])

pivcht = PivotChart(
datasource = ds,
datasource = ds,
series_options = [
{'options': {
'type': 'line',
Expand All @@ -326,7 +326,7 @@ def get_ticker_price(bs,denom,symbol,start_time):

p = Price.objects.none()
for minute in [0,5,10,15,20,25,30,35,40,45,50,55]:
p = p | Price.objects.exclude(created_on_str="").filter(symbol=symbol,created_on__gte=start_time,created_on__minute=minute)
p = p | Price.objects.exclude(created_on_str="").filter(symbol=symbol,created_on__gte=start_time,created_on__minute=minute)
p = p.order_by('created_on')

ds = DataPool(
Expand All @@ -339,16 +339,16 @@ def get_ticker_price(bs,denom,symbol,start_time):
])

cht = Chart(
datasource = ds,
series_options =
datasource = ds,
series_options =
[{'options':{
'type': 'line',
'stacking': False},
'terms':{
'created_on_str': [
'price']
}}],
chart_options =
chart_options =
{'title': {
'text': 'Price Over Time {}'.format(symbol)},
'xAxis': {
Expand Down Expand Up @@ -403,7 +403,7 @@ def nn_chart_view(request):
'options' : options,
})

# get parameter distribution charts
# get parameter distribution charts
parameters = ['datasetinputs','hiddenneurons','granularity','minutes_back','epochs','learningrate','momentum','weightdecay','bias_chart','recurrent_chart','timedelta_back_in_granularity_increments','time','prediction_size']
for x_axis in parameters:
i = i + 1
Expand All @@ -425,19 +425,19 @@ def nn_chart_view(request):


#Step 3: Send the chart object to the template.
return render_to_response('chart.html',{
return render_to_response('chart.html',{
'pts' : pts.order_by('percent_correct'),
'ticker' : symbol,
'symbols' : symbols,
'meta' : meta,
'days_ago' : [1,2,3,4,5,10,15,30],
'hours_ago' : [1,2,3,6,12,24],
'getparams' : getify(request.GET),
'charts': charts,
'metas' : metas,
'chartnames' : chartnames,
'meta' : meta,
'days_ago' : [1,2,3,4,5,10,15,30],
'hours_ago' : [1,2,3,6,12,24],
'getparams' : getify(request.GET),
'charts': charts,
'metas' : metas,
'chartnames' : chartnames,
'chartnamesstr' : ",".join(chartnames),
'is_trainer_running' : is_trainer_running,
'is_trainer_running' : is_trainer_running,
'trainer_last_seen' : trainer_last_seen,
'symbols_that_exist' : symbols_that_exist,
})
Expand Down Expand Up @@ -490,7 +490,7 @@ def c_chart_view(request):
'options' : options,
})

# get parameter distribution charts
# get parameter distribution charts
parameters = ['name','datasetinputs','granularity','minutes_back','timedelta_back_in_granularity_increments','time','prediction_size']
for x_axis in parameters:
i = i + 1
Expand All @@ -512,19 +512,19 @@ def c_chart_view(request):


#Step 3: Send the chart object to the template.
return render_to_response('c_chart.html',{
return render_to_response('c_chart.html',{
'pts' : pts.order_by('percent_correct'),
'ticker' : symbol,
'symbols' : symbols,
'meta' : meta,
'days_ago' : [1,2,3,4,5,10,15,30],
'hours_ago' : [1,2,3,6,12,24],
'getparams' : getify(request.GET),
'charts': charts,
'metas' : metas,
'chartnames' : chartnames,
'meta' : meta,
'days_ago' : [1,2,3,4,5,10,15,30],
'hours_ago' : [1,2,3,6,12,24],
'getparams' : getify(request.GET),
'charts': charts,
'metas' : metas,
'chartnames' : chartnames,
'chartnamesstr' : ",".join(chartnames),
'is_trainer_running' : is_trainer_running,
'is_trainer_running' : is_trainer_running,
'trainer_last_seen' : trainer_last_seen,
'symbols_that_exist' : symbols_that_exist,
})
Expand Down Expand Up @@ -571,7 +571,7 @@ def profit_view(request):
chartnames.append(str(func).split()[1].replace('get_','').replace('_chart',''))
options = []


num_runs = 0
view_data = []
for key in data.keys():
Expand All @@ -598,17 +598,17 @@ def profit_view(request):
'diff' : round(data[key]['diff'],4),
})

view_data = sorted(view_data, reverse=True, key=lambda vd: vd['date'])
view_data = sorted(view_data, reverse=True, key=lambda vd: vd['date'])
last_day_profit = view_data[0]['diff'] if len(view_data) > 0 else 0
max_date = view_data[0]['date'] if len(view_data) > 0 else 0
is_in_profit = last_day_profit > 0

return render_to_response('profit.html',{ 'data' : view_data,
'days_ago' : [1,2,3,4,5,10,15,30],
'hours_ago' : [1,2,3,6,12,24],
'getparams' : getify(request.GET),
'charts' : charts,
'chartnames' : chartnames,
'days_ago' : [1,2,3,4,5,10,15,30],
'hours_ago' : [1,2,3,6,12,24],
'getparams' : getify(request.GET),
'charts' : charts,
'chartnames' : chartnames,
'chartnamesstr' : ",".join(chartnames),
'denoms' : denoms,
'the_denom' : the_denom,
Expand Down Expand Up @@ -664,14 +664,14 @@ def optimize_view(request):
chartnames.append(str(func).split()[1].replace('get_','').replace('_chart',''))
options = []



return render_to_response('optimize.html',{
'days_ago' : [1,2,3,4,5,10,15,30],
'hours_ago' : [1,2,3,6,12,24],
'getparams' : getify(request.GET),
'charts' : charts,
'chartnames' : chartnames,

return render_to_response('optimize.html',{
'days_ago' : [1,2,3,4,5,10,15,30],
'hours_ago' : [1,2,3,6,12,24],
'getparams' : getify(request.GET),
'charts' : charts,
'chartnames' : chartnames,
'chartnamesstr' : ",".join(chartnames),
'denoms' : denoms,
'the_denom' : the_denom,
Expand Down