[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GT] SVN Commit r706 - in branches/CPAN/t: . cs data



Author: clkao
Date: 2009-11-06 14:40:02 +0100 (Fri, 06 Nov 2009)
New Revision: 706

Added:
   branches/CPAN/t/cs/
   branches/CPAN/t/cs/stop-fixed.t
   branches/CPAN/t/data/TXExtreme_5min.txt
Log:
Add a failing test for ordering issues of multiple stop orders within position.

Added: branches/CPAN/t/cs/stop-fixed.t
===================================================================
--- branches/CPAN/t/cs/stop-fixed.t	                        (rev 0)
+++ branches/CPAN/t/cs/stop-fixed.t	2009-11-06 13:40:02 UTC (rev 706)
@@ -0,0 +1,60 @@
+#!/usr/bin/perl -w
+use strict;
+use Finance::GeniusTrader::DateTime;
+use Finance::GeniusTrader::Calculator;
+use Finance::GeniusTrader::Prices;
+use Finance::GeniusTrader::BackTest;
+use Finance::GeniusTrader::PortfolioManager;
+use Finance::GeniusTrader::SystemManager;
+use Finance::GeniusTrader::Tools qw(resolve_alias);
+use Finance::GeniusTrader::Test
+    tests => 1,
+    gt_config => sub {
+        my $test_base = shift;
+        my $db_path = File::Spec->catdir($test_base, 'data');
+<<"EOF";
+DB::module Text
+DB::text::file_extension _\$timeframe.txt
+DB::text::directory $db_path
+Brokers::module NoCosts
+
+Aliases::Global::CBBTD[] SY:AlwaysInTheMarket \\
+ |OF:ChannelBreakout {I:G:MaxInPeriod #1 {I:Prices HIGH}} \\
+                     {I:G:MinInPeriod #2 {I:Prices LOW }} \\
+ |CS:ChannelBreakout {I:G:Eval #3} \\
+                     {I:G:Eval #4} \\
+                      |CS:Stop:Fixed #5|MM:FixedShares 1 \\
+ |TF:MaxOpenTrades 1|TF:ShortOnly
+EOF
+    };
+
+my ($calc, $first, $last) = Finance::GeniusTrader::Tools::find_calculator(Finance::GeniusTrader::Test->gt_db, 'TXExtreme', $PERIOD_5MIN, 0, '2007-08-14 00:00:00', '2007-08-15 00:00:00');
+
+my $pf_manager = Finance::GeniusTrader::PortfolioManager->new;
+my $sys_manager = Finance::GeniusTrader::SystemManager->new;
+my $sysname = 'CBBTD[60,60,8000,9000,1]';
+my $alias = resolve_alias($sysname);
+$sys_manager->set_alias_name($sysname);
+$sysname = $alias;
+$sys_manager->setup_from_name($sysname);
+$pf_manager->setup_from_name($sysname);
+
+$pf_manager->finalize;
+$sys_manager->finalize;
+my $analysis = backtest_single($pf_manager, $sys_manager, undef, $calc, $first, $last);
+
+my $compact = [ map {
+        my $details = join( ',', map { $_->{'order'} . $_->price }
+                $_->list_detailed_orders );
+        [ $_->open_date, $_->close_date, $details ];
+} @{ $analysis->{portfolio}{history} } ];
+
+is_deeply($compact,
+          [ [
+              '2007-08-14 09:25:00',
+              '2007-08-14 10:05:00',
+              'S8842,B8930.42'
+          ]
+        ]
+      );
+

Added: branches/CPAN/t/data/TXExtreme_5min.txt
===================================================================
--- branches/CPAN/t/data/TXExtreme_5min.txt	                        (rev 0)
+++ branches/CPAN/t/data/TXExtreme_5min.txt	2009-11-06 13:40:02 UTC (rev 706)
@@ -0,0 +1,120 @@
+8896	8910	8875	8904	1469	2007-08-13 08:50
+8904	8919	8903	8908	988	2007-08-13 08:55
+8905	8909	8902	8907	502	2007-08-13 09:00
+8906	8923	8905	8915	1055	2007-08-13 09:05
+8914	8944	8912	8930	1876	2007-08-13 09:10
+8935	8960	8931	8957	1398	2007-08-13 09:15
+8957	8957	8938	8943	963	2007-08-13 09:20
+8943	8955	8930	8935	867	2007-08-13 09:25
+8934	8938	8917	8923	735	2007-08-13 09:30
+8923	8928	8910	8910	1034	2007-08-13 09:35
+8913	8930	8909	8926	896	2007-08-13 09:40
+8924	8932	8922	8928	653	2007-08-13 09:45
+8928	8938	8925	8930	704	2007-08-13 09:50
+8932	8933	8915	8924	703	2007-08-13 09:55
+8924	8928	8920	8925	242	2007-08-13 10:00
+8924	8939	8922	8938	490	2007-08-13 10:05
+8936	8938	8923	8923	293	2007-08-13 10:10
+8922	8925	8906	8915	967	2007-08-13 10:15
+8914	8925	8914	8915	400	2007-08-13 10:20
+8915	8932	8913	8928	564	2007-08-13 10:25
+8929	8934	8925	8934	357	2007-08-13 10:30
+8932	8934	8925	8927	338	2007-08-13 10:35
+8927	8930	8911	8912	532	2007-08-13 10:40
+8912	8918	8895	8899	819	2007-08-13 10:45
+8900	8908	8888	8897	663	2007-08-13 10:50
+8896	8915	8891	8914	621	2007-08-13 10:55
+8913	8919	8909	8916	627	2007-08-13 11:00
+8912	8916	8903	8911	286	2007-08-13 11:05
+8912	8913	8894	8894	413	2007-08-13 11:10
+8891	8907	8891	8895	413	2007-08-13 11:15
+8895	8899	8884	8899	813	2007-08-13 11:20
+8898	8907	8886	8905	652	2007-08-13 11:25
+8905	8905	8887	8893	601	2007-08-13 11:30
+8893	8896	8862	8876	1404	2007-08-13 11:35
+8877	8877	8851	8860	1389	2007-08-13 11:40
+8861	8871	8842	8868	1303	2007-08-13 11:45
+8871	8871	8843	8863	825	2007-08-13 11:50
+8863	8892	8857	8885	1008	2007-08-13 11:55
+8887	8889	8876	8878	568	2007-08-13 12:00
+8879	8894	8878	8889	611	2007-08-13 12:05
+8891	8908	8889	8906	967	2007-08-13 12:10
+8905	8928	8902	8928	1247	2007-08-13 12:15
+8926	8945	8925	8942	1311	2007-08-13 12:20
+8942	8960	8935	8937	1299	2007-08-13 12:25
+8934	8938	8918	8924	826	2007-08-13 12:30
+8925	8937	8920	8921	640	2007-08-13 12:35
+8918	8920	8905	8917	613	2007-08-13 12:40
+8917	8948	8917	8943	653	2007-08-13 12:45
+8945	8950	8936	8939	753	2007-08-13 12:50
+8938	8943	8923	8925	634	2007-08-13 12:55
+8924	8943	8923	8932	525	2007-08-13 13:00
+8934	8936	8923	8926	462	2007-08-13 13:05
+8926	8931	8905	8905	695	2007-08-13 13:10
+8905	8915	8891	8901	1154	2007-08-13 13:15
+8902	8928	8893	8920	1087	2007-08-13 13:20
+8918	8922	8910	8919	639	2007-08-13 13:25
+8919	8923	8914	8916	596	2007-08-13 13:30
+8915	8922	8901	8915	852	2007-08-13 13:35
+8916	8920	8911	8918	859	2007-08-13 13:40
+8925	8925	8925	8925	674	2007-08-13 13:45
+8860	8894	8860	8885	1049	2007-08-14 08:50
+8882	8887	8875	8883	648	2007-08-14 08:55
+8880	8884	8872	8879	481	2007-08-14 09:00
+8879	8889	8869	8879	1159	2007-08-14 09:05
+8880	8887	8876	8883	675	2007-08-14 09:10
+8879	8895	8871	8884	827	2007-08-14 09:15
+8884	8885	8853	8860	1264	2007-08-14 09:20
+8859	8860	8825	8832	1918	2007-08-14 09:25
+8830	8845	8825	8837	904	2007-08-14 09:30
+8837	8854	8837	8847	1035	2007-08-14 09:35
+8847	8857	8842	8849	721	2007-08-14 09:40
+8847	8855	8844	8850	614	2007-08-14 09:45
+8851	8854	8842	8843	779	2007-08-14 09:50
+8843	8850	8836	8848	598	2007-08-14 09:55
+8850	8878	8845	8870	908	2007-08-14 10:00
+8870	9019	8868	9019	3583	2007-08-14 10:05
+9004	9075	8953	8960	2606	2007-08-14 10:10
+8959	8960	8908	8956	2066	2007-08-14 10:15
+8961	8961	8931	8944	890	2007-08-14 10:20
+8945	8960	8913	8930	1126	2007-08-14 10:25
+8932	8959	8930	8959	813	2007-08-14 10:30
+8953	8958	8932	8940	653	2007-08-14 10:35
+8939	8951	8929	8946	541	2007-08-14 10:40
+8943	8947	8933	8941	400	2007-08-14 10:45
+8937	8950	8937	8942	407	2007-08-14 10:50
+8942	8946	8938	8945	201	2007-08-14 10:55
+8945	8948	8940	8947	428	2007-08-14 11:00
+8946	8955	8940	8948	687	2007-08-14 11:05
+8950	8970	8950	8970	918	2007-08-14 11:10
+8968	8987	8968	8985	1138	2007-08-14 11:15
+8983	9004	8981	8994	1346	2007-08-14 11:20
+8994	8995	8978	8987	768	2007-08-14 11:25
+8987	8989	8973	8981	658	2007-08-14 11:30
+8980	8994	8974	8984	646	2007-08-14 11:35
+8986	8988	8982	8985	469	2007-08-14 11:40
+8985	8986	8955	8961	974	2007-08-14 11:45
+8963	8969	8958	8967	729	2007-08-14 11:50
+8968	8980	8960	8978	768	2007-08-14 11:55
+8978	8983	8959	8973	742	2007-08-14 12:00
+8973	8975	8950	8950	891	2007-08-14 12:05
+8951	8963	8946	8950	696	2007-08-14 12:10
+8954	8968	8949	8964	751	2007-08-14 12:15
+8960	8968	8952	8964	711	2007-08-14 12:20
+8968	8968	8918	8920	1390	2007-08-14 12:25
+8918	8945	8912	8939	1098	2007-08-14 12:30
+8938	8949	8927	8945	649	2007-08-14 12:35
+8948	8952	8942	8947	635	2007-08-14 12:40
+8949	8953	8931	8931	770	2007-08-14 12:45
+8931	8945	8920	8930	876	2007-08-14 12:50
+8929	8930	8911	8917	1275	2007-08-14 12:55
+8917	8923	8890	8905	1428	2007-08-14 13:00
+8902	8909	8886	8906	1227	2007-08-14 13:05
+8901	8909	8895	8906	1108	2007-08-14 13:10
+8903	8907	8882	8885	887	2007-08-14 13:15
+8883	8906	8882	8903	769	2007-08-14 13:20
+8903	8908	8895	8908	620	2007-08-14 13:25
+8904	8907	8900	8905	601	2007-08-14 13:30
+8902	8908	8894	8897	790	2007-08-14 13:35
+8897	8903	8892	8901	856	2007-08-14 13:40
+8885	8885	8885	8885	523	2007-08-14 13:45