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
public class TradeServiceXChangeImplementation extends BaseService implements TradeService
Trade service - XChange implementation.
-
-
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
accountMapper, currencyMapper, logger, orderMapper, positionMapper, strategyMapper, tickerMapper, tradeMapper, utilMapper
-
-
Constructor Summary
Constructors Constructor Description TradeServiceXChangeImplementation(long rate, OrderRepository newOrderRepository, org.knowm.xchange.service.trade.TradeService newTradeService)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
cancelOrder(String orderId)
Cancel order.OrderCreationResultDTO
createBuyLimitOrder(GenericCassandreStrategy strategy, CurrencyPairDTO currencyPair, BigDecimal amount, BigDecimal limitPrice)
Creates a buy limit order.OrderCreationResultDTO
createBuyMarketOrder(GenericCassandreStrategy strategy, CurrencyPairDTO currencyPair, BigDecimal amount)
Creates a buy market order.OrderCreationResultDTO
createSellLimitOrder(GenericCassandreStrategy strategy, CurrencyPairDTO currencyPair, BigDecimal amount, BigDecimal limitPrice)
Creates a sell limit order.OrderCreationResultDTO
createSellMarketOrder(GenericCassandreStrategy strategy, CurrencyPairDTO currencyPair, BigDecimal amount)
Creates a sell market order.Set<OrderDTO>
getOrders()
Get orders from exchange.Set<TradeDTO>
getTrades()
Get trades from exchange.
-
-
-
Constructor Detail
-
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 Detail
-
createBuyMarketOrder
public OrderCreationResultDTO createBuyMarketOrder(GenericCassandreStrategy strategy, CurrencyPairDTO currencyPair, 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(GenericCassandreStrategy strategy, CurrencyPairDTO currencyPair, 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(GenericCassandreStrategy strategy, CurrencyPairDTO currencyPair, BigDecimal amount, 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(GenericCassandreStrategy strategy, CurrencyPairDTO currencyPair, BigDecimal amount, 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(String orderId)
Description copied from interface:TradeService
Cancel order.- Specified by:
cancelOrder
in interfaceTradeService
- Parameters:
orderId
- order id- Returns:
- true if cancelled
-
getOrders
public Set<OrderDTO> getOrders()
Description copied from interface:TradeService
Get orders from exchange.- Specified by:
getOrders
in interfaceTradeService
- Returns:
- list of orders
-
getTrades
public Set<TradeDTO> getTrades()
Description copied from interface:TradeService
Get trades from exchange.- Specified by:
getTrades
in interfaceTradeService
- Returns:
- list of orders
-
-