Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def apply_change_to_orderbook(self, change):
# Re-sort the bids.
self.orderbook['bids'] = OrderedDict(sorted(
self.orderbook['bids'].iteritems(),
key=lambda (k, v): float(k),
key=lambda k_v1: float(k_v1[0]),
reverse=True,
))

Expand All @@ -230,7 +230,7 @@ def apply_change_to_orderbook(self, change):

# Re-sort the asks.
self.orderbook['asks'] = OrderedDict(
sorted(self.orderbook['asks'].iteritems(), key=lambda (k, v): float(k)),
sorted(self.orderbook['asks'].items(), key=lambda k_v: float(k_v[0])),
)

def parse_orders(self, orders):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,13 +309,13 @@ def get_orderbook_to_publish(self):

sorted_bid_keys = sorted(
fancy_orderbook['bids'].keys(),
key=lambda (k): float(k),
key=lambda k: float(k),
reverse=True,
)

sorted_ask_keys = sorted(
fancy_orderbook['asks'].keys(),
key=lambda (k): float(k),
key=lambda k: float(k),
)

bids = [[k, str(fancy_orderbook['bids'][k]), ''] for k in sorted_bid_keys]
Expand Down
3 changes: 2 additions & 1 deletion gryphon/data_service/scripts/benchmark.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
# Simple test script for benchmarking regular python logging vs twisted's logging.

import logging
Expand Down Expand Up @@ -25,7 +26,7 @@ def tx_log():


def stop():
print "Log Counter: %s" % log_counter
print("Log Counter: %s" % log_counter)
reactor.stop()


Expand Down
17 changes: 9 additions & 8 deletions gryphon/data_service/scripts/historical_trade_collector.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import csv
from datetime import timedelta
import gzip
Expand Down Expand Up @@ -161,7 +162,7 @@ def get_our_recorded_ticker_volume_for_period(exchange, start_date, end_date):
def audit_ticker_volume_individual_days(exchange_list, start_date=test_start_date, end_date=test_end_date):
d = start_date
while d < test_end_date:
print '\n\nAuditing: %s' % d
print('\n\nAuditing: %s' % d)
day_after = d + timedelta(days=1)
audit_all_ticker_volume(exchange_list, d, day_after)
d = day_after
Expand Down Expand Up @@ -191,20 +192,20 @@ def audit_ticker_volume(exchange, start_date, end_date):
end_date,
)

print '%s Our Volume:%s Ticker Volume:%s, Accuracy: %s' % (
print('%s Our Volume:%s Ticker Volume:%s, Accuracy: %s' % (
exchange,
our_volume,
ticker_volume,
our_volume / ticker_volume,
)
))


def audit_bw_volume(exchange, start_date, end_date):
bw_exchange = BitcoinWisdom(exchange=exchange)
bw_volume = bw_exchange.volume_in_period(start_date, end_date)

our_volume = get_our_recorded_exchange_trade_volume_for_period(exchange, start_date, end_date)
print '%s Our Volume:%s BW Volume:%s, Accuracy: %s' % (exchange, our_volume, bw_volume, our_volume / bw_volume)
print('%s Our Volume:%s BW Volume:%s, Accuracy: %s' % (exchange, our_volume, bw_volume, our_volume / bw_volume))


