Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Stock Signals
#1
What are Signals?
Signals are used to create orders in the market and are sent by what we call Signal Providers (SPs). There are various types of signals that are tailored for specific purposes in order to allow customization of signals and prevent errors on the side of the SP and the user. This guide presents all the types of signals, how they are processed, and how to create them.

Further reading: Conditional Signals and Delayed Signals

Actions
The action specifies the purpose of the order and ensures that the current position can be properly changed by the order. Note that if the signal is not ignored as result of the action (see below for when a signal is ignored), then the signal will replace any existing order.

Buy To Open (BTO)
  • Signal to open a long position (i.e positive number of shares)
  • If the current position is not neutral, this signal will be ignored
Sell To Open (STO)
  • Signal to open a short position (i.e negative number of shares)
  • If the current position is not neutral, this signal will be ignored
Close (CLOSE)
  • Signal to entirely close a position, regardless of whether it is short or long
  • If the current position is neutral, it will cancel any existing orders
Sell To Close (STC)
  • Signal to entirely close a long position
  • If the current position is not long, this signal will be ignored
Buy To Close (BTC)
  • Signal to entirely close a short position
  • If the current position is not short, this signal will be ignored
Long  (LONG)
  • Signal to make the current position long
  • This will work even if the current position is short
Short (SHORT)
  • Signal to make the current position short
  • This will work even if the current position is long
Add to Long (ATL)
  • Signal to increase the current long position
  • If the current position is not long, this signal will be ignored
  • Requires a signal ID to be processed
Add to Short (ATS)
  • Signal to increase the current short position (i.e. go more short)
  • If the current position is not short, this signal will be ignored
  • Requires a signal ID to be processed
Subtract from Long (SFL)
  • Signal to decrease the current long position
  • If the current position is not long, this signal will be ignored
  • Requires a signal ID to be processed
Subtract from Short (SFS)
  • Signal to decrease the current short position (i.e. go less short)
  • If the current position is not short, this signal will be ignored
  • Requires a signal ID to be processed
Quantity and Units
The quantity is used to specify how much of a stock is bought. When a quantity is specified, the unit must also be specified. Note that when using CLOSE, STC, and BTC actions, you do not need to specify a quantity because those actions will close your entire position regardless.

Shares (SHARES)
  • Specifies the number of shares to buy
Dollars ($)
  • Specifies the total dollar value to be bought
Percent Portfolio (%PORTFOLIO)
  • Specifies that the total dollar value bought should be a percent of the portfolio/strategy allocation
Percent Position (%POSITION)
  • Specifies that the total dollar value bought should be a percent of the current position (this means if the current position is neutral, then the signal is ignored)
Percent Cash (%CASH)
  • Specifies that the total dollar value bought should be a percent of the current cash available to the strategy
  • Available cash is calculated as: strategy allocation - total exposure, where total exposure = (long exposure + short exposure)
  • Note that whatever asset you are purchasing will not be included in the total exposure calculation
  • For example, if strategy allocation is $10,000 and you are long $1,000 of AAPL, short $500 of IBM, and long $500 of SPY, then the signal
    LONG SPY 50 %CASH
    would see that total exposure is $1,500 (AAPL and IBM), so available cash is $10,000-$1,500 = $8,500. Therefore, we want to hold $8,500/2 = $4,250 of SPY, which means we need to BUY $3750 of SPY (since we already have $500)
  • This unit type may be confusing to understand at first, but it will make more sense as you read the rest of the documentation.
Percent Account Cash (%ACCTCASH)
  • Specifies that the total dollar value bought should be a percent of the current cash available to ALL your strategies
  • Available cash is calculated as: total allocation among all strategies - total account exposure, where total exposure = (long exposure + short exposure)
  • Note that whatever asset you are purchasing will not be included in the total exposure calculation
  • For example, if Strategy1 and Strategy2 each have allocation $10,000, and you are long $1,000 of AAPL, short $500 of IBM, and long $500 of SPY, then the signal
    LONG SPY 50 %ACCTCASH
    would see that total exposure is $1,500 (AAPL and IBM), so available cash is 2x$10,000-$1,500 = $18,500. Therefore, we want to hold $18,500/2 = $9,250 of SPY, which means we need to BUY $8750 of SPY (since we already have $500)
