Navigation: Trading Your System >

CSV Order Baskets

 

 

 

 

The Tomorrow's Orders feature produces an order list in a human-readable text format by default.

RealTest can optionally generate a machine-readable CSV order basket file instead, and lets you define the format using a template file.

This will, in most cases, be an easier and better way to generate a CSV-format order basket vs. building a Scan or TestScan.

To create a CSV order basket file, add the following (or something similar) to your TestSettings (note that there is not a way to do this using the Settings Panel):

When the test is run, the default text file list of tomorrow's orders will be not be displayed. Instead, the specified CSV file will be created and formatted using the specified template file. If you omit the OrdersFile specification, the default will be {RealTest folder}/Orders/{test_name}_{date}_orders.txt, where your actual test name and the current date are used. (You can add the current date to your own OrdersFile, or any RealTest output file, by including ?date? in your file path.)

An important consideration when using RealTest to generate a CSV order list is position sizing. Pick a StartDate that is as recent as possible while still allowing enough time to align the backtest with your actual positions. In other words, whatever your longest holding period is, you would need to start the test at least that many days ago. You would then also need to set the AccountSize setting to whatever your actual account value was on that start date. Even then, the position sizes shown in the order list will most likely not exactly match your live trading. It is always advisable to review and edit as needed the generated files before using them to submit orders.

The Examples folder in the RealTest installation directory includes two example CSV basket order template files: ib_basket_template.csv and chartist_api_template.csv. The first can be used to generate CSV order lists that IB Basket Trader can read, and the other will work with the automation "API" that Nick Radge sells as "The Chartist API".

The IB Basket template looks like this:

A CSV order list template file should have two rows. The first row will be used as the first (header) row of the output CSV file. The second row defines the fields to include in each order that is added to the list.

In the above example, all of the lower-case text values are special codes for field contents, and the upper-case values are literal constant strings to include.

Running the mr_sample.rts example script and using this template, the following order list is produced for 18-November-2000:

The test was started in January 2020 with $100K, so the position sizes reflect the theoretical equity growth from this test.

Notice how the entry limit orders are each given a unique order ID which the child target orders then use to identify their parents.

Comparing the template to the output should serve to clarify how this works. Strings in the second row of the template that match the ones in the following table are placeholders for specific elements of each order (action, quantity, price, etc.) All other strings in the second row are simply copied to every output row, as in the above example.

Here is the list of template field placeholder strings:

String

Description

act

order action (BUY or SELL)

sym

stock symbol

type

order type (MKT, LMT, STP, STP LMT)

qty

position size (shares)

qty0

position size (shares) for entry, 0 for exit

dlr

position size (dollars)

lmt

limit price

stp

stop price

tif

time-in-force (DAY, GAT, GTD, LOC, MOC)

gat

good-after-time time (e.g. 15:58:00 EST)

gtd

good-until-date time (e.g. 15:45:00 EST)

oca

OCA group (automatically added if both stop and limit exits are used)

id

order id (use when attaching target/stop exits to entry orders)

parent

parent order id (use when attaching target/stop exits to entry orders)

strat

strategy name (typically for the order reference field)

maxent

MaxEntries value (for The Chartist API "Max Fill" column)

exit

whether order is for an exit (1) vs. an entry (0)

If you require blank columns, simply add them to the header row but leave them blank in the second row of the template.

 

 

 

 

 

 

Copyright © 2020-2022 Systematic Solutions, LLC