Skip to content

Commit 86ee66f

Browse files
committed
removing tickIndex, we don't need this variable
1 parent 7c97a80 commit 86ee66f

4 files changed

Lines changed: 4 additions & 10 deletions

File tree

include/strategies/randomStrategy.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ class RandomStrategy : public IStrategy {
5757
// is passed by mutable reference so future strategies (trailing
5858
// stops, partial closes, scale-ins) can act on open positions
5959
// here without changing the interface.
60-
void during(std::size_t tickValue,
61-
const PriceData& price,
60+
void during(const PriceData& price,
6261
TradeManager& tradeManager) override;
6362

6463
private:

include/strategies/strategy.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ class IStrategy {
5656
// analogue is just passing the manager as a parameter; C# has no
5757
// distinction between reference and pointer so the by-ref nature
5858
// is implicit there.
59-
virtual void during(std::size_t tickValue,
60-
const PriceData& price,
59+
virtual void during(const PriceData& price,
6160
TradeManager& tradeManager) = 0;
6261
};

source/operations.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ void Operations::run(const std::vector<PriceData>& ticks,
6464

6565
const auto& tradingVars = config.STRATEGY.TRADING_VARIABLES;
6666

67-
std::size_t tickIndex = 0;
6867
for (const auto& tick : ticks) {
6968

7069
// Close any trade whose stop-loss or take-profit fired on this tick
@@ -90,9 +89,7 @@ void Operations::run(const std::vector<PriceData>& ticks,
9089
// (e.g. trailing stops, partial closes). The default
9190
// RandomStrategy implementation is a no-op now that exits are
9291
// handled by reviewStopAndLimit above.
93-
strategy->during(tickIndex, tick, *tradeManager);
94-
95-
++tickIndex;
92+
strategy->during(tick, *tradeManager);
9693
}
9794

9895
std::cout << "Final PnL: " << std::fixed << std::setprecision(2) << tradeManager->calculatePnl() << std::endl;

source/strategies/randomStrategy.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ std::optional<Direction> RandomStrategy::decide(const PriceData& /*tick*/) {
2323
return coin(rng) ? Direction::LONG : Direction::SHORT;
2424
}
2525

26-
void RandomStrategy::during(std::size_t /*tickValue*/,
27-
const PriceData& /*price*/,
26+
void RandomStrategy::during(const PriceData& /*price*/,
2827
TradeManager& /*tradeManager*/) {
2928
// Exits are handled centrally by Operations using each trade's
3029
// stop-loss / take-profit pip distances. Strategies that want

0 commit comments

Comments
 (0)