Custom Lots (LOTS)
  • Specifies that the unit to be used is whatever the user specified in the Custom Lot Size field in the strategy window.
  • Note that the Custom Lot Size field is limited to the Shares and Dollars as units.
Order Type
The order type is used to specify what kind of order is used to enter the market.
Note that some order types (such as MOO) might be automatically cancelled in PAPER trading accounts on Interactive Brokers, but will work correctly in LIVE accounts. You may want to use MKT orders for paper trading and then switch to MOO on your live account if you're having issues.

Market (MKT)
  • An order which will be executed at the current market price
Market on Close (MOC)
  • A market order that will be placed when the market closes
  • Note that these orders must be placed before 3:45pm EST, so your strategies must run before then
  • The advantage of these kinds of orders is that there is no spread (difference between bid and ask price) when the market closes
Market on Open (MOO)
  • A market order that will be placed when the market opens
  • Similar to MOC orders
  • Note that in Interactive Brokers these orders will appear as MKT orders with a Time in Force of OPG
Limit (LMT)
Limit on Close (LOC)
  • A limit order that will be placed when the market closes
  • Similar to the Market on Close order, this type of order must be placed before 3:45PM EST on most US exchanges
Limit on Open (LOO)
  • A limit order that will be placed when the market open
  • Similar to the Market on Open order, this type of order must be placed before 9:28AM EST on most US exchanges
Stop Market (STPMKT)
Stop Limit (STPLMT)
Limit If Touched (LIT)
Time in Force
The time in force specifies how long an order will stay in the market.

Day (DAY) - Day orders stay in the market until it closes. If they are not executed, then they are automatically removed.
Good 'Til Cancelled (GTC) - GTC orders stay in the market until they are executed or cancelled.
Good 'Til Date (GTD) - GTD orders stay in the market until the specified time. Format should be YYYYMMdd hh:mm:ss zzz where zzz is the timezone e.g. 20200108 15:30:00 EST
*NOTE* In order to get London time, you should use GMT as the timezone. In APM we include daylight savings time in GMT in order to give users a way to specify London time. If you don't want the adjusted time, you should use UTC as the timezone.

It is recommended to use DAY or GTD orders because there is no fee if they are not executed and automatically cancelled (whereas there is a cancellation fee for GTC orders).

Reference Market Price
When submitting market orders to APM there will be cases where APM needs the market price in order to compute order quantity. In these cases, APM will try to get the market price from the broker if possible, otherwise it will try to get the data from the data provider specified in your account settings (e.g. Yahoo). Sometimes the data provider may be down, and in those cases APM will not be able to compute order quantity, and therefore not be able to place certain types of market orders.

If you have a data provider, whose prices you'd prefer to use when placing orders, then you can specify the reference price you'd like to use in your signal instead of having APM look for that price itself. Note that if you're running a system where signals are processed in APM several hours after they are generated, then this reference price may not be practical because the price may not be accurate -- keep in mind however that the price does not need to be perfectly accurate since it is only used for computing quantity and some other non-critical values.

To specify a reference price you can add REF_PRICE <price> to the end of your signal. For example
LONG AAPL REF_PRICE 120.25

Signal ID
A signal ID is a positive integer that allows APM to identify duplicate orders and prevent them from causing potential issues. Most of the actions do not have issues with placing duplicate orders, so signal IDs are not required (although they are allowed) for these actions. However, some of the actions, namely ATL, SFL, ATS, and SFS, do not naturally prevent duplicate orders, so they require signal IDs.

The first signal ID can begin at 1 (not 0), and every ID after must be greater than the last. To reset signal IDs back to 1, the next signal ID must be 1 AND smaller than the last signal ID by at least 10,000 (this will ignore the normal rule for signal IDs).

