MCPcopy
hub / github.com/owocki/pytrader / get_exchange_rate_to_btc

Function get_exchange_rate_to_btc

history/tools.py:68–83  ·  view source on GitHub ↗
(ticker, d=None)

Source from the content-addressed store, hash-verified

66
67
68def get_exchange_rate_to_btc(ticker, d=None):
69 from history.models import Price
70
71 if d is None:
72 d = datetime.datetime.now()
73 if ticker == 'BTC':
74 return 1
75
76 try:
77 exchange_pair = 'BTC_' + ticker
78 latest_price = Price.objects.filter(symbol=exchange_pair, created_on__lt=d).order_by('-created_on').first()
79 return latest_price.price
80 except:
81 exchange_pair = ticker + '_BTC'
82 latest_price = Price.objects.filter(symbol=exchange_pair, created_on__lt=d).order_by('-created_on').first()
83 return 1.0 / latest_price.price
84
85
86def get_exchange_rate_btc_to_usd(d=None):

Callers 4

handleMethod · 0.90
get_deposit_balanceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected