Reverted strategy to random buy/sell
This commit is contained in:
@@ -16,7 +16,7 @@ class Portfolio(object):
|
|||||||
self.equity = equity
|
self.equity = equity
|
||||||
self.balance = deepcopy(self.equity)
|
self.balance = deepcopy(self.equity)
|
||||||
self.risk_per_trade = risk_per_trade
|
self.risk_per_trade = risk_per_trade
|
||||||
self.trade_units = 100000#self.calc_risk_position_size()
|
self.trade_units = self.calc_risk_position_size()
|
||||||
self.positions = {}
|
self.positions = {}
|
||||||
|
|
||||||
def calc_risk_position_size(self):
|
def calc_risk_position_size(self):
|
||||||
|
|||||||
@@ -10,9 +10,8 @@ class TestRandomStrategy(object):
|
|||||||
def calculate_signals(self, event):
|
def calculate_signals(self, event):
|
||||||
if event.type == 'TICK':
|
if event.type == 'TICK':
|
||||||
self.ticks += 1
|
self.ticks += 1
|
||||||
if self.ticks == 2:
|
if self.ticks % 2 == 0:
|
||||||
signal = SignalEvent(self.instrument, "market", "buy")
|
signal = SignalEvent(self.instrument, "market", "buy")
|
||||||
self.events.put(signal)
|
else:
|
||||||
if self.ticks == 10:
|
|
||||||
signal = SignalEvent(self.instrument, "market", "sell")
|
signal = SignalEvent(self.instrument, "market", "sell")
|
||||||
self.events.put(signal)
|
self.events.put(signal)
|
||||||
+1
-1
@@ -55,7 +55,7 @@ if __name__ == "__main__":
|
|||||||
# Create the portfolio object that will be used to
|
# Create the portfolio object that will be used to
|
||||||
# compare the OANDA positions with the local, to
|
# compare the OANDA positions with the local, to
|
||||||
# ensure backtesting integrity.
|
# ensure backtesting integrity.
|
||||||
portfolio = Portfolio(prices, events, equity=98505.02)
|
portfolio = Portfolio(prices, events, equity=98499.05)
|
||||||
|
|
||||||
# Create the execution handler making sure to
|
# Create the execution handler making sure to
|
||||||
# provide authentication commands
|
# provide authentication commands
|
||||||
|
|||||||
Reference in New Issue
Block a user