move epl files to separate directory
This commit is contained in:
@ -50,12 +50,12 @@ distributions {
|
|||||||
main {
|
main {
|
||||||
contents {
|
contents {
|
||||||
into('csv') {
|
into('csv') {
|
||||||
from('.') {
|
from('csv') {
|
||||||
include 'EURUSD-2017-01-*.csv'
|
include 'EURUSD-2017-01-*.csv'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
into('epl') {
|
into('epl') {
|
||||||
from('.') {
|
from('epl') {
|
||||||
include '*.epl'
|
include '*.epl'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
111
epl/test.epl
Normal file
111
epl/test.epl
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
-- test.epl - sample setup
|
||||||
|
--
|
||||||
|
-- Statements must be separated by an empty line.
|
||||||
|
|
||||||
|
|
||||||
|
-- The time the trading logic will begin to enter trades.
|
||||||
|
-- Exiting trades is 24/7.
|
||||||
|
create constant variable int StartTimeHour = 9
|
||||||
|
|
||||||
|
-- The time the trading logic will begin to enter trades.
|
||||||
|
-- Exiting trades is 24/7.
|
||||||
|
create constant variable int EndTimeHour = 17
|
||||||
|
|
||||||
|
-- The time frame or tickbar count of the data to be analyzed or
|
||||||
|
-- traded. Examples: 5s, 1m, 1h 30m, 2h, 12h, 1d.
|
||||||
|
create constant variable string Interval = '2s'
|
||||||
|
|
||||||
|
-- Amount to be traded, measured in units.
|
||||||
|
create constant variable int TradeSize = 100000
|
||||||
|
|
||||||
|
-- How many ticks to use for simple moving average calculation
|
||||||
|
create constant variable int SMASize = 5
|
||||||
|
|
||||||
|
-- How many ticks to store for Ref() access
|
||||||
|
create constant variable int RefSize = 5
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Trading window
|
||||||
|
--
|
||||||
|
|
||||||
|
-- InTradingHours will be set to true when the current time is between
|
||||||
|
-- StartTime and EndTime.
|
||||||
|
create variable bool InTradingHours = false
|
||||||
|
|
||||||
|
-- Update on each tick
|
||||||
|
-- NOTE: see "timer:within" pattern for possible alternate formulation
|
||||||
|
on TickEvent as t set InTradingHours =
|
||||||
|
(EPLHelpers.getHour(t.time) >= StartTimeHour and
|
||||||
|
EPLHelpers.getHour(t.time) < EndTimeHour)
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- A stream of OHLC values calculated from TickEvents
|
||||||
|
--
|
||||||
|
|
||||||
|
create variant schema OneMinuteOHLCStream as OHLCEvent
|
||||||
|
|
||||||
|
insert into OneMinuteOHLCStream
|
||||||
|
select * from TickEvent#OHLC(Interval, time, midDouble)
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Simple moving average streams
|
||||||
|
--
|
||||||
|
|
||||||
|
-- Average the most recent OHLC close values and create events that
|
||||||
|
-- contain open, high, low, close and SMA(close). The number of
|
||||||
|
-- OHLC events used in the SMA calc is set by SMASize.
|
||||||
|
create schema SMACloseStream as ats.plugin.OHLCValueEvent
|
||||||
|
|
||||||
|
insert into SMACloseStream
|
||||||
|
select new ats.plugin.OHLCValueEvent(time, open, high, low, close, Avg(close))
|
||||||
|
from OneMinuteOHLCStream#length(SMASize)
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- ValueWhen calculations
|
||||||
|
--
|
||||||
|
|
||||||
|
-- A stream that feeds B1 and B2
|
||||||
|
create schema BStream as (low double)
|
||||||
|
|
||||||
|
-- Find a bar with a lower close than its neighbors.
|
||||||
|
-- Add that low value to the stream.
|
||||||
|
insert into BStream
|
||||||
|
select prev(1, low) as low from SMACloseStream#length(RefSize)
|
||||||
|
where prev(0, value) > prev(1, value)
|
||||||
|
and prev(1, value) < prev(2, value)
|
||||||
|
|
||||||
|
create schema B1 (low double)
|
||||||
|
|
||||||
|
insert into B1 select prev(0, low) as low
|
||||||
|
from BStream#length(RefSize)
|
||||||
|
|
||||||
|
create schema B2 (low double)
|
||||||
|
|
||||||
|
insert into B2 select prev(1, low) as low
|
||||||
|
from BStream#length(RefSize)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- A stream that feeds P1 and P2
|
||||||
|
create schema PStream as (low double)
|
||||||
|
|
||||||
|
-- Find a bar with a higher close than its neighbors.
|
||||||
|
-- Add that low value to the stream.
|
||||||
|
insert into PStream
|
||||||
|
select prev(1, low) as low from SMACloseStream#length(RefSize)
|
||||||
|
where prev(0, value) < prev(1, value)
|
||||||
|
and prev(1, value) > prev(2, value)
|
||||||
|
|
||||||
|
create schema P1 (low double)
|
||||||
|
|
||||||
|
insert into P1 select prev(0, low) as low
|
||||||
|
from PStream#length(RefSize)
|
||||||
|
|
||||||
|
create schema P2 (low double)
|
||||||
|
|
||||||
|
insert into P2 select prev(1, low) as low
|
||||||
|
from PStream#length(RefSize)
|
||||||
161
epl/trading_system_1.epl
Normal file
161
epl/trading_system_1.epl
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
-- test.epl - sample setup
|
||||||
|
--
|
||||||
|
-- Statements must be separated by an empty line.
|
||||||
|
|
||||||
|
|
||||||
|
-- The time the trading logic will begin to enter trades.
|
||||||
|
-- Exiting trades is 24/7.
|
||||||
|
create constant variable int StartTimeHour = 9
|
||||||
|
|
||||||
|
-- The time the trading logic will begin to enter trades.
|
||||||
|
-- Exiting trades is 24/7.
|
||||||
|
create constant variable int EndTimeHour = 17
|
||||||
|
|
||||||
|
-- The time frame or tickbar count of the data to be analyzed or
|
||||||
|
-- traded. Examples: 5s, 1m, 1h 30m, 2h, 12h, 1d.
|
||||||
|
create constant variable string Interval = '2s'
|
||||||
|
|
||||||
|
-- Amount to be traded, measured in units.
|
||||||
|
create constant variable int TradeSize = 100000
|
||||||
|
|
||||||
|
-- How many ticks to use for simple moving average calculation
|
||||||
|
create constant variable int SMASize = 5
|
||||||
|
|
||||||
|
-- How many ticks to store for Ref() access
|
||||||
|
create constant variable int RefSize = 5
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Trading window
|
||||||
|
--
|
||||||
|
|
||||||
|
-- InTradingHours will be set to true when the current time is between
|
||||||
|
-- StartTime and EndTime.
|
||||||
|
create variable bool InTradingHours = false
|
||||||
|
|
||||||
|
-- Update on each tick
|
||||||
|
-- NOTE: see "timer:within" pattern for possible alternate formulation
|
||||||
|
on TickEvent as t set InTradingHours =
|
||||||
|
(EPLHelpers.getHour(t.time) >= StartTimeHour and
|
||||||
|
EPLHelpers.getHour(t.time) < EndTimeHour)
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- A stream of OHLC values calculated from TickEvents
|
||||||
|
--
|
||||||
|
|
||||||
|
create variant schema OneMinuteOHLCStream as OHLCEvent
|
||||||
|
|
||||||
|
insert into OneMinuteOHLCStream
|
||||||
|
select * from TickEvent#OHLC(Interval, time, midDouble)
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Simple moving average streams
|
||||||
|
--
|
||||||
|
|
||||||
|
-- Average the most recent OHLC close values and create events that
|
||||||
|
-- contain open, high, low, close and SMA(close). The number of
|
||||||
|
-- OHLC events used in the SMA calc is set by SMASize.
|
||||||
|
create schema SMACloseStream as ats.plugin.OHLCValueEvent
|
||||||
|
|
||||||
|
insert into SMACloseStream
|
||||||
|
select new ats.plugin.OHLCValueEvent(time, open, high, low, close, Avg(close))
|
||||||
|
from OneMinuteOHLCStream#length(SMASize)
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- ValueWhen calculations
|
||||||
|
--
|
||||||
|
|
||||||
|
-- A stream that feeds B1 and B2
|
||||||
|
create schema BStream as (low double, time org.joda.time.DateTime)
|
||||||
|
|
||||||
|
-- Find a bar with a lower close than its neighbors.
|
||||||
|
-- Add that low value to the stream.
|
||||||
|
insert into BStream
|
||||||
|
select prev(1, low) as low, prev(1, time) as time from SMACloseStream#length(RefSize)
|
||||||
|
where prev(0, value) > prev(1, value)
|
||||||
|
and prev(1, value) < prev(2, value)
|
||||||
|
|
||||||
|
create schema B1 (low double, time org.joda.time.DateTime)
|
||||||
|
|
||||||
|
insert into B1 select prev(0, low) as low, prev(0, time) as time
|
||||||
|
from BStream#length(RefSize)
|
||||||
|
|
||||||
|
create schema B2 (low double, time org.joda.time.DateTime)
|
||||||
|
|
||||||
|
insert into B2 select prev(1, low) as low, prev(1, time) as time
|
||||||
|
from BStream#length(RefSize)
|
||||||
|
|
||||||
|
|
||||||
|
-- A stream that feeds P1 and P2
|
||||||
|
create schema PStream as (low double, time org.joda.time.DateTime)
|
||||||
|
|
||||||
|
-- Find a bar with a higher close than its neighbors.
|
||||||
|
-- Add that low value to the stream.
|
||||||
|
insert into PStream
|
||||||
|
select prev(1, low) as low, prev(1, time) as time from SMACloseStream#length(RefSize)
|
||||||
|
where prev(0, value) < prev(1, value)
|
||||||
|
and prev(1, value) > prev(2, value)
|
||||||
|
|
||||||
|
create schema P1 (low double, time org.joda.time.DateTime)
|
||||||
|
|
||||||
|
insert into P1 select prev(0, low) as low, prev(0, time) as time
|
||||||
|
from PStream#length(RefSize)
|
||||||
|
|
||||||
|
create schema P2 (low double, time org.joda.time.DateTime)
|
||||||
|
|
||||||
|
insert into P2 select prev(1, low) as low, prev(1, time) as time
|
||||||
|
from PStream#length(RefSize)
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Long entry
|
||||||
|
--
|
||||||
|
|
||||||
|
create schema LongEntryStream as (low double)
|
||||||
|
|
||||||
|
insert into LongEntryStream
|
||||||
|
select B1.low as low
|
||||||
|
from B1#lastevent, B2#lastevent, P1#lastevent, P2#lastevent
|
||||||
|
where B1.low < B2.low
|
||||||
|
and P1.low < P2.low
|
||||||
|
and EPLHelpers.laterThan(B1.time, P1.time)
|
||||||
|
and EPLHelpers.laterThan(B2.time, P2.time)
|
||||||
|
and EPLHelpers.laterThan(P1.time, B2.time)
|
||||||
|
|
||||||
|
-- LE = C > HHV(High,3)
|
||||||
|
-- and B1 < B2
|
||||||
|
-- and P1 < P2
|
||||||
|
-- and BT1 > PT1
|
||||||
|
-- and BT2 > PT2
|
||||||
|
-- and PT1 > BT2
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Event logging
|
||||||
|
--
|
||||||
|
|
||||||
|
create schema LogStream as (stream string, event string)
|
||||||
|
|
||||||
|
-- Enable logging specific stream events by uncommenting individual
|
||||||
|
-- lines below:
|
||||||
|
|
||||||
|
-- insert into LogStream select 'TickEvent' as stream, EPLHelpers.str(*) as event from TickEvent
|
||||||
|
|
||||||
|
-- insert into LogStream select 'OneMinuteOHLCStream' as stream, EPLHelpers.str(*) as event from OneMinuteOHLCStream
|
||||||
|
|
||||||
|
-- insert into LogStream select 'BStream' as stream, EPLHelpers.str(*) as event from BStream
|
||||||
|
|
||||||
|
-- insert into LogStream select 'PStream' as stream, EPLHelpers.str(*) as event from PStream
|
||||||
|
|
||||||
|
insert into LogStream select 'B1' as stream, EPLHelpers.str(*) as event from B1
|
||||||
|
|
||||||
|
insert into LogStream select 'B2' as stream, EPLHelpers.str(*) as event from B2
|
||||||
|
|
||||||
|
insert into LogStream select 'P1' as stream, EPLHelpers.str(*) as event from P1
|
||||||
|
|
||||||
|
insert into LogStream select 'P2' as stream, EPLHelpers.str(*) as event from P2
|
||||||
|
|
||||||
|
insert into LogStream select 'LongEntryStream' as stream, EPLHelpers.str(*) as event from LongEntryStream
|
||||||
70
test.epl
70
test.epl
@ -1,70 +0,0 @@
|
|||||||
-- test.epl - sample setup
|
|
||||||
--
|
|
||||||
-- Statements must be separated by an empty line.
|
|
||||||
|
|
||||||
|
|
||||||
-- The time the trading logic will begin to enter trades.
|
|
||||||
-- Exiting trades is 24/7.
|
|
||||||
create constant variable int StartTimeHour = 9
|
|
||||||
|
|
||||||
-- The time the trading logic will begin to enter trades.
|
|
||||||
-- Exiting trades is 24/7.
|
|
||||||
create constant variable int EndTimeHour = 17
|
|
||||||
|
|
||||||
-- The time frame or tickbar count of the data to be analyzed or
|
|
||||||
-- traded. Examples: 5s, 1m, 1h 30m, 2h, 12h, 1d.
|
|
||||||
create constant variable string Interval = '15s'
|
|
||||||
|
|
||||||
-- Amount to be traded, measured in units.
|
|
||||||
create constant variable int TradeSize = 100000
|
|
||||||
|
|
||||||
-- InTradingHours will be set to true if the current time is between
|
|
||||||
-- StartTime and EndTime.
|
|
||||||
create variable bool InTradingHours = false
|
|
||||||
|
|
||||||
-- Update on each tick
|
|
||||||
on TickEvent as t set InTradingHours =
|
|
||||||
(EPLHelpers.getHour(t.time) >= StartTimeHour and
|
|
||||||
EPLHelpers.getHour(t.time) < EndTimeHour)
|
|
||||||
|
|
||||||
-- A stream of OHLC values
|
|
||||||
create variant schema OHLCStream as OHLCEvent
|
|
||||||
|
|
||||||
insert into OHLCStream
|
|
||||||
select * from TickEvent#OHLC(Interval, time, midDouble)
|
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- testing/debug/WIP below
|
|
||||||
--
|
|
||||||
|
|
||||||
-- create window LongEntryTimeWindow#time(60 min) as
|
|
||||||
-- select * from LongEntryEvent
|
|
||||||
|
|
||||||
--
|
|
||||||
-- create window TicksTimeWindow#time(30 sec) as
|
|
||||||
-- select * from TickEvent
|
|
||||||
|
|
||||||
-- on TickEvent insert into TicksTimeWindow select * from TickEvent
|
|
||||||
|
|
||||||
-- on TickEvent as t merge TicksTimeWindow as win
|
|
||||||
-- where win.time
|
|
||||||
-- insert into OrdersWindow select * from MerchandiseProductEvent
|
|
||||||
-- set InTradingHours =
|
|
||||||
-- (EPLHelpers.getHour(t.time) >= StartTimeHour and
|
|
||||||
-- EPLHelpers.getHour(t.time) < EndTimeHour)
|
|
||||||
|
|
||||||
|
|
||||||
-- LECount = (1,clock,60 min) == only allow one long entry per clock hour example: one LE between 1:00pm to 1:59pm
|
|
||||||
|
|
||||||
-- B1 = ValueWhen( (ref(sma(5,c),-1)>ref(sma(5,c),-2)<ref(sma(5,c),-3)), Ref(Low,-2), 1 )
|
|
||||||
|
|
||||||
-- something like "insert into CountPerSec select count(*) as cnt from XYZ.win:time_batch(1)" "select sum(cnt) from CountPerSec.win:time(1 hour)" for example, this has 1 second resolution of counts, define as you like
|
|
||||||
|
|
||||||
-- 1) String stmt = "insert into WebEventTotalCount select count(*) as cnt from " +
|
|
||||||
-- "WebEvent.win:firstlength(1) A where A.page.pageName is not null ";
|
|
||||||
|
|
||||||
-- 2) String stmt = "update istream WebEventTotalCount set cnt = cnt + ( select count(*) as cnt from " +
|
|
||||||
-- "WebEvent.win:time(1) A where A.page.pageName is not null ) " ;
|
|
||||||
|
|
||||||
-- 3) String stmt = " select cnt from WebEventTotalCount ";
|
|
||||||
Reference in New Issue
Block a user