Note that when no signal ID is specified, orders with the actions BTO, STO, CLOSE, STC, BTC, LONG, and SHORT will be placed even if other signals do have IDs.

Signal Structure
Signals must follow the format below in order for them to be processed correctly:

[Action] [Ticker] [Quantity Units] [Type Price] [Time in Force] [ID]

The Action is one of BTO, STO, CLOSE, STC, BTC, LONG, SHORT, ATL, ATS, SFL, SFS
The Ticker must be of a valid US stock, for example AAPL.
The Quantity must be a positive real number followed by one of the Units: $, SHARES, %PORTFOLIO, %POSITION, LOTS
The Type is one of MKT, MOC, MOO, LMT, LOC, LOO, STPLMT. The types LOC, LOO, LMT must be followed by a price. And STPLMT must be followed by two prices (the stop and limit)
The Time in Force is one of GTC and DAY.
The ID is of the form 'ID <number>' and specifies the signal ID.

Here are some example signals:

BTO AAPL
STO AAPL 100 SHARES DAY
LONG AAPL 1000 $
CLOSE AAPL
CLOSE AAPL LMT 230 GTC
LONG AAPL 10 %PORTFOLIO MKT
ATL AAPL 50 %POSITION LMT 200 DAY ID 20
ATL AAPL ID 30
LONG AAPL STPLMT 400 401 DAY
LONG AAPL LIT 200 195 DAY
LONG AAPL LMT 200 GTD 20200108 15:30:00 EST

The only mandatory fields are the Action and Ticker.
If the Quantity and Units are not specified, the system will use the user defined Custom Lot Size to determine the number of shares to trade.
This happens in the signals BTO AAPL and ATL AAPL ID 30.

Closing All Positions
You can send the following signal to place a CLOSE order for all symbols in your strategy.
CLOSE __ALL__

Creating and Processing Signals

File
A file with one signal per line can be processed by the 'Local File' Signal Provider. This file must end with a valid extension (.sig .sig.txt .sig.csv) and placed in the folder specified by the path on the status bar at the bottom of the APM window. Note that this folder is not created until the strategy is saved for the first time (i.e. it is not a 'new' strategy).
Set the Max Number of Positions field to limit the number of positions your strategy will take from the signal provider. If you do not need this field, then set it to a large value like 1000.

Try to run Order Preview to make sure that the signals are processed correctly. You can view any errors in the log tab if some signals are not processed as expected.
Note that once you run your strategy for real, the signal will be moved to the ProcessedSignals folder (which is also located at the path on the status bar).
This means you wont be able to run your strategy again because there won't be any signal files left to process (running Order Preview won't move your signal files).

Other Signal Types
Signals can also be created from stock screeners or be pulled from online.
Reply
#2
Regarding Close (CLOSE), what if my signal file contains QUANLTY but not exact position size quantity?
Will Alera close all position size, whatever the QUANTITY is?
Reply
#3
(09-28-2020, 08:57 PM)C0101 Wrote: Regarding Close (CLOSE), what if my signal file contains QUANLTY but not exact position size quantity?
Will Alera close all position size, whatever the QUANTITY is?

Yes, Alera ignores the quantity field for CLOSE orders and closes whatever quantity you have
Reply
#4
I got a error

[9/29/2020 2:12:02 PM][1002] [ ERROR] [ Signal.INVALID] Invalid quantity [ 135.911 %POSITION] for signal [ADBE,9/29/2020 2:11:00 PM,0.00,1.00,1.00,0.00,0.00,Short, 135.911 %POSITION,1.23,3.30,1]

What's wrong with [ 135.911 %POSITION]?

I want to use leverage. the leverage could range from 0 to 3, including fraction.
i.e. 5% or 300%
Reply
#5
(09-29-2020, 01:16 PM)C0101 Wrote: I got a error

