Skip to content

Commit 89ba99a

Browse files
Use log instead of print.
1 parent 96dc442 commit 89ba99a

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

TurtleRules/__init__.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
99
In Turtle system theory, a complete trading system must cover several aspects, i.e.:
1010
- Markets - What to buy or sell
11-
ƒ - Position Sizing - How much to buy or sell
12-
ƒ - Entries - When to buy or sell
13-
ƒ - Stops - When to get out of a losing position
14-
ƒ - Exits - When to get out of a winning position
15-
ƒ - Tactics - How to buy or sell
11+
- Position Sizing - How much to buy or sell
12+
- Entries - When to buy or sell
13+
- Stops - When to get out of a losing position
14+
- Exits - When to get out of a winning position
15+
- Tactics - How to buy or sell
1616
1717
This Python module attempts to implement the system on Jesse framework as described in the pdf by Curtis Faith & Perry J. Kaufman.
1818
@@ -107,7 +107,7 @@ def go_long(self):
107107

108108
self.buy = qty, self.price
109109
self.stop_loss = qty, sl
110-
# print(f"enter long {qty}")
110+
# self.log(f"enter long {qty}")
111111
self.current_pyramiding_levels += 1 # Track the pyramiding level
112112
self.last_opened_price = self.price # Store this value to determine when to add next pyramiding
113113

@@ -117,7 +117,7 @@ def go_short(self):
117117

118118
self.sell = qty, self.price
119119
self.stop_loss = qty, sl
120-
# print(f"enter short {qty}")
120+
# self.log(f"enter short {qty}")
121121
self.current_pyramiding_levels += 1 # Track the pyramiding level
122122
self.last_opened_price = self.price # Store this value to determine when to add next pyramiding
123123

@@ -127,12 +127,12 @@ def update_position(self):
127127
if self.is_long and self.price > self.last_opened_price + (self.vars["pyramiding_threshold"] * self.atr):
128128
qty = self.unit_qty(self.vars["unit_risk_percent"])
129129
self.buy = qty, self.price
130-
# print(f"atr={self.atr}, last price={self.last_opened_price}, cur price={self.price}, action: increase long position {qty}")
130+
# self.log(f"atr={self.atr}, last price={self.last_opened_price}, cur price={self.price}, action: increase long position {qty}")
131131

132132
if self.is_short and self.price < self.last_opened_price - (self.vars["pyramiding_threshold"] * self.atr):
133133
qty = self.unit_qty(self.vars["unit_risk_percent"])
134134
self.sell = qty, self.price
135-
# print(f"atr={self.atr}, last price={self.last_opened_price}, cur price={self.price}, action: increase short position {qty}")
135+
# self.log(f"atr={self.atr}, last price={self.last_opened_price}, cur price={self.price}, action: increase short position {qty}")
136136

137137
# "Trades are exited on the fi rst occurrence of
138138
# a. The stop-loss
@@ -148,14 +148,14 @@ def on_increased_position(self, order):
148148
# This generally meant that all the stops for the entire position would be placed at 2 N from the most recently added unit." (Faith, 2003)
149149
if self.is_long:
150150
self.stop_loss = abs(self.position.qty), self.price - self.vars["atr_multiplier"] * self.atr
151-
# print(f"atr={self.atr}, current position sl: {self.average_stop_loss}")
151+
# self.log(f"atr={self.atr}, current position sl: {self.average_stop_loss}")
152152
if self.is_short:
153153
self.stop_loss = abs(self.position.qty), self.price + self.vars["atr_multiplier"] * self.atr
154-
# print(f"atr={self.atr}, current position sl: {self.average_stop_loss}")
154+
# self.log(f"atr={self.atr}, current position sl: {self.average_stop_loss}")
155155

156156
self.current_pyramiding_levels += 1
157157
self.last_opened_price = self.price
158-
# print(f"current pyramiding levels: {self.current_pyramiding_levels}")
158+
# self.log(f"current pyramiding levels: {self.current_pyramiding_levels}")
159159

160160
def on_stop_loss(self, order):
161161
# Reset tracked pyramiding levels
@@ -174,7 +174,7 @@ def filters(self):
174174

175175
def S1_filter(self):
176176
if self.vars["system_type"] == "S1" and self.last_was_profitable:
177-
# print(f"prev was profitable, do not enter trade")
177+
# self.log(f"prev was profitable, do not enter trade")
178178
self.last_was_profitable = False
179179
return False
180180
return True

0 commit comments

Comments
 (0)