Skip to content

Commit

Permalink
Removed deprecated code.
Browse files Browse the repository at this point in the history
  • Loading branch information
gbeced committed Apr 21, 2016
1 parent d0cdd41 commit 0b27d79
Show file tree
Hide file tree
Showing 17 changed files with 142 additions and 272 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Version 0.18 (TBD)
. [FIX] Fixed a bug in VWAP calculation when using adjusted values.
. [FIX] Added a way to change the dataseries.DEFAULT_MAX_LEN value.
. [BREAKING CHANGE] Removed Xignite support (http://www.xignite.com/).
. [BREAKING CHANGE] Removed deprecated code that issued warnings in previous versions.

Version 0.17 (10/May/2015)
. [NEW] Hurst exponent technical indicator (pyalgotrade.technical.hurst.HurstExponent).
Expand Down
27 changes: 0 additions & 27 deletions pyalgotrade/bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,33 +227,6 @@ def getClose(self, adjusted=False):
def getVolume(self):
return self.__volume

def getAdjOpen(self):
# Deprecated in 0.15
warninghelpers.deprecation_warning(
"The getAdjOpen method will be deprecated in the next version. "
"Please use the getOpen(True) instead.",
stacklevel=2
)
return self.getOpen(True)

def getAdjHigh(self):
# Deprecated in 0.15
warninghelpers.deprecation_warning(
"The getAdjHigh method will be deprecated in the next version. "
"Please use the getHigh(True) instead.",
stacklevel=2
)
return self.getHigh(True)

def getAdjLow(self):
# Deprecated in 0.15
warninghelpers.deprecation_warning(
"The getAdjLow method will be deprecated in the next version. "
"Please use the getLow(True) instead.",
stacklevel=2
)
return self.getLow(True)

def getAdjClose(self):
return self.__adjClose

Expand Down
5 changes: 0 additions & 5 deletions pyalgotrade/broker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,11 +553,6 @@ def submitOrder(self, order):
"""
raise NotImplementedError()

def placeOrder(self, order):
# Deprecated since v0.16
warninghelpers.deprecation_warning("placeOrder will be deprecated in the next version. Please use submitOrder instead.", stacklevel=2)
return self.submitOrder(order)

@abc.abstractmethod
def createMarketOrder(self, action, instrument, quantity, onClose=False):
"""Creates a Market order.
Expand Down
14 changes: 1 addition & 13 deletions pyalgotrade/broker/backtesting.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,10 @@ def getFillStrategy(self):
def getUseAdjustedValues(self):
return self.__useAdjustedValues

def setUseAdjustedValues(self, useAdjusted, deprecationCheck=None):
def setUseAdjustedValues(self, useAdjusted):
# Deprecated since v0.15
if not self.__barFeed.barsHaveAdjClose():
raise Exception("The barfeed doesn't support adjusted close values")
if deprecationCheck is None:
warninghelpers.deprecation_warning(
"setUseAdjustedValues will be deprecated in the next version. Please use setUseAdjustedValues on the strategy instead.",
stacklevel=2
)
self.__useAdjustedValues = useAdjusted

def getActiveOrders(self, instrument=None):
Expand All @@ -287,13 +282,6 @@ def getActiveOrders(self, instrument=None):
ret = [order for order in self.__activeOrders.values() if order.getInstrument() == instrument]
return ret

def getPendingOrders(self):
warninghelpers.deprecation_warning(
"getPendingOrders will be deprecated in the next version. Please use getActiveOrders instead.",
stacklevel=2
)
return self.getActiveOrders()

def _getCurrentDateTime(self):
return self.__barFeed.getCurrentDateTime()

Expand Down
19 changes: 1 addition & 18 deletions pyalgotrade/strategy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,6 @@ def marketOrder(self, instrument, quantity, onClose=False, goodTillCanceled=Fals
self.getBroker().submitOrder(ret)
return ret

def order(self, instrument, quantity, onClose=False, goodTillCanceled=False, allOrNone=False):
# Deprecated since v0.15
warninghelpers.deprecation_warning("The order method will be deprecated in the next version. Please use the marketOrder method instead.", stacklevel=2)
return self.marketOrder(instrument, quantity, onClose, goodTillCanceled, allOrNone)

def limitOrder(self, instrument, limitPrice, quantity, goodTillCanceled=False, allOrNone=False):
"""Submits a limit order.
Expand Down Expand Up @@ -406,11 +401,6 @@ def enterShortStopLimit(self, instrument, stopPrice, limitPrice, quantity, goodT

return pyalgotrade.strategy.position.ShortPosition(self, instrument, stopPrice, limitPrice, quantity, goodTillCanceled, allOrNone)

def exitPosition(self, position, stopPrice=None, limitPrice=None, goodTillCanceled=None):
# Deprecated since v0.13
warninghelpers.deprecation_warning("exitPosition will be deprecated in the next version. Please use the exit method in the position class instead.", stacklevel=2)
position.exit(limitPrice, stopPrice, goodTillCanceled)

def onEnterOk(self, position):
"""Override (optional) to get notified when the order submitted to enter a position was filled. The default implementation is empty.
Expand Down Expand Up @@ -602,7 +592,7 @@ def getUseAdjustedValues(self):

def setUseAdjustedValues(self, useAdjusted):
self.getFeed().setUseAdjustedValues(useAdjusted)
self.getBroker().setUseAdjustedValues(useAdjusted, True)
self.getBroker().setUseAdjustedValues(useAdjusted)
self.__useAdjustedValues = useAdjusted

def setDebugMode(self, debugOn):
Expand All @@ -611,10 +601,3 @@ def setDebugMode(self, debugOn):
level = logging.DEBUG if debugOn else logging.INFO
self.getLogger().setLevel(level)
self.getBroker().getLogger().setLevel(level)


class Strategy(BacktestingStrategy):
def __init__(self, *args, **kwargs):
# Deprecated since v0.13
warninghelpers.deprecation_warning("Strategy class will be deprecated in the next version. Please use BaseStrategy or BacktestingStrategy instead.", stacklevel=2)
super(Strategy, self).__init__(*args, **kwargs)
37 changes: 0 additions & 37 deletions pyalgotrade/strategy/position.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,6 @@ def getReturn(self, includeCommissions=True):
ret = self.__posTracker.getReturn(price, includeCommissions)
return ret

def getUnrealizedReturn(self, price=None):
# Deprecated in v0.15.
warninghelpers.deprecation_warning("getUnrealizedReturn will be deprecated in the next version. Please use getReturn instead.", stacklevel=2)
if price is not None:
raise Exception("Setting the price to getUnrealizedReturn is no longer supported")
return self.getReturn(False)

def getPnL(self, includeCommissions=True):
"""
Calculates PnL up to this point.
Expand All @@ -283,23 +276,6 @@ def getPnL(self, includeCommissions=True):
ret = self.__posTracker.getPnL(price=price, includeCommissions=includeCommissions)
return ret

def getNetProfit(self, includeCommissions=True):
# Deprecated in v0.15.
warninghelpers.deprecation_warning("getNetProfit will be deprecated in the next version. Please use getPnL instead.", stacklevel=2)
return self.getPnL(includeCommissions)

def getUnrealizedNetProfit(self, price=None):
# Deprecated in v0.15.
warninghelpers.deprecation_warning("getUnrealizedNetProfit will be deprecated in the next version. Please use getPnL instead.", stacklevel=2)
if price is not None:
raise Exception("Setting the price to getUnrealizedNetProfit is no longer supported")
return self.getPnL(False)

def getQuantity(self):
# Deprecated in v0.15.
warninghelpers.deprecation_warning("getQuantity will be deprecated in the next version. Please use abs(self.getShares()) instead.", stacklevel=2)
return abs(self.getShares())

def cancelEntry(self):
"""Cancels the entry order if its active."""
if self.entryActive():
Expand Down Expand Up @@ -374,19 +350,6 @@ def exitStopLimit(self, stopPrice, limitPrice, goodTillCanceled=None):

self.__state.exit(self, stopPrice, limitPrice, goodTillCanceled)

def exit(self, stopPrice=None, limitPrice=None, goodTillCanceled=None):
# Deprecated in v0.15.
if stopPrice is None and limitPrice is None:
warninghelpers.deprecation_warning("exit will be deprecated in the next version. Please use exitMarket instead.", stacklevel=2)
elif stopPrice is None and limitPrice is not None:
warninghelpers.deprecation_warning("exit will be deprecated in the next version. Please use exitLimit instead.", stacklevel=2)
elif stopPrice is not None and limitPrice is None:
warninghelpers.deprecation_warning("exit will be deprecated in the next version. Please use exitStop instead.", stacklevel=2)
elif stopPrice is not None and limitPrice is not None:
warninghelpers.deprecation_warning("exit will be deprecated in the next version. Please use exitStopLimit instead.", stacklevel=2)

self.__state.exit(self, stopPrice, limitPrice, goodTillCanceled)

def _submitExitOrder(self, stopPrice, limitPrice, goodTillCanceled):
assert(not self.exitActive())

Expand Down
3 changes: 0 additions & 3 deletions testcases/bar_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ def testGetPrice(self):
self.assertEquals(b.getPrice(), b.getClose())
b.setUseAdjustedValue(True)
self.assertEquals(b.getPrice(), b.getAdjClose())
self.assertEquals(b.getOpen(True), b.getAdjOpen())
self.assertEquals(b.getHigh(True), b.getAdjHigh())
self.assertEquals(b.getLow(True), b.getAdjLow())

def testPickle(self):
b1 = bar.BasicBar(datetime.datetime.now(), 2, 3, 1, 2.1, 10, 5, bar.Frequency.DAY)
Expand Down
4 changes: 2 additions & 2 deletions testcases/bitstamp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def onBars(self, bars):
if self.pos is None:
self.pos = self.enterLongLimit("BTC", 100, 1, True)
elif bars.getDateTime() == datetime.datetime(2000, 1, 3):
self.pos.exit(limitPrice=101)
self.pos.exitLimit(101)

barFeed = TestingLiveTradeFeed()
barFeed.addTrade(datetime.datetime(2000, 1, 1), 1, 100, 0.1)
Expand Down Expand Up @@ -323,7 +323,7 @@ def onBars(self, bars):
if self.pos is None:
self.pos = self.enterLongLimit("BTC", 100, 1, True)
elif bars.getDateTime() == datetime.datetime(2000, 1, 3):
self.pos.exit(limitPrice=101)
self.pos.exitLimit(101)

barFeed = TestingLiveTradeFeed()
barFeed.addTrade(datetime.datetime(2000, 1, 1), 1, 100, 0.1)
Expand Down
Loading

0 comments on commit 0b27d79

Please sign in to comment.