Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

61
LINES

< > BotCompany Repo | #1036557 // G22PassiveTradingStrategy

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (30496L) is out of date.

1  
concept G22PassiveTradingStrategy extends G22TradingStrategy {
2  
  // A regular expression that will be used to match
3  
  // the "strategy" field coming from TradingView to
4  
  // distinguish this strategy from others on the same coin.
5  
  settableWithVar S tradingViewRegexp;
6  
  
7  
  // If not 0, ths "PS" comment (position size) coming from
8  
  // TradingView is evaluated.
9  
  // tradingViewPSFactor == 100 => scale $100 in TradingView to our current equity
10  
  // tradingViewPSFactor == 50 => scale $100 in TradingView to 50% of our current equity
11  
  settableWithVar double tradingViewPSFactor;
12  
  
13  
  // Stop loss percentage assumed for riskPerTrade calculation (0 if not set)
14  
  settableWithVar double assumedStopLoss;
15  
  
16  
  // If not 0, this is the assumed standard quantity of each
17  
  // trade in the TradingView strategy. Then pyramiding will be
18  
  // done using this value.
19  
  settableWithVar double tradingViewStandardQty;
20  
  
21  
  // If not 0, positions will be opened proportional to those
22  
  // in the TradingView strategy using this factor.
23  
  // This overrides the other methods of determining position size.
24  
  settableWithVar double tradingViewScalingFactor;
25  
  
26  
  settable bool remoteOpenable = true;
27  
  settable bool remoteCloseable = true;
28  
  
29  
  void price(double price) {
30  
    if (currentPrice == price) ret;
31  
    currentPrice = price;
32  
    afterStep(); change();
33  
  }
34  
  
35  
  bool tradingViewMatch(S text) {
36  
    ret empty(cleanedTradingViewRegexp())
37  
      || safeRegexpFindIC(cleanedTradingViewRegexp(), text);
38  
  }
39  
  
40  
  S cleanedTradingViewRegexp() {
41  
    ret trim(tradingViewRegexp);
42  
  }
43  
  
44  
  LS addPassiveTradingStatus(LS list) {
45  
    if (nempty(tradingViewRegexp))
46  
      list.add("TradingView regexp: " + cleanedTradingViewRegexp());
47  
    ret list;
48  
  }
49  
  
50  
  LS status() {
51  
    ret addPassiveTradingStatus(super.status());
52  
  }
53  
  
54  
  LS activationStatus() {
55  
    ret addPassiveTradingStatus(super.activationStatus());
56  
  }
57  
  
58  
  bool hasTradingViewPSFactor() {
59  
    ret isNonZero(tradingViewPSFactor);
60  
  }
61  
}

Author comment

Began life as a copy of #1036351

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): elmgxqgtpvxh, mqqgnosmbjvj, wnsclhtenguj

No comments. add comment

Snippet ID: #1036557
Snippet name: G22PassiveTradingStrategy
Eternal ID of this version: #1036557/22
Text MD5: e99439675be940f815f89569c41e3d2c
Author: stefan
Category: javax / gazelle 22
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2024-01-04 21:54:11
Source code size: 2040 bytes / 61 lines
Pitched / IR pitched: No / No
Views / Downloads: 130 / 244
Version history: 21 change(s)
Referenced in: [show references]