コード例 #1
6
ファイル: TestIdTracker.cs プロジェクト: bluejack2000/core
        public void VirtualIds()
        {
            const int BOX1ID = 22;
            const int BOX2ID = 23;
            const int ATTEMPTS = 1000;
            // store ids
            List<long> b1 = new List<long>(ATTEMPTS);
            List<long> b2 = new List<long>(ATTEMPTS);
            // create a new tracker with virtual id represent my book
            it = new IdTracker(BOX1ID);
            // create a second tracker with unique id
            IdTracker it2 = new IdTracker(BOX2ID);
            // make sure consequetive assignments don't match
            Assert.AreNotEqual(it.AssignId, it.AssignId);
            // make sure checks of ids do match
            Assert.AreEqual(it.NextId, it.NextId);
            // assign 1000 ids to make sure we overlap with tracker2 initial id
            for (int i = 0; i < ATTEMPTS; i++)
            {
                b1.Add(it.AssignId);
            }
            // assign 1000 ids to make sure we overlap with tracker1 assignments
            for (int i = 0; i < ATTEMPTS; i++)
            {
                b2.Add(it2.AssignId);
            }
            bool overlap = false;
            // test for id overlap
            for (int i = 0; i < ATTEMPTS; i++)
                for (int j = 0; j < ATTEMPTS; j++)
                    overlap |= (b1[i] == b2[j]);
            Assert.IsFalse(overlap, "ids overlapped");

        }
コード例 #2
0
ファイル: LimitCancel.cs プロジェクト: antonywu/tradelink
 public override void Reset()
 {
     // we do this in reset so we can pickup the response id and keep our orders unique
     _idt = new IdTracker(ID);
     // prompt for parameters if specified
     ParamPrompt.Popup(this, true, !_prompt);
 }
コード例 #3
0
ファイル: TestIdTracker.cs プロジェクト: bluejack2000/core
 public void Basics()
 {
     // create new tracker
     it = new IdTracker();
     // make sure consequetive assignments don't match
     Assert.AreNotEqual(it.AssignId, it.AssignId);
     // make sure checks of ids do match
     Assert.AreEqual(it.NextId, it.NextId);
 }
コード例 #4
0
ファイル: TIF_Response.cs プロジェクト: wang-shun/tradelink
        public override void Reset()
        {
            idt = new IdTracker(ID);
            tt = new TIFTracker(idt);
            tt.SendCancelEvent += new LongDelegate(sendcancel);
            tt.SendDebugEvent += new DebugDelegate(D);
            tt.SendOrderEvent += new OrderDelegate(sendorder);
            tt.DefaultTif = 3;

        }
コード例 #5
0
 public LatencyTracker(string logpath, IdTracker idt)
 {
     if (logpath != null)
     {
         try
         {
             _logit   = true;
             _logpath = logpath;
         }
         catch
         {
             _log   = null;
             _logit = false;
         }
     }
     _idt = idt;
 }
コード例 #6
0
ファイル: TestIdTracker.cs プロジェクト: antonywu/tradelink
        public void NamedIds()
        {
            IdTracker idt = new IdTracker();
            idt.SendDebugEvent+=new TradeLink.API.DebugDelegate(Console.WriteLine);
            idt.isMagicIdOnMaxName = false;
            const string sym = "TST";
            // get an id
            string id1 = "my market entry";
            string id2 = "my limit entry";
            string id3 = "my exit";
            var entry = new MarketOrder(sym, 100, idt[id1]);
            var lmt = new LimitOrder(sym, 100, 11, idt[id2]);
            var exit = new StopOrder(sym, 100, 9, idt[id3]);

            // verify they are unique
            Assert.AreNotEqual(entry.id, lmt.id, "entry market and limit should not match");
            Assert.AreNotEqual(exit.id, lmt.id, "exit and entry limit should not match");

            // make sure they always return the same value
            var c1 = idt[id1];
            var c2 = idt[id2];
            var c3 = idt[id3];
            Assert.AreEqual(c1, entry.id, id1 + " id changed");
            Assert.AreEqual(c2, lmt.id, id2 + " id changed");
            Assert.AreEqual(c3, exit.id, id3+" id changed");

            // test resetting
            idt[id3] = 0;
            var newc3 = idt[id3];
            Assert.AreNotEqual(newc3, c3, id3 + " did not change after a reset");

            // request it again, should be same

            var newc3compare = idt[id3];
            Assert.AreEqual(newc3, newc3compare, id3 + " changed after a read request");



        }
