diff --git a/portfolio/portfolio.py b/portfolio/portfolio.py index 2b12489..ea08242 100644 --- a/portfolio/portfolio.py +++ b/portfolio/portfolio.py @@ -16,7 +16,7 @@ class Portfolio(object): self.equity = equity self.balance = deepcopy(self.equity) 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 = {} def calc_risk_position_size(self): diff --git a/strategy/strategy.py b/strategy/strategy.py index 89cd890..2e432fe 100644 --- a/strategy/strategy.py +++ b/strategy/strategy.py @@ -10,9 +10,8 @@ class TestRandomStrategy(object): def calculate_signals(self, event): if event.type == 'TICK': self.ticks += 1 - if self.ticks == 2: + if self.ticks % 2 == 0: signal = SignalEvent(self.instrument, "market", "buy") - self.events.put(signal) - if self.ticks == 10: + else: signal = SignalEvent(self.instrument, "market", "sell") - self.events.put(signal) + self.events.put(signal) \ No newline at end of file diff --git a/trading/trading.py b/trading/trading.py index ab8a251..2187bf8 100644 --- a/trading/trading.py +++ b/trading/trading.py @@ -55,7 +55,7 @@ if __name__ == "__main__": # Create the portfolio object that will be used to # compare the OANDA positions with the local, to # ensure backtesting integrity. - portfolio = Portfolio(prices, events, equity=98505.02) + portfolio = Portfolio(prices, events, equity=98499.05) # Create the execution handler making sure to # provide authentication commands