Class TradeServiceXChangeImplementation
java.lang.Object
tech.cassandre.trading.bot.util.base.Base
tech.cassandre.trading.bot.util.base.service.BaseService
tech.cassandre.trading.bot.service.TradeServiceXChangeImplementation
- All Implemented Interfaces:
TradeService
Trade service - XChange implementation of
TradeService
.-
Field Summary
Fields inherited from class tech.cassandre.trading.bot.util.base.service.BaseService
bucket
Fields inherited from class tech.cassandre.trading.bot.util.base.Base
ACCOUNT_MAPPER, CANDLE_MAPPER, CURRENCY_MAPPER, logger, ORDER_MAPPER, POSITION_MAPPER, STRATEGY_MAPPER, TICKER_MAPPER, TRADE_MAPPER, UTIL_MAPPER
-
Constructor Summary
ConstructorDescriptionTradeServiceXChangeImplementation
(long rate, OrderRepository newOrderRepository, org.knowm.xchange.service.trade.TradeService newTradeService) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
cancelOrder
(long orderUid) Cancel order.createBuyLimitOrder
(@NonNull CassandreStrategyInterface strategy, @NonNull CurrencyPairDTO currencyPair, @NonNull BigDecimal amount, @NonNull BigDecimal limitPrice) Creates a buy limit order.createBuyMarketOrder
(@NonNull CassandreStrategyInterface strategy, @NonNull CurrencyPairDTO currencyPair, @NonNull BigDecimal amount) Creates a buy market order.createSellLimitOrder
(@NonNull CassandreStrategyInterface strategy, @NonNull CurrencyPairDTO currencyPair, @NonNull BigDecimal amount, @NonNull BigDecimal limitPrice) Creates a sell limit order.createSellMarketOrder
(@NonNull CassandreStrategyInterface strategy, @NonNull CurrencyPairDTO currencyPair, @NonNull BigDecimal amount) Creates a sell market order.Get orders from exchange.Get trades from exchange.
-
Constructor Details
-
TradeServiceXChangeImplementation
public TradeServiceXChangeImplementation(long rate, OrderRepository newOrderRepository, org.knowm.xchange.service.trade.TradeService newTradeService) Constructor.- Parameters:
rate
- rate in msnewOrderRepository
- order repositorynewTradeService
- market data service
-
-
Method Details
-
createBuyMarketOrder
public OrderCreationResultDTO createBuyMarketOrder(@NonNull @NonNull CassandreStrategyInterface strategy, @NonNull @NonNull CurrencyPairDTO currencyPair, @NonNull @NonNull BigDecimal amount) Description copied from interface:TradeService
Creates a buy market order.- Specified by:
createBuyMarketOrder
in interfaceTradeService
- Parameters:
strategy
- strategycurrencyPair
- currency pairamount
- amount- Returns:
- order result (order id or error)
-
createSellMarketOrder
public OrderCreationResultDTO createSellMarketOrder(@NonNull @NonNull CassandreStrategyInterface strategy, @NonNull @NonNull CurrencyPairDTO currencyPair, @NonNull @NonNull BigDecimal amount) Description copied from interface:TradeService
Creates a sell market order.- Specified by:
createSellMarketOrder
in interfaceTradeService
- Parameters:
strategy
- strategycurrencyPair
- currency pairamount
- amount- Returns:
- order result (order id or error)
-
createBuyLimitOrder
public OrderCreationResultDTO createBuyLimitOrder(@NonNull @NonNull CassandreStrategyInterface strategy, @NonNull @NonNull CurrencyPairDTO currencyPair, @NonNull @NonNull BigDecimal amount, @NonNull @NonNull BigDecimal limitPrice) Description copied from interface:TradeService
Creates a buy limit order.- Specified by:
createBuyLimitOrder
in interfaceTradeService
- Parameters:
strategy
- strategycurrencyPair
- currency pairamount
- amountlimitPrice
- the highest acceptable price- Returns:
- order result (order id or error)
-
createSellLimitOrder
public OrderCreationResultDTO createSellLimitOrder(@NonNull @NonNull CassandreStrategyInterface strategy, @NonNull @NonNull CurrencyPairDTO currencyPair, @NonNull @NonNull BigDecimal amount, @NonNull @NonNull BigDecimal limitPrice) Description copied from interface:TradeService
Creates a sell limit order.- Specified by:
createSellLimitOrder
in interfaceTradeService
- Parameters:
strategy
- strategycurrencyPair
- currency pairamount
- amountlimitPrice
- the lowest acceptable price- Returns:
- order result (order id or error)
-
cancelOrder
public boolean cancelOrder(long orderUid) Description copied from interface:TradeService
Cancel order.- Specified by:
cancelOrder
in interfaceTradeService
- Parameters:
orderUid
- order uid- Returns:
- true if cancelled
-
getOrders
Description copied from interface:TradeService
Get orders from exchange.- Specified by:
getOrders
in interfaceTradeService
- Returns:
- list of orders
-
getTrades
Description copied from interface:TradeService
Get trades from exchange.- Specified by:
getTrades
in interfaceTradeService
- Returns:
- list of trades
-