Added Python 2.7.x and 3.4.x compatibility to the code. Disabled HTTPS security warning in urllib3 package of 'requests' package.

This commit is contained in:
Michael Halls-Moore
2015-05-11 17:30:28 +01:00
parent 8e74edb4f7
commit a03bc7a1fb
9 changed files with 67 additions and 39 deletions
+8 -6
View File
@@ -1,5 +1,5 @@
import datetime
from decimal import Decimal, ROUND_HALF_DOWN
from decimal import Decimal, getcontext, ROUND_HALF_DOWN
import os
import os.path
import time
@@ -59,12 +59,13 @@ class PriceHandler(object):
This will turn the bid/ask of "GBPUSD" into bid/ask for
"USDGBP" and place them in the prices dictionary.
"""
getcontext().rounding = ROUND_HALF_DOWN
inv_pair = "%s%s" % (pair[3:], pair[:3])
inv_bid = (Decimal("1.0")/bid).quantize(
Decimal("0.00001", ROUND_HALF_DOWN)
Decimal("0.00001")
)
inv_ask = (Decimal("1.0")/ask).quantize(
Decimal("0.00001", ROUND_HALF_DOWN)
Decimal("0.00001")
)
return inv_pair, inv_bid, inv_ask
@@ -129,16 +130,17 @@ class HistoricCSVPriceHandler(PriceHandler):
well as updating the current bid/ask and inverse bid/ask.
"""
try:
index, row = self.all_pairs.next()
index, row = next(self.all_pairs)
except StopIteration:
return
else:
getcontext().rounding = ROUND_HALF_DOWN
pair = row["Pair"]
bid = Decimal(str(row["Bid"])).quantize(
Decimal("0.00001", ROUND_HALF_DOWN)
Decimal("0.00001")
)
ask = Decimal(str(row["Ask"])).quantize(
Decimal("0.00001", ROUND_HALF_DOWN)
Decimal("0.00001")
)
# Create decimalised prices for traded pair