Note that there are some explanatory texts on larger screens.

plurals
  1. POChanges to Pointers not made permanent
    primarykey
    data
    text
    <pre><code>struct Limit { float Price; int size; int Volume; struct Limit *Parent; struct Limit *ltChild; struct Limit *rtChild; struct list_head* Order; }; typedef struct Limit Limit; struct Order { double idNum; bool BuySell; int shares; float limitPrice; char* entryTime; char* eventTime; struct list_head ord_Queue; }; typedef struct Order Order; void AddOrder(Order* newOrder,Limit* Limit,HXmap* OrderMap) { list_add_tail(&amp;newOrder-&gt;ord_Queue,Limit-&gt;Order); HXmap_add(OrderMap,&amp;newOrder-&gt;idNum,newOrder); Limit-&gt;size++; Limit-&gt;Volume +=newOrder-&gt;shares; } void ModifyOrder(float oLimit, int oShares,float nLimit,int nShares,HXmap* LimitMap,HXmap* OrderMap, oBook* OrderBook) { Limit* ParentLimit = (Limit*)HXmap_get(LimitMap,&amp;oLimit); if(ParentLimit==NULL) { printf("ERRONEOUS ORDER\n"); return; } struct list_head *pos; pos = ParentLimit-&gt;Order-&gt;next; Order* Ord= NULL; while(pos!=ParentLimit-&gt;Order) { Ord = list_entry((pos),Order,ord_Queue); if(Ord-&gt;shares==oShares) break; //found the order else pos = pos-&gt;next; } if(pos==ParentLimit-&gt;Order &amp;&amp; Ord-&gt;shares!=oShares) { printf("ORDER NOT FOUND\n"); return; } if(oLimit==nLimit) { ParentLimit-&gt;Volume = (ParentLimit-&gt;Volume + nShares)-oShares; Ord-&gt;shares = nShares; } else { //delete from list Ord-&gt;ord_Queue.next-&gt;prev = Ord-&gt;ord_Queue.prev; Ord-&gt;ord_Queue.prev-&gt;next = Ord-&gt;ord_Queue.next; ParentLimit-&gt;size--; HXmap_del(OrderMap,&amp;Ord-&gt;idNum); if(ParentLimit-&gt;Volume==Ord-&gt;shares) { if(Ord-&gt;BuySell==1) OrderBook-&gt;buyTree = RemoveLimit(OrderBook-&gt;buyTree,ParentLimit,LimitMap); else OrderBook-&gt;sellTree = RemoveLimit(OrderBook-&gt;sellTree,ParentLimit,LimitMap); } else ParentLimit-&gt;Volume-=Ord-&gt;shares; Ord-&gt;limitPrice = nLimit; Ord-&gt;shares = nShares; INIT_LIST_HEAD(&amp;Ord-&gt;ord_Queue); ParentLimit = HXmap_get(LimitMap,&amp;nLimit); if(ParentLimit==NULL) { ParentLimit = Limit_init(nLimit); if(Ord-&gt;BuySell==1) OrderBook-&gt;buyTree= AddLimit(OrderBook-&gt;buyTree,ParentLimit,LimitMap); else OrderBook-&gt;sellTree = AddLimit(OrderBook-&gt;sellTree,ParentLimit,LimitMap); } AddOrder(Ord,ParentLimit,OrderMap); } } </code></pre> <p>Okay, its a longish code, but much of it is purely intuitive. [It uses list.h Kernel Linked List and its associate functions.More info about KLL can be found <a href="http://isis.poly.edu/kulesh/stuff/src/klist/" rel="nofollow">here</a> ]The idea, is when a message to modify a preexisting order at a particular price(its a financial code) arrives, it removes the order from the previous "queue" of its old Price (ParentLimit in <code>ModifyOrder()</code> ) finds the address of new limit price structure by querying the map, if it doesnt exist, creates a new limit and add the order else it simply adds it.</p> <p>Now, I enter same message of modifying orders in a particular limit price. Configuration before passing the messages:</p> <p><code>Limit Price : 181.25, two orders of 250 shares each.</code></p> <p>When I pass, the first modify message, to modify the first order of 250 shares from 181.25 to 181.35(no previous limit exists so it will create a new limit and add it to the tree), the control eventually flows to <code>AddOrder()</code> hence, adding the orders. Definition of <code>AddOrder()</code> function is attached, though its very simplistic and calls <code>list_add_tail()</code> to add it to list. </p> <p>After the first modification(and addition of order), the DDD gives me this situation:</p> <pre><code>Address of ParentLimit: 0x804f1d0 Address of -&gt;Order: 804f710 Contents of -&gt;next: 804dec4 Contents of -&gt;prev: 804dec4 Address of Order-&gt;ord_Queue (just inserted): 0x804dec4 Contents of Order-&gt;ord_Queue-&gt;prev: 0x804f710 Contents of Order-&gt;ord_Queue-&gt;next: 0x804f710 </code></pre> <p>This shows the addition of the order to the queue has taken place successfully. </p> <p>When I pass the second message to modify another order at the same old price (181.25 to 181.35) and query the map to find me the address of the new Limit Price,</p> <p>The situation is:</p> <pre><code>Address of ParentLimit: 0x804f1d0 Address of -&gt;Order: 804f710 Contents of -&gt;next: 804f710 Contents of -&gt;prev: 804f710 </code></pre> <p>Which means, that somehow the change made was not made permanent. I dont know why this is happeneing. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload