trading_system_1.epl: deprecate use of CurrentTick

This commit is contained in:
2019-02-12 10:12:29 -08:00
parent 8ffed736da
commit bf69120753

View File

@ -41,11 +41,11 @@ create constant variable int RefSize = 5
-- Define the window as length 1, using the structure of the TickEvent -- Define the window as length 1, using the structure of the TickEvent
-- java class to describe what the window contains. -- java class to describe what the window contains.
create window CurrentTick#length(1) as TickEvent -- create window CurrentTick#length(1) as TickEvent
-- Describe how events get added to the window. This runs every time -- Describe how events get added to the window. This runs every time
-- a new TickEvent is posted. -- a new TickEvent is posted.
insert into CurrentTick select * from TickEvent -- insert into CurrentTick select * from TickEvent
-- --
@ -226,7 +226,7 @@ create schema LongEntryStream as (current BigDecimal, time DateTime, instrument
insert into LongEntryStream insert into LongEntryStream
select C.mid as current, C.time as time, C.instrument as instrument select C.mid as current, C.time as time, C.instrument as instrument
from CurrentTick as C, from TickEvent#lastevent as C,
MaxHigh3Window as T, MaxHigh3Window as T,
B1#lastevent, B2#lastevent, B1#lastevent, B2#lastevent,
P1#lastevent, P2#lastevent P1#lastevent, P2#lastevent
@ -328,19 +328,56 @@ create schema LongExitStream
-- or -- or
-- (LESBC>60 and C<(EntryPrice + 2 pips) -- (LESBC>60 and C<(EntryPrice + 2 pips)
insert into LongExitStream -- insert into LongExitStream
select C.mid as current, -- select C.mid as current,
C.time as time, -- C.time as time,
C.instrument as instrument, -- C.instrument as instrument,
0 - TradeSize as units -- negative for "sell" -- 0 - TradeSize as units -- negative for "sell"
from CurrentTick as C, -- from CurrentTick as C
LongEntryPreEntryBarPrevLow#lastevent as L -- where LongEntryStopBarCount = 2
where ((LongEntryStopBarCount <= 60 and C.mid < min(L.low, LongEntryPrice - (10 * PipSize))) or -- and InLongEntry
(LongEntryStopBarCount > 60 and C.mid < LongEntryPrice + (2 * PipSize)))
and InLongEntry -- where ((LongEntryStopBarCount <= 60 and C.mid < min(L.low, LongEntryPrice - (10 * PipSize))) or
-- (LongEntryStopBarCount > 60 and C.mid < LongEntryPrice + (2 * PipSize)))
-- Register the long position as closed -- Register the long position as closed
on LongExitStream as lx set InLongEntry = false -- on LongExitStream as lx set InLongEntry = false
-- Long exit event definition
create schema LongExitStream
as (id string)
-- Send an event whenever we should close an order.
-- Received and acted upon in EsperProcessor.
on TickEvent as C
insert into LongExitStream
select ot.id as id
from OrderTable ot
where ot.stopBarCount > 1 and ot.open is true
and ot.id is not 'dummy'
create schema OpenOrderStream
as (id string,
instrument String,
price BigDecimal,
units BigDecimal)
-- Add an order to the order table.
-- OpenOrderStream events are sent from Java TradingManagers.
on OpenOrderStream as oos
insert into OrderTable(id, time, instrument, price, units, open, stopBarCount)
select oos.id, EPLHelpers.makeTime(current_timestamp()), oos.instrument, oos.price, oos.units, true, 0
create schema CloseOrderStream
as (id string)
-- Add an order to the order table.
-- CloseOrderStream events are sent from Java TradingManagers.
on CloseOrderStream
update OrderTable
set OrderTable.open = false where OrderTable.id = CloseOrderStream.id
-- --