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(); }