Indicators is the one of widely used instruments for financial analysis. Almost each trading(manual or automated) platform has support of indicators. This article is our point of view on task how indicators should work inside application.
Preconditions for creation of separate component for indicators calculation:
- different trading rules may use the same indicators.
There situations even applying the same parameters. There is no point perform calculation of the same data from different places of application, if it can be done centrally. - calculating the value of the indicator is a painstaking task, in which involved mathematical operations and interaction with the repository(s) of historical information.
Unavoidable time delays that may adversely affect the productivity applications, when the same indicator used from different places of application
Possible architecture
Indicators service can be a separate thread(s) responsible for interaction with subscribers (registration of new requests for indicator calculation, issuance of the latest targeted data on demand, removal of the subscriber), working with repositories of historical data and the direct calculation.
Steps:
- Client sends a query, which indicates that it should expect an indicator H with parameters A, B, C. These actions can be performed, for example, the section Init of trading rules.
- Service adds a request and increases the count of subscribers. If it can not be register (for some reason) than throws the exception. Upon receipt of the exception system should block all accounts signed by given trading rule.
- With the arrival of market prices indicator service should calculate values according to subscription.
- To get latest calculated values of indicators, application should use interface, offered bu service. If request contains indicator or settings that were previously not register, service must return an exception. In handling this exceptional situation can be, depending on location, to register / subscribe to the indicator. As a result, following successful.
- Upon completion of work (for example, the account given by trading rule, was blocked) must submit a request to make a come-off.
Exceptions
- Error while registering a new request for calculation indicator
- Error treatment without subscription
- Error calculation indicator. Incorrect data
Original article locate here