コード例 #7
0
 public OffsetTracker(IdTracker tracker)
 {
     _ids = tracker;
 }
コード例 #8
0
 public PapertradeTracker(IdTracker idt)
 {
     _idt = idt;
 }
コード例 #9
0
 public OCOTracker(IdTracker idt) : this("OcoTracker", 100, idt)
 {
 }
コード例 #10
0
 public OCOTracker(string name, int estsymbols, IdTracker idt) : base(estsymbols, name)
 {
     _idt = idt;
 }
コード例 #11
0
ファイル: OCOTracker.cs プロジェクト: michaelwills/tradelink
 public OCOTracker(string name, IdTracker idt) : base(name, OCOGroup.EmptyGroup())
 {
     _idt = idt;
 }
コード例 #12
0
ファイル: OffsetTracker.cs プロジェクト: antonywu/tradelink
 public OffsetTracker(IdTracker tracker)
 {
     _ids = tracker;
 }
コード例 #13
0
ファイル: TrailTracker.cs プロジェクト: antonywu/tradelink
 /// <summary>
 /// creates a trail tracker from an existing position tracker component
 /// </summary>
 /// <param name="pt"></param>
 public TrailTracker(PositionTracker pt, IdTracker id)
 {
     _pt = pt;
     _id = id;
 }
コード例 #14
0
 public OversellTracker(PositionTracker pt, IdTracker idt)
 {
     _pt  = pt;
     _idt = idt;
 }
コード例 #15
0
 /// <summary>
 /// creates a trail tracker from an existing position tracker component
 /// </summary>
 /// <param name="pt"></param>
 public TrailTracker(PositionTracker pt, IdTracker id)
 {
     _pt = pt;
     _id = id;
 }
コード例 #16
0
 public PapertradeTracker(IdTracker idt)
 {
     _idt = idt;
 }
コード例 #17
0
 public TIFTracker(IdTracker id)
 {
     _idt = id;
 }
コード例 #18
0
 public RejectTracker(IdTracker idt)
 {
     _idt    = idt;
     NewTxt += new TextIdxDelegate(RejectTracker_NewTxt);
 }
コード例 #19
0
 public TIFTracker_Ticks(IdTracker id)
 {
     _idt    = id;
     NewTxt += new TextIdxDelegate(TIFTracker_Ticks_NewTxt);
 }
コード例 #20
0
ファイル: TestIdTracker.cs プロジェクト: bluejack2000/core
        public void SymbolNamedIds()
        {
            IdTracker idt = new IdTracker();
            idt.isMagicIdOnMaxName = false;
            idt.SendDebugEvent += new TradeLink.API.DebugDelegate(Console.WriteLine);
            const string sym = "TST";
            const string sym2 = "BST";
            // get an id
            string id1 = "my market entry";
            var entry = new MarketOrder(sym, 100, idt[sym,id1]);
            var entry2 = new MarketOrder(sym, 100, idt[sym2, id1]);


            // verify they are unique
            Assert.AreNotEqual(entry.id, entry2.id, "different symbol entries should not match");
            

            // make sure they always return the same value
            var c1 = idt[sym,id1];
            var c1_2 = idt[sym2,id1];

            Assert.AreEqual(c1, entry.id, id1 + " id changed");

            // test resetting
            idt[sym,id1] = 0;
            var newc1 = idt[sym,id1];
            Assert.AreNotEqual(newc1, c1, id1 + " did not change after a reset");

            // request it again, should be same

            var newc1compare = idt[sym,id1];
            Assert.AreEqual(newc1, newc1compare, id1 + " changed after a read request");

            // test fetching idname from id
            Assert.AreEqual(idt.idname(sym,id1), idt.getidname(newc1compare));
            Assert.AreEqual(IdTracker.UNKNOWN_IDNAME, idt.getidname(2));



        }
