Class SimulatedExchange
- All Implemented Interfaces:
Exchange
This is not remotely suitable for use as a real-world exchange. The concurrency is extremely coarse-grained and most data transforms involve data mutation with no . If any errors occur midway through a trade, they are likely to leave the system in an inconsistent state. And nothing gets saved to a database anyway.
If you start using this for running a real exchange, you will suffer a stolen.
- Author:
- Graham Crockford
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
As withENGINE_FACTORY_PARAM
, provides a default unshared but optionally shared instance ofAccountFactory
.static final String
Allows the scope of the simulated exchange to be controlled.static final String
Provides aSimulatedExchangeOperationListener
.Fields inherited from class org.knowm.xchange.BaseExchange
accountService, exchangeMetaData, exchangeSpecification, logger, marketDataService, tradeService
Fields inherited from interface org.knowm.xchange.Exchange
USE_SANDBOX
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAn account service typically provides access to the user's private exchange dataA market data service typically consists of a regularly updated list of the available prices for the various symbolssi.mazi.rescu.SynchronizedValueFactory<Long>
The nonce factory used to create a nonce value.An trade service typically provides access to trading functionalityprotected void
void
Initialize this instance with the remote meta data.Methods inherited from class org.knowm.xchange.BaseExchange
applySpecification, getExchangeInstruments, getExchangeMetaData, getExchangeSpecification, getMetaDataFileName, loadExchangeMetaData, loadMetaData, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.knowm.xchange.Exchange
getResilienceRegistries
-
Field Details
-
ENGINE_FACTORY_PARAM
Allows the scope of the simulated exchange to be controlled. Pass toExchangeSpecification.setExchangeSpecificParametersItem(String, Object)
to choose one of:new MatchingEngineFactory()
- default. Each instance ofSimulatedExchange
works on a different virtual exchange with its own set of order books, thus the simulated exchange is single-user. Recommended for unit testing.- An existing, shared instance of
MatchingEngineFactory
- Create your own factory and share it betweenSimulatedExchange
instances to allow those specific instances to share the same order books and thus trade against each other. Recommended for integration testing.
- See Also:
-
ACCOUNT_FACTORY_PARAM
As withENGINE_FACTORY_PARAM
, provides a default unshared but optionally shared instance ofAccountFactory
.- See Also:
-
ON_OPERATION_PARAM
Provides aSimulatedExchangeOperationListener
.- See Also:
-
-
Constructor Details
-
SimulatedExchange
public SimulatedExchange()
-
-
Method Details
-
getNonceFactory
Description copied from interface:Exchange
The nonce factory used to create a nonce value. Allows services to accept a placeholder that is replaced with generated value just before message is serialized and sent. If a method of a rest accepts ValueFactory as a parameter, it's evaluated, the message is serialized and sent in a single synchronized block.- Specified by:
getNonceFactory
in interfaceExchange
- Overrides:
getNonceFactory
in classBaseExchange
- Returns:
- Synchronized value factory
-
getDefaultExchangeSpecification
- Returns:
- A default ExchangeSpecification to use during the creation process if one is not supplied
-
initServices
protected void initServices()- Specified by:
initServices
in classBaseExchange
-
remoteInit
Description copied from interface:Exchange
Initialize this instance with the remote meta data. Most exchanges require this method to be called beforeExchange.getExchangeMetaData()
. Some exchanges require it before using some of their services.- Specified by:
remoteInit
in interfaceExchange
- Overrides:
remoteInit
in classBaseExchange
- Throws:
IOException
ExchangeException
-
getMarketDataService
Description copied from interface:Exchange
A market data service typically consists of a regularly updated list of the available prices for the various symbolsThis is the non-streaming (blocking) version of the service
- Specified by:
getMarketDataService
in interfaceExchange
- Overrides:
getMarketDataService
in classBaseExchange
- Returns:
- The exchange's market data service
-
getAccountService
Description copied from interface:Exchange
An account service typically provides access to the user's private exchange dataTypically access is restricted by a secret API key and/or username password authentication which are usually provided in the
ExchangeSpecification
- Specified by:
getAccountService
in interfaceExchange
- Overrides:
getAccountService
in classBaseExchange
- Returns:
- The exchange's account service
-
getTradeService
Description copied from interface:Exchange
An trade service typically provides access to trading functionalityTypically access is restricted by a secret API key and/or username password authentication which are usually provided in the
ExchangeSpecification
- Specified by:
getTradeService
in interfaceExchange
- Overrides:
getTradeService
in classBaseExchange
- Returns:
- The exchange's trade service
-