Interesting. It uses a simple enough syntax for new users to understand yet could be very flexible and powerful for people familiar with JavaScript.
My original idea to use a trading logic in AidoATP kept things very simple by keeping everything boolean.....easy to understand logic and easy to code. A couple of months ago as part of a discussion with
daybyter I had toyed with developing a more comprehensive trading language using ANTLR.
It may be possible to use ANTLR to parse similar, more readable boolean logic from the config file or other file. This will then give the user more control over the use of the different trading algorithms rather than having it hardcoded.
I think daybyter tried to get some discussion started on a similar idea on a
Formal definition of a trading language but I'm not sure if it got off the ground.
But why create a whole new trading language syntax when something similar to a eclipsetraders JavaScript syntax can give a lot of power to experienced users but still be relatively simple for new users to pick up.
I agree, and it would be quite possible to have each Signal expose itself to the Javascript API.
BTW here is the way the new ATPx modular API works.
A module is a completely self contained mini-app, it implements runnable and has 0 or more dependencies.
Each instance runs a single ExchangeModule.
The ExchangeModule, among other things is responsible for listening to Ticks coming from the Exchange.
Every time a tick is captured, it passes the tick to a SignalManager. The signal manager's job is to record the tick to the DB and relay the tick to all subscribed signals.
A signal is a discrete unit of logic and is comprised of 3 elements, Direction, Amount and Intensity. For instance if the VWAP for BTC doubled in price, the signal would be VWAP|Advancing|100|1.0 (This was done to allow DSP's to more easily digest signal data).
Trading logic (aka individual trading modules or strategy modules in some parlances) subscribe to the individual signals it needs, notifying the signal of it's interest, and then is notified that a signal has changed through the trading logic's onSignalChanged method.
A javascript based trading logic module would just subscribe to all available signals and use onSignalChanged as its entry point.
VWAP cross then becomes a simple
function onSignalChanged{
val Object;
if(VWAP.Direction == Signal.Declining){
Object.Action = BUY;
Object.Amount = VWAP.Strength * Balance.USD;
}elseif(VWAP.Direction == Signal.Advancing){
Object.Action = Sell;
Object.Amount = VWAP.Strength * Balance.BTC;
}
return Object;
}
Of course Object here would be converted to an Order and then handed to the ExchangeModule, but that would be handled seamlessly in the background by the javascript trading logic module.
This would allow you to change trading logic on the fly fairly easily.
Thoughts?