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

65
LINES

< > BotCompany Repo | #1036219 // IFuturesMarket - interface to a single market (e.g. ETHUSDT)

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

Transpiled version (11476L) is out of date.

interface IFuturesMarket {
  // all open/close orders are market right now (not limit)
  
  sclass OpenOrCloseOrder {
    // input parameters
    
    settable S clientOrderID; // optional
    
    settable HoldSide holdSide;
    settable double cryptoAmount;
    
    settable double leverage = 1;
    
    // Limit order if set. Otherwise market order.
    // Limit orders are good-until-cancel.
    // (unimplemented)
    settable double limitPrice = Double.NaN;
    
    // output parameters
    
    // order ID returned by platform
    settable S orderID;
  }
  
  macro ExtendingOpenOrCloseOrder {
    public selfType clientOrderID(S clientOrderID) { super.clientOrderID(clientOrderID); this; }
    public selfType holdSide(HoldSide holdSide) { super.holdSide(holdSide); this; }
    public selfType cryptoAmount(double cryptoAmount) { super.cryptoAmount(cryptoAmount); this; }
    public selfType leverage(double leverage) { super.leverage(leverage); this; }
    public selfType limitPrice(double limitPrice) { super.limitPrice(limitPrice); this; }
  }
  
  sclass OpenOrder extends OpenOrCloseOrder {
    ExtendingOpenOrCloseOrder
    settable bool isCross;
    
    settable double takeProfitPrice = Double.NaN;
    settable double stopLossPrice = Double.NaN;
  }
  
  sclass CloseOrder extends OpenOrCloseOrder {
    ExtendingOpenOrCloseOrder
  }
  
  // throws exception if order failed
  void openPosition(OpenOrder order);
  
  // throws exception if order failed
  void closePosition(CloseOrder order);
  
  sclass SwappableImplementation is IFuturesMarket {
    public swappable void openPosition(OpenOrder order) {}
    public swappable void closePosition(CloseOrder order) {}
    public swappable double drift() { unimplemented(); }
    public swappable FutureCoinParameters getCoinParameters() { unimplemented(); }
    public swappable bool anyOpenPositions() { unimplemented(); }
  }
  
  // Get current drift (sum of longs+shorts in crypto units)
  double drift();
  
  FutureCoinParameters getCoinParameters();
  
  bool anyOpenPositions();
}

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1036219
Snippet name: IFuturesMarket - interface to a single market (e.g. ETHUSDT)
Eternal ID of this version: #1036219/22
Text MD5: b3cb6d0b096ce7c03302718a163a2904
Author: stefan
Category: javax / trading
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2024-07-07 06:23:36
Source code size: 2127 bytes / 65 lines
Pitched / IR pitched: No / No
Views / Downloads: 1226 / 1368
Version history: 21 change(s)
Referenced in: [show references]