-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathturtle.json
More file actions
1411 lines (1408 loc) · 47.2 KB
/
turtle.json
File metadata and controls
1411 lines (1408 loc) · 47.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
"configuration": {
/* The name of this trading system. */
"name": "turtle",
/* The folder that contains code files for custom transforms. */
"custom_transform_code_folder_path": "/media/data/backup/System_Studio_3_20210723/configuration/systems/turtle/",
/* This is for debugging pre system evaluation transforms. This can be ignored. */
"evaluate_pre_system_evaluation_transform_requests_only": false,
/* The folder that contains transform results so they don't have to be recalculated. This can be ignored. */
"transformed_data_output_folder_path": "/media/data/no_backup/ss_data/transformed_data",
},
"system_parameters": [
[
1,
/* Set the initial equity to $1 million. */
{
"name": "initial_equity",
"value": "1000000.0"
}
],
[
2,
/* Limit trading to 10% of the historical volume. */
{
"name": "volume_fraction",
"value": "0.1"
}
]
],
/* The folder that contains system evaluation results so they don't have to be recalculated. This can be ignored. */
"system_results_path": null,
/* These are custom transforms we want to calculate before we evaluate the system. For now, we don't have any. */
"pre_system_evaluation_custom_transform_requests": [],
/* These are predefined transforms we want to calculate before we evaluate the system. */
"pre_system_evaluation_predefined_transform_requests": [
{
/* This transform reads in raw futures contract files. This is a special transform. We will talk more about typical transforms in the comments on the next transform, continuous_contract. */
"name": "read_raw_contract_data",
"output_data_save_file_name": null,
"predefined_transform_type": "read_raw_contract_data",
/* Evaluate this transform first. */
"evaluation_order": 0,
"inputs": [],
"float_parameters": {},
"string_parameters": {
/* The folder where the raw futures contract files are stored. */
"raw_data_input_folder_path": "/media/data/no_backup/ss_data/raw_data",
/* The file name format of the raw futures contract files. For example, JY77H. */
"future_input_file_name_format": "([a-zA-Z]{2})([0-9]{2})(F|G|H|J|K|M|N|Q|U|V|X|Z).txt",
/* The date format used by the raw futures contract files. For example, 770131 (January 31, 1977). */
"future_input_date_time_format": "yyMMdd",
},
},
/* This denotes the start of a section we want to duplicate. The 1 means to use template variable group 1. In this case, we duplicate this section for each future.
We don't duplicate the read_raw_contract_data transform because it reads in the raw contract data for all futures.
*/
<<<1<
{
/* A typical transform has:
1. A name.
2. A type (predefined or custom).
3. If the transform is predefined, it has a predefined transform type, such as simple moving average.
4. An evaluation order. This is needed because some transforms input the output of other transforms.
5. Inputs. The transform converts these inputs into output.
6. Float parameters. These help determine the transform's behavior. For example, a simple moving average has a period.
7. String parameters. These help determine the transform's behavior.
An input for a predefined transform has:
1. A name.
2. Filters. These are used to make sure the transform only receives the input data it needs.
Each data item contains a set of tag name and value pairs. For example, a data item that represents the raw futures contract price data for a single date/time might have the following tag names and values:
future_name: JY
date_time: 01/30/1977
open: 34.63
high: 34.69
low: 34.64
close: 34.69
volume: 11
open interest: 219
We use these tags to filter data. For example, for a transform that only handles input data for the JY future, we filter for the tag name "future_name" and tag value "JY".
*/
/* This transform creates a continuous contract from raw futures contract data.
$future_name_lowercase! is a template variable that is replaced with, for example, jy or sf. */
"name": "$future_name_lowercase!_continuous_contract",
/* The file where we store transform results so they don't have to be recalculated. This can be ignored. */
"output_data_save_file_name": null,
/* The predefined type of this transform. */
"predefined_transform_type": "continuous_contract",
/* Evaluate this transform second, after the read_raw_contract_data transform. */
"evaluation_order": 1,
"inputs": [
{
/* Each predefined transform has a predefined set of inputs. */
"name": "data",
/* Filter the input data for the future name defined by the template variable. For example, JY. */
"filters": [
{
"Case": "Name_Value",
"Fields": [
{
"name": "future_name",
"value": "$future_name_uppercase"
}
]
}
]
}
],
"float_parameters": {
/* We use the data from the contract with the highest volume for a given date/time to create the continuous contract. To prevent excessive switching between contracts, we wait until another contract has a higher volume than our current contract for 4 straight days before we switch contracts. */
"switch_threshold": 4
},
"string_parameters": {},
},
{
/* This transform delays the data in the input stream by the specified number of days (in this case, one). We do this because we enter and exit trades on the open for each day, so we calculate most transforms with the input data delayed by one day. */
"name": "$future_name_lowercase!_delayed_1",
"output_data_save_file_name": null,
"predefined_transform_type": "delay",
/* Evaluate this transform after the continuous contract tranform. */
"evaluation_order": 2,
"inputs": [
{
"name": "data",
/* Filter the input data for the continuous contract for a single future. For example, jy_continuous_contract. */
"filters": [
{
"Case": "Name_Value",
"Fields": [
{
"name": "last_transform_applied",
"value": "$future_name_lowercase!_continuous_contract"
}
]
},
]
}
],
"float_parameters": {
/* Delay the data by one day. */
"period": 1
},
"string_parameters": {},
},
{
/* Create another delayed data stream, this time delayed by 2 days. We use this for the true range transform. */
"name": "$future_name_lowercase!_delayed_2",
"output_data_save_file_name": null,
"predefined_transform_type": "delay",
"evaluation_order": 3,
"inputs": [
{
"name": "data",
"filters": [
{
"Case": "Name_Value",
"Fields": [
{
"name": "last_transform_applied",
"value": "$future_name_lowercase!_continuous_contract"
}
]
},
]
}
],
"float_parameters": {
/* Delay the data by two days. */
"period": 2
},
"string_parameters": {},
},
/* This transform calculates the true range, which measures price volatility. */
{
"name": "$future_name_lowercase!_true_range",
"output_data_save_file_name": null,
"predefined_transform_type": "true_range",
"evaluation_order": 4,
"inputs": [
/* The true range is calculated using the high, low, and previous close. To calculate this transform for a given day, we need the high and low prices from the previous day's data, and the closing price from the day before that. So we provide two inputs: the data stream that we delayed by one day, and the data stream we delayed by two days. */
{
"name": "data",
"filters": [
{
"Case": "Name_Value",
"Fields": [
{
"name": "last_transform_applied",
"value": "$future_name_lowercase!_delayed_1"
}
]
},
]
},
{
/* "previous_data" is a predefined input for the true range transform. */
"name": "previous_data",
"filters": [
{
"Case": "Name_Value",
"Fields": [
{
"name": "last_transform_applied",
"value": "$future_name_lowercase!_delayed_2"
}
]
},
]
}
],
"float_parameters": {},
"string_parameters": {},
},
{
/* This transform calculates the exponential moving average. */
"name": "$future_name_lowercase!_trema",
"output_data_save_file_name": null,
"predefined_transform_type": "exponential_moving_average",
"evaluation_order": 5,
"inputs": [
{
"name": "data",
"filters": [
{
"Case": "Name_Value",
"Fields": [
{
"name": "last_transform_applied",
"value": "$future_name_lowercase!_true_range"
}
]
},
]
}
],
"float_parameters": {
/* The EMA period is a permutation variable. That is, we create a system permutation for each EMA period value (in this case, 20 and 21). */
"period": @ema_period
},
"string_parameters": {
/* Calculate the exponential moving average of the true range. */
"tag_name": "true_range",
},
},
{
/* This transform calculates the high price for the previous n days. We use this to determine when to enter long positions or exit short ones. */
"name": "$future_name_lowercase!_high",
"output_data_save_file_name": null,
"predefined_transform_type": "n_period_high",
"evaluation_order": 6,
"inputs": [
{
"name": "data",
"filters": [
{
"Case": "Name_Value",
"Fields": [
{
"name": "last_transform_applied",
"value": "$future_name_lowercase!_delayed_1"
}
]
},
]
}
],
"float_parameters": {
/* Get the high price for the last 20 days. */
"period": 20,
},
"string_parameters": {
/* Get the highest closing price for the previous n days. */
"tag_name": "price_close",
},
},
/* This transform calculates the low price for the previous n days. We use this to determine when to exit long positions or enter short ones. */
{
"name": "$future_name_lowercase!_low",
"output_data_save_file_name": null,
"predefined_transform_type": "n_period_low",
"evaluation_order": 7,
"inputs": [
{
"name": "data",
"filters": [
{
"Case": "Name_Value",
"Fields": [
{
"name": "last_transform_applied",
"value": "$future_name_lowercase!_delayed_1"
}
]
},
]
}
],
"float_parameters": {
/* Get the low price for the last 20 days. */
"period": 20,
},
"string_parameters": {
/* Get the lowest closing price for the previous n days. */
"tag_name": "price_close"
},
},
/* This denotes the end of the section to duplicate. */
>>>
],
/* These are transforms we must calculate while evaluating the system, because they depend on system evaluation data. All such transforms are custom transforms. */
"during_system_evaluation_transform_requests": [
/* Duplicate these transforms for each future. */
<<<1<
{
/* A typical custom transform has:
1. A name.
2. A code file. This contains the function that tells the transform how to calculate the output.
3. An evaluation order.
4. Inputs.
5. Float parameters.
6. String parameters.
An input for a custom transform has:
1. A name.
2. Filters. These are used to make sure the transform only receives the input data it needs.
3. Tags to extract. These determine what values to extract from the input data. Each value is then assigned a name before it is passed to the transform function.
4. Tags to copy to output. These determine what tag names and values to copy from the input stream to the output stream. This helps with filtering the output data for later transforms.
*/
/* This transform determines when to enter a long position. We must calculate it while evaluating the system because it must take currently open trades into account. */
"name": "$future_name_lowercase!_long_entry",
/* This is a custom transform, so it has a code file. */
"code_file": "long_entry.txt",
"evaluation_order": 0,
/* This transform takes the following inputs.
c: The closing price for the previous day.
high: The n-period high closing price for the previous day.
trema: The exponential moving average of the true range (TREMA) for the previous day.
*/
"inputs": [
{
"name": "c",
"filters": [
{
"Case": "Name_Value",
"Fields": [
{
"name": "last_transform_applied",
"value": "$future_name_lowercase!_delayed_1"
}
]
},
],
/* Extract the closing price for the previous day. */
"tags_to_extract": [
{
"tag_name": "price_close",
"name_to_assign": "c"
}
],
/* In this case, we don't need to copy any specific tags from the input stream to the output stream. */
"tags_to_copy_to_output": [],
/* This setting copies certain tags from the input stream to the output stream, to help with filtering the output data for later transforms. In general, this should be set to true for the first input to each custom transform, and false for the remaining inputs. */
"copy_series_tags_to_output": true,
/* When copy_series_tags_to_output is set to true, this setting overwrites existing data in the output stream. In general, this should be set to false. */
"copy_series_tags_to_output_allow_overwrite": false
},
{
/* This is the n-period high closing price for the previous day. */
"name": "high",
/* We need to filter the input data so that the last transform applied was the n-period high.
*/
"filters": [
{
"Case": "Name_Value",
"Fields": [
{
"name": "last_transform_applied",
"value": "$future_name_lowercase!_high"
}
]
},
],
/* Extract the n-period high for the previous day. */
"tags_to_extract": [
{
"tag_name": "n_period_high",
"name_to_assign": "high"
}
],
"tags_to_copy_to_output": [],
"copy_series_tags_to_output": false,
"copy_series_tags_to_output_allow_overwrite": false
},
{
/* This is the TREMA for the previous day. */
"name": "trema",
/* We need to filter the input data for two things:
1. The last transform applied was the TREMA for this future.
2. The period used for the TREMA for the current system permutation.
*/
"filters": [
{
"Case": "Name_Value",
"Fields": [
{
"name": "last_transform_applied",
"value": "$future_name_lowercase!_trema"
}
]
},
{
"Case": "Name_Value",
"Fields": [
{
"name": "exponential_moving_average_period",
"value": "@ema_period"
}
]
},
],
/* Extract the TREMA for the previous day. */
"tags_to_extract": [
{
"tag_name": "exponential_moving_average",
"name_to_assign": "trema"
}
],
"tags_to_copy_to_output": [],
"copy_series_tags_to_output": false,
"copy_series_tags_to_output_allow_overwrite": false
}
],
/* This custom transform needs to know the ID of the first long position for the current future. This is a template variable. */
"float_parameters": {
"position_id_start": $long_position_id_start,
},
"string_parameters": {},
},
/* This transform determines when to exit a long position. It is similar to the transform that determines when to enter a long position, in terms of inputs and so on. */
{
"name": "$future_name_lowercase!_long_exit",
"code_file": "long_exit.txt",
"evaluation_order": 0,
"inputs": [
{
"name": "c",
"filters": [
{
"Case": "Name_Value",
"Fields": [
{
"name": "last_transform_applied",
"value": "$future_name_lowercase!_delayed_1"
}
]
},
],
"tags_to_extract": [
{
"tag_name": "price_close",
"name_to_assign": "c"
}
],
"tags_to_copy_to_output": [],
"copy_series_tags_to_output": true,
"copy_series_tags_to_output_allow_overwrite": false,
},
{
"name": "low",
"filters": [
{
"Case": "Name_Value",
"Fields": [
{
"name": "last_transform_applied",
"value": "$future_name_lowercase!_low"
}
]
},
],
"tags_to_extract": [
{
"tag_name": "n_period_low",
"name_to_assign": "low"
}
],
"tags_to_copy_to_output": [],
"copy_series_tags_to_output": false,
"copy_series_tags_to_output_allow_overwrite": false,
},
{
"name": "trema",
"filters": [
{
"Case": "Name_Value",
"Fields": [
{
"name": "last_transform_applied",
"value": "$future_name_lowercase!_trema"
}
]
},
{
"Case": "Name_Value",
"Fields": [
{
"name": "exponential_moving_average_period",
"value": "@ema_period"
}
]
},
],
"tags_to_extract": [
{
"tag_name": "exponential_moving_average",
"name_to_assign": "trema"
}
],
"tags_to_copy_to_output": [],
"copy_series_tags_to_output": false,
"copy_series_tags_to_output_allow_overwrite": false
}
],
"float_parameters": {
"position_id_start": $long_position_id_start,
},
"string_parameters": {},
},
/* This transform determines when to enter a short position. It is similar to the transform that determines when to enter a long position, in terms of inputs and so on. */
{
"name": "$future_name_lowercase!_short_entry",
"code_file": "short_entry.txt",
"evaluation_order": 0,
"inputs": [
{
"name": "c",
"filters": [
{
"Case": "Name_Value",
"Fields": [
{
"name": "last_transform_applied",
"value": "$future_name_lowercase!_delayed_1"
}
]
},
],
"tags_to_extract": [
{
"tag_name": "price_close",
"name_to_assign": "c"
}
],
"tags_to_copy_to_output": [],
"copy_series_tags_to_output": true,
"copy_series_tags_to_output_allow_overwrite": false
},
{
"name": "low",
"filters": [
{
"Case": "Name_Value",
"Fields": [
{
"name": "last_transform_applied",
"value": "$future_name_lowercase!_low"
}
]
},
],
"tags_to_extract": [
{
"tag_name": "n_period_low",
"name_to_assign": "low"
}
],
"tags_to_copy_to_output": [],
"copy_series_tags_to_output": false,
"copy_series_tags_to_output_allow_overwrite": false
},
{
"name": "trema",
"filters": [
{
"Case": "Name_Value",
"Fields": [
{
"name": "last_transform_applied",
"value": "$future_name_lowercase!_trema"
}
]
},
{
"Case": "Name_Value",
"Fields": [
{
"name": "exponential_moving_average_period",
"value": "@ema_period"
}
]
},
],
"tags_to_extract": [
{
"tag_name": "exponential_moving_average",
"name_to_assign": "trema"
}
],
"tags_to_copy_to_output": [],
"copy_series_tags_to_output": false,
"copy_series_tags_to_output_allow_overwrite": false
}
],
"float_parameters": {
"position_id_start": $short_position_id_start,
},
"string_parameters": {},
},
/* This transform determines when to exit a short position. It is similar to the transform that determines when to enter a long position, in terms of inputs and so on. */
{
"name": "$future_name_lowercase!_short_exit",
"code_file": "short_exit.txt",
"evaluation_order": 0,
"inputs": [
{
"name": "c",
"filters": [
{
"Case": "Name_Value",
"Fields": [
{
"name": "last_transform_applied",
"value": "$future_name_lowercase!_delayed_1"
}
]
},
],
"tags_to_extract": [
{
"tag_name": "price_close",
"name_to_assign": "c"
}
],
"tags_to_copy_to_output": [],
"copy_series_tags_to_output": true,
"copy_series_tags_to_output_allow_overwrite": false
},
{
"name": "high",
"filters": [
{
"Case": "Name_Value",
"Fields": [
{
"name": "last_transform_applied",
"value": "$future_name_lowercase!_high"
}
]
},
],
"tags_to_extract": [
{
"tag_name": "n_period_high",
"name_to_assign": "high"
}
],
"tags_to_copy_to_output": [],
"copy_series_tags_to_output": false,
"copy_series_tags_to_output_allow_overwrite": false,
},
{
"name": "trema",
"filters": [
{
"Case": "Name_Value",
"Fields": [
{
"name": "last_transform_applied",
"value": "$future_name_lowercase!_trema"
}
]
},
{
"Case": "Name_Value",
"Fields": [
{
"name": "exponential_moving_average_period",
"value": "@ema_period"
}
]
},
],
"input_name": "trema",
"tags_to_extract": [
{
"tag_name": "exponential_moving_average",
"name_to_assign": "trema"
}
],
"tags_to_copy_to_output": [],
"copy_series_tags_to_output": false,
"copy_series_tags_to_output_allow_overwrite": false
}
],
"float_parameters": {
"position_id_start": $short_position_id_start,
},
"string_parameters": {},
},
>>>
],
/* Position inputs contain the information used to determine when to enter or exit positions and to calculate the profits/losses on trades for each position. */
"position_inputs": [
/* Duplicate these position inputs for each future. */
<<<1<
{
/* This input contains the price data for a single future. */
"id": $price_input_id,
"name": "input_$future_name_lowercase",
"type_": {
/* This input contains price data. */
"Case": "Price"
},
/* We need to filter the input data so that the last transform applied was the continuous contract for this future.
*/
"filters": [
{
"Case": "Name_Value",
"Fields": [
{
"name": "last_transform_applied",
"value": "$future_name_lowercase!_continuous_contract"
}
]
},
]
},
{
/* This input contains the exponential moving average of the true range (TREMA) for this future. We use this when we open a trade for a position, to determine the trade size. */
"id": $trema_input_id,
"name": "$future_name_lowercase!_trema",
"type_": {
/* This input comes from a pre system evaluation transform. */
"Case": "Before_System_Evaluation_Transform"
},
/* We need to filter the input data for two things:
1. The last transform applied was the TREMA for this future.
2. The period used for the TREMA for the current system permutation.
*/
"filters": [
{
"Case": "Name_Value",
"Fields": [
{
"name": "last_transform_applied",
"value": "$future_name_lowercase!_trema"
}
]
},
{
"Case": "Name_Value",
"Fields": [
{
"name": "exponential_moving_average_period",
"value": "@ema_period"
}
]
},
]
},
{
/* This input contains the long position entry signal. */
"id": $long_entry_input_id,
"name": "$future_name_lowercase long_entry signal",
"type_": {
/* The long position entry signal comes from a during system evaluation transform. */
"Case": "During_System_Evaluation_Transform"
},
/* We need to filter the input data so that the last transform applied was the custom transform that determines when to enter a long position. */
"filters": [
{
"Case": "Name_Value",
"Fields": [
{
"name": "last_transform_applied",
"value": "$future_name_lowercase!_long_entry"
}
]
},
]
},
/* This input contains the long position exit signal. It is similar to the input for the long position entry signal. */
{
"id": $long_exit_input_id,
"name": "$future_name_lowercase long_exit signal",
"type_": {
"Case": "During_System_Evaluation_Transform"
},
"filters": [
{
"Case": "Name_Value",
"Fields": [
{
"name": "last_transform_applied",
"value": "$future_name_lowercase!_long_exit",
}
]
},
]
},
/* This input contains the short position entry signal. It is similar to the input for the long position entry signal. */
{
"id": $short_entry_input_id,
"name": "$future_name_lowercase short_entry signal",
"type_": {
"Case": "During_System_Evaluation_Transform"
},
"filters": [
{
"Case": "Name_Value",
"Fields": [
{
"name": "last_transform_applied",
"value": "$future_name_lowercase!_short_entry"
}
]
},
]
},
/* This input contains the short position exit signal. It is similar to the input for the long position entry signal. */
{
"id": $short_exit_input_id,
"name": "$future_name_lowercase short_exit signal",
"type_": {
"Case": "During_System_Evaluation_Transform"
},
"filters": [
{
"Case": "Name_Value",
"Fields": [
{
"name": "last_transform_applied",
"value": "$future_name_lowercase!_short_exit"
}
]
},
]
},
>>>
],
/* Position money management inputs contain the information we use to determine the sizes of trades. */
"position_money_management_function_inputs": [
/* Duplicate this input for each future. */
<<<1<
{
"name": "$future_name_lowercase!_trema",
"position_input_name": "$future_name_lowercase!_trema",
/* Extract the TREMA for the previous day. */
"tag_name": "exponential_moving_average"
},
>>>
],
/* Position money management functions determine the sizes of trades. */
"position_money_management_functions": [
/* Duplicate this function for each future. */
<<<1<
{
"id": $position_mmf_id,
"name": "$future_name_lowercase!_mmf",
"inputs": [
/* This looks up the corresponding name in the position money management function inputs. */
"$future_name_lowercase!_trema"
],
"float_parameters": {},
"string_parameters": {},
/* Like a custom transform, a position money management function has a code file. */
"code_file": "money_management.txt"
},
>>>
],
"position_parameters": [
[
1,
{
/* Risk one percent of closed equity when we open a trade. */
"name": "equity_fraction",
"value": "0.01"
}
]
],
/* Positions determine how we enter and exit trades. */
"positions": [
/* Duplicate these positions for each future. */
<<<1<
{
"id": $long_1_position_id,
"name": "$future_name_lowercase!_long_1",
/* Each position belongs to a single future. */
"instrument": {
"id": $future_id,
"name": "$future_name_uppercase"
},
/* A position can be either long or short. */
"long_or_short": {
"Case": "Long"
},
/* Like a transform, a position has an evaluation order. This is needed for systems like the turtle system that use pyramiding. */
"evaluation_order": $long_1_evaluation_order,
/* The position input that provides price data. */
"price_input_id": $price_input_id,
/* The multiplier is used to calculate profits/losses on trades, and to determine the sizes of trades. */
"multiplier": $multiplier,
/* The position input that provides entry signals. */
"entry_signal_input_id": $long_entry_input_id,
/* The tag name for the value to extract from the entry signal input data. The value should be of type bool. */
"entry_signal_tag_name": "long_1_entry_tag",
/* The position input that provides exit signals. */
"exit_signal_input_id": $long_exit_input_id,
/* The tag name for the value to extract from the exit signal input data. The value should be of type bool. */
"exit_signal_tag_name": "long_1_exit_tag",
/* We cannot trade partial futures contracts. For equities, this setting would be false. */
"size_must_be_whole_number": true,
/* These two settings let us dynamically increase or decrease the size of each trade when we recalculate the position money management formula for each day. They should be set to false. */
"dynamically_increase_size" : false,
"dynamically_decrease_size" : false,
/* The position money management input. */
"money_management_function_id": $position_mmf_id,
/* Enter and exit the position using the opening price for the current day. */
"entry_price_tag_name": "price_open",
"exit_price_tag_name": "price_open"
},
/* The turtle system uses pyramiding. We have a total of four long positions and four short positions for each future. We could create one long and one short position and use templates to duplicate them four times each, but that would require nested templates, which aren't currently supported.
These positions are similar to the first long position.
*/
{
"id": $long_2_position_id,
"name": "$future_name_lowercase!_long_2",
"instrument": {
"id": $future_id,
"name": "$future_name_uppercase"
},
"long_or_short": {
"Case": "Long"
},
"evaluation_order": $long_2_evaluation_order,
"price_input_id": $price_input_id,
"multiplier": $multiplier,
"entry_signal_input_id": $long_entry_input_id,
"entry_signal_tag_name": "long_2_entry_tag",
"exit_signal_input_id": $long_exit_input_id,
"exit_signal_tag_name": "long_2_exit_tag",
"size_must_be_whole_number": true,
"dynamically_increase_size" : false,
"dynamically_decrease_size" : false,
"money_management_function_id": $position_mmf_id,
"entry_price_tag_name": "price_open",
"exit_price_tag_name": "price_open"
},
{
"id": $long_3_position_id,
"name": "$future_name_lowercase!_long_3",
"instrument": {
"id": $future_id,
"name": "$future_name_uppercase"
},
"long_or_short": {
"Case": "Long"
},
"evaluation_order": $long_3_evaluation_order,
"price_input_id": $price_input_id,
"multiplier": $multiplier,
"entry_signal_input_id": $long_entry_input_id,
"entry_signal_tag_name": "long_3_entry_tag",
"exit_signal_input_id": $long_exit_input_id,
"exit_signal_tag_name": "long_3_exit_tag",
"size_must_be_whole_number": true,
"dynamically_increase_size" : false,
"dynamically_decrease_size" : false,
"money_management_function_id": $position_mmf_id,
"entry_price_tag_name": "price_open",
"exit_price_tag_name": "price_open"
},
{
"id": $long_4_position_id,
"name": "$future_name_lowercase!_long_4",
"instrument": {
"id": $future_id,
"name": "$future_name_uppercase"
},
"long_or_short": {
"Case": "Long"
},
"evaluation_order": $long_4_evaluation_order,
"price_input_id": $price_input_id,
"multiplier": $multiplier,
"entry_signal_input_id": $long_entry_input_id,
"entry_signal_tag_name": "long_4_entry_tag",
"exit_signal_input_id": $long_exit_input_id,
"exit_signal_tag_name": "long_4_exit_tag",