コード例 #21
0
 public OffsetTracker(IdTracker tracker) : base("OFFSET")
 {
     _ids = tracker;
 }
コード例 #22
0
ファイル: TestIdTracker.cs プロジェクト: bluejack2000/core
        public void MaxNamedAssigns()
        {
            IdTracker idt = new IdTracker();
            // set defaults
            idt.MaxNamedAssigns = 1;
            idt.isMagicIdOnMaxName = true;

            idt.SendDebugEvent += new TradeLink.API.DebugDelegate(Console.WriteLine);
            const string sym = "TST";
            
            // get an id
            string id1 = "my market entry";
            //var newc1 = idt[sym, id1];
            var entry = new MarketOrder(sym, 100, idt[sym, id1]);
            
            // verify # of assigns
            Assert.AreEqual(1, idt.AssignCount(id1, sym), "wrong assignment count 1");

            // request it again, should be zero
            var newc1compare = idt[sym, id1];
            Assert.AreEqual(idt.MagicId, newc1compare, id1 + " was not an invalid id (#1)");

            // verify # of assigns
            Assert.AreEqual(1, idt.AssignCount(id1, sym), "wrong assignment count 2");
            // override it
            Assert.AreEqual(entry.id, idt[sym, id1, false], "override failed");
            Assert.AreNotEqual(idt.MagicId, idt[sym, id1, false], "override failed");

            // change default fires
            idt.MaxNamedAssigns = 2;
            // fire again
            newc1compare = idt[sym, id1];
            // verify # of assigns
            Assert.AreEqual(2, idt.AssignCount(id1, sym), "wrong assignment count 3");
            Assert.AreNotEqual(entry.id, newc1compare, " was not unique");
            Assert.AreNotEqual(idt.MagicId, newc1compare, " should not be magic id");

            // fire again to hit the max
            var denied = idt[sym, id1];
            // verify # of assigns
            Assert.AreEqual(2, idt.AssignCount(id1, sym), "wrong assignment count 4");
            Assert.AreEqual(idt.MagicId, denied, id1 + " was not an invalid id (#2)");


            // change default
            idt.isMagicIdOnMaxName = false;
            var final = idt[sym, id1];
            Assert.AreEqual(2, idt.AssignCount(id1, sym), "wrong assignment count 5");
            Assert.AreEqual(final, newc1compare, id1 + " changed after a read request");

            // reset it to get a new id
            idt.Reset(sym, id1);
            var resetfinal = idt[sym,id1];
            var resetfinaloverride = idt[sym, id1, false];
            Assert.AreNotEqual(idt.MagicId, resetfinal, "no id after reset");
            Assert.AreNotEqual(idt.MagicId, resetfinaloverride, "no overriden id after reset");
            
            Assert.AreNotEqual(final, resetfinal, "no change in id after reset");
            Assert.AreNotEqual(resetfinaloverride, resetfinal, "no change in overriden id after reset");
            

        }
コード例 #23
0
ファイル: OversellTracker.cs プロジェクト: bluejack2000/core
 public OversellTracker(PositionTracker pt, IdTracker idt)
 {
     _pt = pt;
     _idt = idt;
 }
コード例 #24
0
ファイル: OrderTIFTracker.cs プロジェクト: antonywu/tradelink
 public TIFTracker(IdTracker id)
 {
     _idt = id;
 }
コード例 #25
0
ファイル: LatencyTracker.cs プロジェクト: bluejack2000/core
 public LatencyTracker(string logpath, IdTracker idt)
 {
     if (logpath != null)
     {
         try
         {
             _logit = true;
             _logpath = logpath;
         }
         catch
         {
             _log = null;
             _logit = false;
         }
     }
     _idt = idt;
        
 }