[9/29/2020 2:12:02 PM][1002] [  ERROR] [      Signal.INVALID] Invalid quantity [ 135.911 %POSITION] for signal [ADBE,9/29/2020 2:11:00 PM,0.00,1.00,1.00,0.00,0.00,Short, 135.911 %POSITION,1.23,3.30,1]

What's wrong with 135.911 %POSITION]?

I want to use leverage. the leverage could range from 0 to 3, including fraction.
i.e. 5% or 300%

The QUANTITY and UNIT are different columns. So you would need to specify [135.911, %POSITION] with a comma:
[ADBE,9/29/2020 2:11:00 PM,0.00,1.00,1.00,0.00,0.00,Short, 135.911, %POSITION,1.23,3.30,1]

Make sure you also include a QUANTITY and UNIT column in your csv file header. 
Reply
#6
Hi, Alera sent MKT order even if my signal is LMT and price provided. Attached is my setting screenshot. Thank




Ticker,Date/Time,Buy,Sell,Short,Cover,CloseAll,Action,QUANTITY,UNIT,Type,Price,Sharpe,PositionScore,Rank(Sharpe)
GM,10/1/2020 11:14:00 AM,1.00,0.00,0.00,0.00,0.00,BTO,5,%PORTFOLIO,LMT,29.79,1.14,-10.84,1


Attached Files Thumbnail(s)
   
Reply
#7
(10-01-2020, 09:51 AM)C0101 Wrote: Hi, Alera sent MKT order even if my signal is LMT and price provided. Attached is my setting screenshot. Thank




Ticker,Date/Time,Buy,Sell,Short,Cover,CloseAll,Action,QUANTITY,UNIT,Type,Price,Sharpe,PositionScore,Rank(Sharpe)
GM,10/1/2020 11:14:00 AM,1.00,0.00,0.00,0.00,0.00,BTO,5,%PORTFOLIO,LMT,29.79,1.14,-10.84,1

The 'Price' column should be LIMIT instead. Please see https://aleratrading.com/forum/showthread.php?tid=55 for more details on CSV files.
Reply
#8
Do you mean it should be

Ticker,Date/Time,Buy,Sell,Short,Cover,CloseAll,Action,QUANTITY,UNIT,Type,Price,Sharpe,PositionScore,Rank(Sharpe)
GM,10/1/2020 11:14:00 AM,1.00,0.00,0.00,0.00,0.00,BTO,5,%PORTFOLIO,LIMIT,29.79,1.14,-10.84,1

OR
Ticker,Date/Time,Buy,Sell,Short,Cover,CloseAll,Action,QUANTITY,UNIT,Type,LIMIT,Sharpe,PositionScore,Rank(Sharpe)
GM,10/1/2020 11:14:00 AM,1.00,0.00,0.00,0.00,0.00,BTO,5,%PORTFOLIO,LMT,29.79,1.14,-10.84,1
Reply
#9
(10-05-2020, 02:37 PM)C0101 Wrote: Do you mean it should be

Ticker,Date/Time,Buy,Sell,Short,Cover,CloseAll,Action,QUANTITY,UNIT,Type,Price,Sharpe,PositionScore,Rank(Sharpe)
GM,10/1/2020 11:14:00 AM,1.00,0.00,0.00,0.00,0.00,BTO,5,%PORTFOLIO,LIMIT,29.79,1.14,-10.84,1

OR
Ticker,Date/Time,Buy,Sell,Short,Cover,CloseAll,Action,QUANTITY,UNIT,Type,LIMIT,Sharpe,PositionScore,Rank(Sharpe)
GM,10/1/2020 11:14:00 AM,1.00,0.00,0.00,0.00,0.00,BTO,5,%PORTFOLIO,LMT,29.79,1.14,-10.84,1

The second one
Reply
#10
(10-05-2021, 08:38 AM)hoanganhm81 Wrote: Is there a big difference between orders in forex and orders in stocks? visit https://m8winpro.com/ exchange about forex


We tried to make them very similar in APM. See https://aleratrading.com/forum/showthread.php?tid=128
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)