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.

concept G22PassiveTradingStrategy extends G22TradingStrategy {
  // A regular expression that will be used to match
  // the "strategy" field coming from TradingView to
  // distinguish this strategy from others on the same coin.
  settableWithVar S tradingViewRegexp;
  
  // If not 0, ths "PS" comment (position size) coming from
  // TradingView is evaluated.
  // tradingViewPSFactor == 100 => scale $100 in TradingView to our current equity
  // tradingViewPSFactor == 50 => scale $100 in TradingView to 50% of our current equity
  settableWithVar double tradingViewPSFactor;
  
  // Stop loss percentage assumed for riskPerTrade calculation (0 if not set)
  settableWithVar double assumedStopLoss;
  
  // If not 0, this is the assumed standard quantity of each
  // trade in the TradingView strategy. Then pyramiding will be
  // done using this value.
  settableWithVar double tradingViewStandardQty;
  
  // If not 0, positions will be opened proportional to those
  // in the TradingView strategy using this factor.
  // This overrides the other methods of determining position size.
  settableWithVar double tradingViewScalingFactor;
  
  settable bool remoteOpenable = true;
  settable bool remoteCloseable = true;
  
  void price(double price) {
    if (currentPrice == price) ret;
    currentPrice = price;
    afterStep(); change();
  }
  
  bool tradingViewMatch(S text) {
    ret empty(cleanedTradingViewRegexp())
      || safeRegexpFindIC(cleanedTradingViewRegexp(), text);
  }
  
  S cleanedTradingViewRegexp() {
    ret trim(tradingViewRegexp);
  }
  
  LS addPassiveTradingStatus(LS list) {
    if (nempty(tradingViewRegexp))
      list.add("TradingView regexp: " + cleanedTradingViewRegexp());
    ret list;
  }
  
  LS status() {
    ret addPassiveTradingStatus(super.status());
  }
  
  LS activationStatus() {
    ret addPassiveTradingStatus(super.activationStatus());
  }
  
  bool hasTradingViewPSFactor() {
    ret isNonZero(tradingViewPSFactor);
  }
}

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: 123 / 235
Version history: 21 change(s)
Referenced in: [show references]