Seer Event Execution Order

This topic contains 0 replies, has 1 voice, and was last updated by Seer Seer 7 years, 12 months ago.

Viewing 1 post (of 1 total)
  • Author
  • #612

    Begin, Bar and End Events

    The bar event is fired in response to a complete bar becoming available and is where all trading system logic is attached. The begin events are fired before any bar events, while the end events are fired after all bar events.

    The begin and end events are typically not used in most trading systems, but they are powerful ways to extend the functionality of your system.

    The begin is typically used to initialize any special variables or other constructs such as opening file handles, while the end event is used to perform house keeping tasks such as closing file handles and generating reports.

    In a backtesting environment, the begin event is fired soon after the backtesting button has been pressed, and the end event is fired just before the results tab is shown. Both the begin and end events are fired for each iteration of an optimizing run.

    In a automaric trading environment, where Seer is connected to a live stream of data, the begin event is fired when Seer starts the account (when the account is connected to the live stream), while the end event is fired when Seer stops – either when Seer exits or when the account is no longer associated with the data stream. You can use the begin/end events to store data structures that need to be saved/loaded between Seer incarnations.

    The OrderFill Event

    Unlike the Begin, Bar and End events, the OrderFill event is only triggered when an order is filled. The OrderFill event only fires when an order is filled and the OnFill parameter was set at the time the order was created. For more details on the OnFill parameter, see OnFill.

    There are many uses of OrderFill functionality. Perhaps the simplest use is the creation of stops as soon as an order has been filled. For example, say you have a system running at 10 minute bars, and you want to enter on a limit order. The limit order may or may not be filled in the next 10 minutes, but if it does, you’ll want to place a protective stop straight away and not wait until the next bar to place the order. Using the OnFill functionality allows you to run logic inside a bar event, enabling you to place a stop (which also may be filled before the next bar) as soon as the order is filled. The OrderFill functionality needs a parameter to be set when an order is placed:

    PlaceLimitOrder('Entry',100,26.50, OnFill => 1);

    The use of the OrderFill event enables programmatically control over the cancelling and placing of other orders. A more complex example is the building of bracket orders. A bracket order helps to limit your loss and help to lock in a profit by bracketing a position with two opposing orders. Once your initial long position is filled, your position would be bracketed by a sell limit order (on the high side) and a sell stop order (on the low side). Once either the stop or limit is filled, the OnFill event for those orders are fired allowing you to cancel the opposing order.

    Money Management Events

    Account begin, end and system begin, bar and end events are implicitly called by Seer, while Money Management Events are explicitly called by your code in the Bar event. Calling BuyOpen in the Bar event will call the BuyOpen event in the money management object.

    The Event flow for an Account with one System with one Symbol

    Event order flow of a single instrument (such as a stock or forex pair)

    In the above event flow, we have a single account, containing one system with one symbol in the portfolio. You’ll notice that you have both an account begin/end event as well as a system begin/end event. This allows you to attach and use system specific logic, as well as logic that applies to the whole account.

    The Event flow for an Account with one System and multiple Symbols

    Event order flow of multiple instruments (such as many stocks or multiple forex pairs)

    In the above event flow, we have a single account, containing one system with two symbols in the portfolio. Again, we have account begin/end events, but now we have two system begin events and two system end events. This is because the system begin/end event is fired for each symbol in the portfolio. For the bar event, each event is fired for the symbol in the order than it appeared in the portfolio.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.