def compare_all_exchanges():
Expand All @@ -222,15 +223,15 @@ def compare_ours_to_history(our_exchange_id, exchange, price_currency, volume_cu
start = parse('2015-11-27 0:0:0').datetime.replace(tzinfo=None)
end = parse('2015-11-27 11:59:59').datetime.replace(tzinfo=None)

print our_exchange_id.upper()
print(our_exchange_id.upper())
hist_in_range = [t for t in hist_trades if t[0] >= start and t[0] <= end]
ours_in_range = [t for t in our_trades if t[0] >= start and t[0] <= end]

for t in hist_in_range:
if t not in ours_in_range:
print 'Hist Trade not in ours: %s' % t
print('Hist Trade not in ours: %s' % t)

for t in ours_in_range:
if t not in hist_in_range:
print'Our trade not in history: %s' % t
print'\n\n\n\n\n'
print('Our trade not in history: %s' % t)
print('\n\n\n\n\n')
11 changes: 6 additions & 5 deletions gryphon/execution/controllers/create_dashboard_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

Usage: gryphon-exec create-dashboard-user [--execute]
"""
from __future__ import print_function

import getpass
import termcolor as tc
Expand Down Expand Up @@ -43,14 +44,14 @@


def main(execute):
print tc.colored(WARNING_MESSAGE, 'red')
print(tc.colored(WARNING_MESSAGE, 'red'))
informed_consent = raw_input(WARNING_PROMPT)

if informed_consent != 'y':
print EXIT_MESSAGE
print(EXIT_MESSAGE)
return
else:
print CONTINUE_MESSAGE
print(CONTINUE_MESSAGE)

dashboard_db = session.get_a_dashboard_db_mysql_session()

Expand All @@ -65,7 +66,7 @@ def main(execute):
dashboard_db.add(user)
dashboard_db.commit()

print tc.colored(SUCCESS_MESSAGE, 'green')
print(tc.colored(SUCCESS_MESSAGE, 'green'))
else:
print SUCCESS_NO_EXECUTE_MESSAGE
print(SUCCESS_NO_EXECUTE_MESSAGE)

5 changes: 3 additions & 2 deletions gryphon/execution/controllers/fee_buyback.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import prompter
import termcolor as tc

Expand All @@ -14,7 +15,7 @@ def buyback():
prompt_msg = tc.colored('Did you stop the Coinbase Bot before running this?', 'red')
bot_stopped = prompter.yesno(prompt_msg)
if not bot_stopped:
print tc.colored('Go stop the bot first.', 'red')
print(tc.colored('Go stop the bot first.', 'red'))
return

db = session.get_a_trading_db_mysql_session()
Expand All @@ -33,7 +34,7 @@ def buyback():
transactions_buyback_amount = sum([t.fee for t in transactions_with_outstanding_fees])
btc_buyback_amount = trades_buyback_amount + transactions_buyback_amount

print 'Go buy %s on Coinbase (not the exchange)' % btc_buyback_amount
print('Go buy %s on Coinbase (not the exchange)' % btc_buyback_amount)

prompt_msg = 'How much USD did it cost (total including Coinbase Fee): USD'
raw_usd_cost = prompter.prompt(prompt_msg)
Expand Down
11 changes: 6 additions & 5 deletions gryphon/execution/controllers/initialize_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
[comma-separated list of exchange pairs, e.g. 'bitstamp_btc_usd,gemini_btc_usd']
[--execute]
"""
from __future__ import print_function

import pyximport; pyximport.install()

Expand Down Expand Up @@ -53,7 +54,7 @@ def initialize_exchange_ledger(db, wrapper_obj):
pass
finally:
if db_obj is not None:
print ALREADY_INITIALIZED_ERR_MESSAGE % wrapper_obj.name
print(ALREADY_INITIALIZED_ERR_MESSAGE % wrapper_obj.name)
return

# Create the entry in the Exchange table.
Expand All @@ -66,12 +67,12 @@ def initialize_exchange_ledger(db, wrapper_obj):
try:
balance = wrapper_obj.get_balance()
except KeyError as e:
print NO_API_CREDENTIALS_ERR_MESSAGE % wrapper_obj.name
print e
print(NO_API_CREDENTIALS_ERR_MESSAGE % wrapper_obj.name)
print(e)
return
except Exception as e:
print UNKNOWN_ERR_MESSAGE % wrapper_obj.name
print e
print(UNKNOWN_ERR_MESSAGE % wrapper_obj.name)
print(e)
return

price_currency = wrapper_obj.currency
Expand Down
3 changes: 2 additions & 1 deletion gryphon/execution/lib/config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import ConfigParser

from gryphon.lib.logger import get_logger
Expand All @@ -6,7 +7,7 @@


def get_config_var(filepath, section, key):
print filepath
print(filepath)

config = ConfigParser.RawConfigParser()
config.read(filepath)
Expand Down
3 changes: 2 additions & 1 deletion gryphon/execution/live_runner.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import pyximport; pyximport.install()
from cdecimal import Decimal
import inspect
Expand Down Expand Up @@ -253,7 +254,7 @@ def live_run(configuration):
while True:
try:
tick_start = Delorean().epoch
print '\n\n%s' % strategy.name
print('\n\n%s' % strategy.name)

if warm_shutdown_flag:
return # This takes us into the finally block.
Expand Down
3 changes: 2 additions & 1 deletion gryphon/execution/scripts/itbit_auth_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This is a minimal script that demonstrates authentication on itbit. This is useful for
debugging if you ever run into issues with authenticating on itbit.
"""
from __future__ import print_function

import base64
import hashlib
Expand Down Expand Up @@ -59,5 +60,5 @@ def main(script_arguments, execute):

full_url = 'https://api.itbit.com/v1' + url

print requests.get(full_url, data=request_args).text
print(requests.get(full_url, data=request_args).text)

13 changes: 7 additions & 6 deletions gryphon/lib/analysis/legacy/average_true_range.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import numpy as np
from exponential_moving_average import ExpMovingAverage

Expand All @@ -12,9 +13,9 @@ def TR(d,c,h,l,o,yc):
y = abs(h-yc)
z = abs(l-yc)

print x
print y
print z
print(x)
print(y)
print(z)

if y <= x >= z:
TR = x
Expand All @@ -23,7 +24,7 @@ def TR(d,c,h,l,o,yc):
elif x <= z >= y:
TR = z

print d, TR
print(d, TR)
return d, TR

x = 1
Expand All @@ -39,7 +40,7 @@ def TR(d,c,h,l,o,yc):



print len(TrueRanges)
print(len(TrueRanges))
ATR = ExpMovingAverage(TrueRanges,14)

print ATR
print(ATR)
9 changes: 5 additions & 4 deletions gryphon/lib/analysis/legacy/chaikin_volatility.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import numpy as np
import time

Expand Down Expand Up @@ -32,18 +33,18 @@ def chaikinVolCalc(emaUsed,periodsAgo):
highMlow.append(hml)
x += 1

print len(date)
print len(highMlow)
print(len(date))
print(len(highMlow))
highMlowEMA = ExpMovingAverage(highMlow,emaUsed)
print len(highMlowEMA)
print(len(highMlowEMA))
y = emaUsed + periodsAgo

while y < len(date):
cvc = percentChange(highMlow[y-periodsAgo],highMlow[y])
chaikin_volatility.append(cvc)
y+=1

print len(date[emaUsed+periodsAgo:])
print(len(date[emaUsed+periodsAgo:]))

return date[emaUsed+periodsAgo:], chaikin_volatility

Expand Down
2 changes: 1 addition & 1 deletion gryphon/lib/analysis/legacy/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def graphData(stock,MA1,MA2):
plt.show()
fig.savefig('example.png',facecolor=fig.get_facecolor())

except Exception,e:
except Exception as e:
print 'main loop',str(e)

while True:
Expand Down
7 changes: 4 additions & 3 deletions gryphon/lib/analysis/legacy/ease_of_movement.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import numpy as np
import time

Expand Down Expand Up @@ -25,13 +26,13 @@ def EMV(d,c,h,l,o,v,tf):
boxr = ( (v[x]/1000000.00)/ (h[x]-l[x]) )
OnepEMVs = movement / boxr
OnepEMV.append(OnepEMVs)
print OnepEMVs
print(OnepEMVs)
x += 1

tfEMV = movingaverage(OnepEMV,tf)

print len(tfEMV)
print len(d[tf:])
print(len(tfEMV))
print(len(d[tf:]))

return d[tf:],tfEMV

Expand Down
3 changes: 2 additions & 1 deletion gryphon/lib/analysis/legacy/elder_force_index.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import numpy as np
import time

Expand All @@ -23,7 +24,7 @@ def EFI(d,c,v,tf):
x = 1
while x < len(d):
forceIndex = (c[x] - c[x-1]) * v[x]
print forceIndex
print(forceIndex)
efi.append(forceIndex)
x+=1
efitf = ExpMovingAverage(efi,tf)
Expand Down
3 changes: 2 additions & 1 deletion gryphon/lib/analysis/legacy/gapo.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import numpy as np
import time
import math
Expand All @@ -23,7 +24,7 @@ def GAPO(d,h,l,tf):
gapos = ( (math.log(HighestHigh - LowestLow)) /
math.log(tf))

print gapos
print(gapos)
gapo.append(gapos)
x+=1
return d[tf:],gapo
Expand Down
Loading