interface IFuturesMarket { // all open/close orders are market right now (not limit) sclass OpenOrCloseOrder { settable S orderID; // optional, unimplemented settable HoldSide holdSide; settable double cryptoAmount; // Limit order if set. Otherwise market order. // Limit orders are good-until-cancel. // (unimplemented) settable double limitPrice = Double.NaN; // order ID returned by platform settable S orderID; } macro ExtendingOpenOrCloseOrder { public selfType holdSide(HoldSide holdSide) { super.holdSide(holdSide); this; } public selfType cryptoAmount(double cryptoAmount) { super.cryptoAmount(cryptoAmount); this; } public selfType limitPrice(double limitPrice) { super.limitPrice(limitPrice); this; } } sclass OpenOrder extends OpenOrCloseOrder { ExtendingOpenOrCloseOrder settable double leverage = 1; settable bool isCross; } 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 FutureCoinParameters getCoinParameters() { unimplemented(); } } // Get current drift (sum of longs+shorts in crypto units) double drift(); FutureCoinParameters getCoinParameters(); }