hroptatyr / clob Goto Github PK
View Code? Open in Web Editor NEWSimple limit order book and matching engine.
Simple limit order book and matching engine.
Hello Sir,
I have placed 100 offers in a symbol. Qty starts from 1 to 100 and price starts from 6001 to 6100. These all offers are belongs to ASK side. Now I want to match all 100 offers at once by a BID offer. So I placed 100 qty, 6100 price BID offer but I did not get 100 qty . Instead I got 99 qty as a trade and 1 qty with 6100 price have placed as a BID offer. But it supposed to be fulfil offer instead partial offer.
Please Sir help me.
Many Thanks
Hi @hroptatyr
In clob as of now we are passing amount, price value as double type, will we be allowed to pass long type value. I mean suppose we want to pass million/billion value for amount/price then would we be able to pass it?
A big Thank You
Hello Sir,
I have placed 0.0000232 price and 0.00000008 amount for ASK side and it is stored in orderbook. No issues in this case. Here is the output
LMT/BID
LMT/ASK
0.00002320000000000000 0.00000008000000000000000+0.0
Now I want to match this order by placing 0.0000232 price and 0.00000006 amount for BID side. So after matching with ASK side 0.00000002 amount must be remaining for ASK side. But instead it is showing as below
LMT/BID
LMT/ASK
0.00002320000000000000 0.00000002000000000000001+0.0 // Here 1 has been added an extra value at the end.
So Sir please look into this.
Many Thanks
Hi @hroptatyr
Here I am trying to accept amount,price from the user but in orderbook it is showing too many zeros after value. I am sharing my code and output as below.
int
main(void)
{
clob_t c;
c = make_clob();
c.exe = make_unxs(MODE_BI);
clob_ord_t o;
double amt;
double price;
printf("Enter Amount");
scanf("%lf",&amt);
printf("Enter Price");
scanf("%lf",&price);
/* xetra example 1 */
o=unxs_order(c, (clob_ord_t){CLOB_TYPE_LMT, CLOB_SIDE_ASK, amt , 0.0dd, .lmt =price, .usr = (uintptr_t)"121"},NANPX);
if (o.qty.dis + o.qty.hid > 0.dd) {
/* put remainder of order into book */
clob_oid_t i1 = clob_add(c, o);
//printf("orderid..%lu\n", i1.usr);
printf("orderid..%s\n", i1.usr);
}
/* print trades */
for (size_t i = 0U; i < c.exe->n; i++) {
printf("2nd Order");
//printf("OrderId taker..%s\n",c.exe->o[MODE_BIi+CLOB_SIDE_TAKER].usr);
//printf("OrderId maker..%s\n",c.exe->o[MODE_BIi+CLOB_SIDE_MAKER].usr);
printf("OrderId taker..%s\n",c.exe->o[MODE_BIi+CLOB_SIDE_TAKER].usr);
printf("OrderId maker..%s\n",c.exe->o[MODE_BIi+CLOB_SIDE_MAKER].usr);
printf("Taker Side...%hhd\n",c.exe->o[MODE_BIi+CLOB_SIDE_TAKER].sid);
printf("Maker Side...%hhd\n",c.exe->o[MODE_BIi+CLOB_SIDE_MAKER].sid);
qty_t t1=c.exe->q[MODE_BIi+CLOB_SIDE_TAKER];
qty_t m1=c.exe->q[MODE_BIi+CLOB_SIDE_MAKER];
printf("Taker Remaning Qty..%f\n",(double)t1.dis);
printf("Maker Remaning Qty...%f\n",(double)m1.dis);
send_trade(c.exe->x[i]);
}
unxs_clr(c.exe);
clob_prnt(c);
free_clob(c);
return 0;
}
Output
Enter Amount
0.00001
Enter Price
0.000000789
orderid..121
LMT/BID
LMT/ASK
0.0000007890000000000000 0.00001000000000000000+0.0
0.00001000000000000000+0.0 1
MKT/BID
MKT/ASK
In orderbook amot and price are taking zeros aftre showing original values.
Hi @hroptatyr
I have written one C code for order accept, order update and order cancel , if it is on real environment all time order engine should up and active. In this case how can I free clob by free_clob(c); code. Is free_clob(c); is required? and if then how it will be implemented in production.
Hello @hroptatyr
Thanks for your support!!
Sir I am having all the code like order place, order cancel, order update in .c file and able to accept data from the user at runtime. By your immense help and support I have made this code. If you need I can share the code with you. Now Sir I want to expose REST API for order place, order cancel, order update of the .c file. In C language I think we can not build API. So Sir what is the correct way to build API in C. Please help.
Hello Sir,
Here I am trying to push 100 orders at a time through loop price starting from 6001 to 6100 with 1 qty. In order book 6095 price not being pushed. But if I reduce the loop 100 times to 90 times then all 90 offers would have pushed. Similarly if I increment the loop time 100 to 200 and so on then in orderbook not all offers will not be pushed. I am sharing my simple code for placing 100 offers through loop which you can run from your end and please take a look of order book that 6095 price is missing. But in order book must have 100 offers.
#include <stdio.h>
#include "clob.h"
#include "unxs.h"
#include "nifty.h"
#include "dfp754_d64.h"
#define NANPX (__builtin_nand64(""))
static void
send_trade(unxs_exe_t x)
{
printf("Maker Matched Qty..%f\n",(double)x.qty);
printf("Maker Matched Price...%f\n",(double)x.prc);
}
void orderPlace(clob_t c,double amount,double price, char orderid[19])
{
/* xetra example 1 */
clob_ord_t o=unxs_order(c, (clob_ord_t){CLOB_TYPE_LMT, CLOB_SIDE_ASK, amount,.lmt = price, .usr = (uintptr_t) orderid },NANPX);
clob_oid_t i;
if (o.qty.dis + o.qty.hid > 0.dd) {
/* put remainder of order into book */
i = clob_add(c, o);
//printf("orderid..%lu\n", i.usr);
printf("orderid..%s\n", i.usr);
}
/* print trades /
for (size_t i = 0U; i < c.exe->n; i++) {
printf("2nd Order");
printf("OrderId taker..%lu\n",c.exe->o[MODE_BIi+CLOB_SIDE_TAKER].usr);
printf("OrderId maker..%lu\n",c.exe->o[MODE_BIi+CLOB_SIDE_MAKER].usr);
printf("Taker Side...%hhd\n",c.exe->o[MODE_BIi+CLOB_SIDE_TAKER].sid);
printf("Maker Side...%hhd\n",c.exe->o[MODE_BI*i+CLOB_SIDE_MAKER].sid);
qty_t t1=c.exe->q[MODE_BIi+CLOB_SIDE_TAKER];
qty_t m1=c.exe->q[MODE_BIi+CLOB_SIDE_MAKER];
printf("Taker Remaning Qty..%f\n",(double)t1.dis);
printf("Maker Remaning Qty...%f\n",(double)m1.dis);
send_trade(c.exe->x[i]);
}
unxs_clr(c.exe);
}
int
main(void)
{
clob_t c;
c = make_clob();
c.exe = make_unxs(MODE_BI);
char x[19];
double amount=1.0;
for(int i=1;i<= 100 ;i++)
{
sprintf(x, "%d",i);
char *out=strdup(x);
double price=6000.0;
double price1=price+i;
printf("Price..%f\n",price1);
orderPlace(c,amount,price1, out);
}
clob_prnt(c);
free_clob(c);
return 0;
}
Please Sir help me out. I have been trying and testing it since yesterday.
A big thank you.
Hello @hroptatyr Sir,
Here I want to place 1 quantity and 0.00002372 price for an order and I have hard coded the price as below.
clob_t c;
c = make_clob();
c.exe = make_unxs(MODE_BI);
clob_ord_t o;
/* xetra example 1 */
o=unxs_order(c, (clob_ord_t){CLOB_TYPE_LMT, CLOB_SIDE_ASK, 1.0dd, 0.0dd, .lmt =0.00002372, .usr = (uintptr_t)"1"},NANPX);
If I iterate the orderbook by writing below code
//Code for iterating the orderbook
int j=0;
clob_aggiter_t i1= clob_aggiter(c, CLOB_TYPE_LMT, CLOB_SIDE_ASK);
for (; clob_aggiter_next(&i1); j++) {
printf("Price:%f Amount:%f\n", (double)i1.p, (double)(i1.q.dis + i1.q.hid));
}
Price:0.000024 Amount:1.000000
In production we should display the price exactly whatever user has placed.
Hi @hroptatyr
Actually we are compiling my source file which is stored in clob/src folder as below
cc -o orderbook -I../src ./orderbook.c ../src/libclob.a
Now Sir we want keep orders into database i.e postgreSQL and for postgreSQL we have to include <libpq-fe.h> library.
For compiling we have to pass -I/usr/include/postgresql -lpq line at compile time.
So Sir please help how can I add -I/usr/include/postgresql -lpq command with cc -o orderbook -I../src ./orderbook.c ../src/libclob.a
Thanks
Hello Sir
I am keeping the order clob_oid_t in hashmap as key and value pair. And below is my code snippet .
void orderplace(clob_t c,double amt,double price,char output[19],struct hashMap *hashTable)
{
clob_ord_t o=unxs_order(c, (clob_ord_t){CLOB_TYPE_LMT, CLOB_SIDE_ASK, amt, 0.0dd, .lmt =price, .usr = (uintptr_t) output},NANPX);
if (o.qty.dis + o.qty.hid > 0.dd) {
/* put remainder of order into book */
clob_oid_t i = clob_add(c, o);
//printf("orderid..%lu\n", i.usr);
printf("orderid..%s\n", i.usr);
insertMap(hashTable, i.usr, i);
printMap(hashTable);
}
/* print trades */
for (size_t i = 0U; i < c.exe->n; i++) {
printf("1st Order");
printf("OrderId taker..%lu\n",c.exe->o[MODE_BIi+CLOB_SIDE_TAKER].usr);
printf("OrderId maker..%lu\n",c.exe->o[MODE_BIi+CLOB_SIDE_MAKER].usr);
printf("Taker Side...%hhd\n",c.exe->o[MODE_BIi+CLOB_SIDE_TAKER].sid);
printf("Maker Side...%hhd\n",c.exe->o[MODE_BIi+CLOB_SIDE_MAKER].sid);
send_trade(c.exe->x[i]);
// unxs_clr(c.exe);
}
clob_prnt(c);
}
Now Sir I am passing this function value through hardcode like below and its working fine, am getting all clob_oid_t .
clob_t c;
c = make_clob();
c.exe = make_unxs(MODE_BI);
struct hashMap *hashTable;
int tableSize = 1;
hashTable = createMap(tableSize);
orderplace(c,1,100,"1",struct hashMap *hashTable) //Here 1 isthe orderid
orderplace(c,1,100,"2",struct hashMap *hashTable) //Here 2 is the orderid
But instead of hardcode if I pass the value through dynamic like below and if pass it through loop/ more that one time then old clob_oid_t is getting replaced by new clob_oid_t value. I do not know what is the issue if pass it through hardcode more than one time all time I am getting different different clob_oi_t value. But in dynamic it is the issue.
printf("Enter Amount\n");
scanf("%lf",&amt);
printf("Enter Price\n");
scanf("%lf",&price);
printf("Enter offerid\n");
scanf("%s",&output);
orderplace(c,amt,price,output,hashTable);
Sir please please guide me.
Hi @hroptatyr
Here I am trying to storing data in postgesql via PQexecPrepared command in my clob project , here it is showing no error but data not getting stored in DB. Below is my code.
clob_t c;
c = make_clob();
c.exe = make_unxs(MODE_BI);
clob_ord_t o;
PGconn *conn = PQconnectdb("dbname=maching_c host=localhost user=paybito_match password=p@BI20@Dmin43");
if (PQstatus(conn) == CONNECTION_BAD) {
fprintf(stderr, "Connection to database failed: %s\n",
PQerrorMessage(conn));
}
const char command[]="INSERT INTO offers VALUES($1,$2,$3);";
int nParams=3;
char symbol[2]="1";
char output[19]="1";
char side[3]="ASK";
const char *const paramValues[] ={output,symbol,side};
const int paramLengths[] = {sizeof(output),sizeof(symbol),sizeof(side)};
const int paramFormats[] = {0, 0};
int resultFormat = 0;
PGresult *res=PQexecPrepared(conn, command, nParams, paramValues, paramLengths,
paramFormats, resultFormat);
PQclear(res);
o=unxs_order(c, (clob_ord_t){CLOB_TYPE_LMT, CLOB_SIDE_BID, 2.0dd, 0.0dd, .lmt = 4500.00dd, .usr = (uintptr_t) output},NANPX);
clob_oid_t i;
if (o.qty.dis + o.qty.hid > 0.dd) {
/* put remainder of order into book */
i = clob_add(c, o);
//printf("orderid..%lu\n", i.usr);
printf("orderid..%s\n", i.usr);
}
/* print trades */
for (size_t i = 0U; i < c.exe->n; i++) {
printf("2nd Order");
printf("OrderId taker..%lu\n",c.exe->o[MODE_BIi+CLOB_SIDE_TAKER].usr);
printf("OrderId maker..%lu\n",c.exe->o[MODE_BIi+CLOB_SIDE_MAKER].usr);
printf("Taker Side...%hhd\n",c.exe->o[MODE_BIi+CLOB_SIDE_TAKER].sid);
printf("Maker Side...%hhd\n",c.exe->o[MODE_BIi+CLOB_SIDE_MAKER].sid);
qty_t t1=c.exe->q[MODE_BIi+CLOB_SIDE_TAKER];
qty_t m1=c.exe->q[MODE_BIi+CLOB_SIDE_MAKER];
printf("Taker Remaning Qty..%f\n",(double)t1.dis);
printf("Maker Remaning Qty...%f\n",(double)m1.dis);
send_trade(c.exe->x[i]);
}
printf("Before order delation\n");
clob_prnt(c);
Hi @hroptatyr
Sir, I have worked with clob so far like order placing that is GTC (Good Till Cancel) order type. So are IOC (Immediate Or Cancel) and FOK (Fill Or Cancel) option available in clob like other exchange?
Thank You
Hi @hroptatyr
Here I am placing my order and showing the orderbook.
clob_ord_t o=unxs_order(c, (clob_ord_t){CLOB_TYPE_LMT, CLOB_SIDE_ASK, 1, 0.0dd, .lmt =100, .usr = (uintptr_t) "1"},NANPX);
if (o.qty.dis + o.qty.hid > 0.dd) {
/* put remainder of order into book */
clob_oid_t i = clob_add(c, o);
printf("orderid..%s\n", i.usr);
}
clob_prnt(c); // For showing the orderbook.
clob_prnt(c) showing the orderbook as printed value. But Sir I need to keep it in some variable or something like this, so that I can able to customize it.
Thank U
Hi @hroptatyr
For placing order we need clob_t and we need to create a variable of clob_t type as below
clob_t c;
c = make_clob();
c.exe = make_unxs(MODE_BI);
Now Sir if I want to create multiple symbol so I need to create multiple variable like clob_t c,c1,c2,c3.c4 and I need to pass respective variable to unxs_order function like clob_ord_t o1 = unxs_order(c, (clob_ord_t){i1.typ, i1.sid, amt , 0.0dd,.lmt =price, .usr = i1.usr},NANPX);
But Sir I need to keep backup all offers into db because in production suppose my clob program suddenly get stopped. Then I can easily push all offers from db to unxs_order function one by one. But here I need to identify clob_t for every single order. In db it is not possible to store clob_t type.
Please Sir give me some hint/suggestion to overcome this big issue.
Hi @hroptatyr
I am using postgresql and want to keep data from clob to DB. Below is my code.
If I am using sprintf() function to write the INSERT query inside my below code, getting Segmentation fault (core dumped) error.
PGconn *conn = PQconnectdb("dbname=maching_c host=localhost user=test password=test");
if (PQstatus(conn) == CONNECTION_BAD) {
fprintf(stderr, "Connection to database failed: %s\n",
PQerrorMessage(conn));
do_exit(conn);
}
char query[1000];
fscanf(fptr,"%d", &offerid);
char output[19];
sprintf(output, "%d",offerid);
fclose(fptr);
printf("Enter Amount\n");
scanf("%lf",&amt);
printf("Enter Price\n");
scanf("%lf",&price);
char *out=strdup(output);
printf("Enter Side..");
scanf("%s",&side);
if (!strcmp(side, "ASK")) {
parsed_side = CLOB_SIDE_ASK;
} else if (!strcmp(side, "BID")) {
parsed_side = CLOB_SIDE_BID;
}
//orderplace(c,parsed_side,amt,price,out,hashTable,side);
clob_ord_t o=unxs_order(c, (clob_ord_t){CLOB_TYPE_LMT, parsed_side, amt, 0.0dd, .lmt =price, .usr = (uintptr_t) out},NANPX);
if (o.qty.dis + o.qty.hid > 0.dd) {
/* put remainder of order into book */
clob_oid_t i = clob_add(c, o);
//printf("orderid..%lu\n", i.usr);
printf("orderid..%s\n", i.usr);
insertMap(hashTable, i.usr, i);
printMap(hashTable);
sprintf(query,"INSERT INTO offers(offerid,symbol,amount,price,action) VALUES('%s','%s',%lf,%lf,'%s');",i.usr,'1',amt,price,side); ------> This line terminate the program
PGresult *res=PQexec(conn,query);
printf("Record Inserted");
PQclear(res);
PQfinish(conn);
}
But insted sprintf() function if am using below code, it will work but here I am unable to pass variable which I will get data from clob.
PGresult *res=PQexec(conn, "INSERT INTO offers(offerid,symbol,amount,price,action) VALUES('1','1',12,100,'ASK')");
But Sir non-clob project can able to run INSERT query using sprintf() function which I shared you in my code.
Please Sir any suggestion.
Hi @hroptatyr
I have created one header file called orderbook.h where I have defined one function called orderPlace and created one file called orderbook.c where I have implemented orderPlace function. Inside orderPlace function I have written order related code .But when I am going to compile orderbook.c file getting below error
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o: In function _start': (.text+0x20): undefined reference to
main'
Below is my orderbook.h and orderbook.c file.
#ifndef _ORDERBOOK_H
#define _ORDERBOOK_H
void orderPlace(char *out);
#endif
#include <stdio.h>
#include "clob.h"
#include "unxs.h"
#include "mmod-auction.h"
#include "nifty.h"
#include "dfp754_d64.h"
#include "orderbook.h"
#define NANPX (__builtin_nand64(""))
void orderPlace(char* out)
{
clob_t c;
c = make_clob();
c.exe = make_unxs(MODE_BI);
clob_ord_t o;
/* xetra example 1 */
o=unxs_order(c, (clob_ord_t){CLOB_TYPE_LMT, CLOB_SIDE_BID, 2.0dd, 0.0dd, .lmt = 4500.00dd, .usr = (uintptr_t)"121"},NANPX);
clob_oid_t i;
if (o.qty.dis + o.qty.hid > 0.dd) {
/* put remainder of order into book */
i = clob_add(c, o);
//printf("orderid..%lu\n", i.usr);
printf("orderid..%s\n", i.usr);
sprintf(out,"orderid..%s\n",i.usr);
}
unxs_clr(c.exe);
clob_prnt(c);
free_clob(c);
}
Hi @hroptatyr
Below is my Order placing code
o=unxs_order(c, (clob_ord_t){CLOB_TYPE_LMT, CLOB_SIDE_BID, 2.0dd, 0.0dd, .lmt = 4500.00dd, .usr = (uintptr_t)"121"},NANPX);
clob_oid_t i;
if (o.qty.dis + o.qty.hid > 0.dd) {
/* put remainder of order into book */
i = clob_add(c, o);
printf("orderid..%s\n", i.usr);
//Here I would like to get the pending qty from o.qty.dis but it displaying 0 thoug in orderbook its showing correct qty
printf("Qty%lf",(o.qty.dis + o.qty.hid)); -----> Return 0 though 2 qty has been pushed
}
Thanks
Hello Sir,
To place an order I have below code
clob_t c;
c = make_clob();
c.exe = make_unxs(MODE_BI);
o=unxs_order(c, (clob_ord_t){CLOB_TYPE_LMT, parsed_side, x.for_clob, 0.0dd, .lmt =m, .usr = (uintptr_t)"1"},NANPX);
Before put c into unxs_order function I need to check whether c has been initialized or not I mean below lines are called or not before put into unxs_order function;
c=make_clob();
c.exe = make_unxs(MODE_BI);
Actually Sir I have tried like c==NULL but it does not work.
Thanks
Hi @hroptatyr
I have put all functionality in one code and user can do insert,update or delete order dynamically. Here every thing is dynamic.
Now Sir I am facing one major problem in order updation. Let me explain suppose trader A has placed 1 qty, 1000 price ASK order with order id 1. Now it is pending order. Then trader B has placed 0.5 qty ,500 price BID order with orderid 2. Here is the order book.
LMT/BID
500 0.5+0.0
0.5+0.0 2
LMT/ASK
1000 1+0.0
1+0.0 1
MKT/BID
MKT/ASK
Now trader A is going to change his price 500 and his order gets filled by 0.5 qty and 0.5 qty is still remain in orderbook for orderid 1. Please see the order book
LMT/BID
LMT/ASK
500 0.5+0.0
0.5+0.0 3
MKT/BID
MKT/ASK
Then another trader lets say trader C has placed 0.1 qty with 25 price BID order for order id 3 and is is also pending.
Please see the orderbook.
LMT/BID
25 0.1000000000000000+0.0
0.1000000000000000+0.0 4
LMT/ASK
500 0.5+0.0
0.5+0.0 3
MKT/BID
MKT/ASK
Again trader A is going to update his price 25 for order id 1. So in order book orderid 1 should remain 25 price for 0.4 qty. But in my case order book keeps old order price 500 price, 0.5 qty still. It must have only 25 price for 0.4 qty. Please see my orderbook.
LMT/BID
LMT/ASK
25 0.4000000000000000+0.0
0.4000000000000000+0.0 5
500 0.5+0.0
0.5+0.0 3
MKT/BID
MKT/ASK
Sir I am sharing my order updation code with you. Please help me out. if you need I can share my entire code.
// Here I am declaring hash table for keeping orders
#define SIZE 20
struct DataItem {
clob_oid_t data;
int key;
};
struct DataItem* hashArray[SIZE];
struct DataItem* dummyItem;
struct DataItem* item;
int hashCode(int key) {
return key % SIZE;
}
struct DataItem *search(int key) {
//get the hash
int hashIndex = hashCode(key);
//move in array until an empty
while(hashArray[hashIndex] != NULL) {
if(hashArray[hashIndex]->key == key)
return hashArray[hashIndex];
//go to next cell
++hashIndex;
//wrap around the table
hashIndex %= SIZE;
}
return NULL;
}
void insert(int key,clob_oid_t data) {
struct DataItem item = (struct DataItem) malloc(sizeof(struct DataItem));
item->data = data;
item->key = key;
//get the hash
int hashIndex = hashCode(key);
//move in array until an empty or deleted cell
while(hashArray[hashIndex] != NULL && hashArray[hashIndex]->key != -1) {
//go to next cell
++hashIndex;
//wrap around the table
hashIndex %= SIZE;
}
hashArray[hashIndex] = item;
}
struct DataItem* delete(struct DataItem* item) {
int key = item->key;
//get the hash
int hashIndex = hashCode(key);
//move in array until an empty
while(hashArray[hashIndex] != NULL) {
if(hashArray[hashIndex]->key == key) {
struct DataItem* temp = hashArray[hashIndex];
//assign a dummy item at deleted position
hashArray[hashIndex] = dummyItem;
return temp;
}
//go to next cell
++hashIndex;
//wrap around the table
hashIndex %= SIZE;
}
return NULL;
}
void display() {
int i = 0;
for(i = 0; i<SIZE; i++) {
if(hashArray[i] != NULL)
printf(" (%d,%d)",hashArray[i]->key,hashArray[i]->data.usr);
else
printf(" ~~ ");
}
printf("\n");
}
static void
send_trade(unxs_exe_t x)
{
printf("Qty..%f\n",(double)x.qty);
printf("Price...%f\n",(double)x.prc);
}
///Here I am taking old order id, amout ,price , then search clob_oid_t from the hashtable based on the key and if this order gets match then emove the clob_oid_t from the hash table.
printf("Enter OfferId\n");
scanf("%d",&orderid);
printf("Enter Amount\n");
scanf("%lf",&amt);
printf("Enter Price\n");
scanf("%lf",&price);
clob_oid_t i1;
item = search(orderid); //hash table lookin the existing order id
if(item != NULL) {
printf("Element found\n");
i1=item->data;
if (clob_del(c, i1) < 0) {
puts("error, order doesn't exist");
}
clob_ord_t o1 = unxs_order(c, (clob_ord_t){i1.typ, i1.sid, amt , 0.0dd,.lmt =price, .usr = i1.usr},NANPX);
if (o1.qty.dis + o1.qty.hid > 0.dd) {
/* put remainder of order into book */
clob_oid_t i2 = clob_add(c, o1);
//printf("orderid..%lu\n", i2.usr);
printf("Order Updated");
}
double taker_remainqty;
double maker_remainqty;
int orderidtaker;
int count=0;
/* print trades /
for (size_t i = 0U; i < c.exe->n; i++) {
printf("2nd Order");
printf("OrderId taker..%d\n",c.exe->o[MODE_BIi+CLOB_SIDE_TAKER].usr);
printf("OrderId maker..%d\n",c.exe->o[MODE_BIi+CLOB_SIDE_MAKER].usr);
printf("Taker Side...%hhd\n",c.exe->o[MODE_BIi+CLOB_SIDE_TAKER].sid);
printf("Maker Side...%hhd\n",c.exe->o[MODE_BIi+CLOB_SIDE_MAKER].sid);
orderidtaker=c.exe->o[MODE_BIi+CLOB_SIDE_TAKER].usr;
qty_t t1=c.exe->q[MODE_BIi+CLOB_SIDE_TAKER];
qty_t m1=c.exe->q[MODE_BIi+CLOB_SIDE_MAKER];
printf("Taker Remaning Qty..%f\n",(double)t1.dis);
printf("Maker Remaning Qty...%f\n",(double)m1.dis);
taker_remainqty=(double)t1.dis;
maker_remainqty=(double)m1.dis;
if(maker_remainqty==0)
{
item = search(c.exe->o[MODE_BI*i+CLOB_SIDE_MAKER].usr);
delete(item); // this for hastable
}
count++;
send_trade(c.exe->x[i]);
}
if(count!=0)
{
if(taker_remainqty==0)
{
item = search(orderidtaker); // this for hastable
delete(item); // this for hastable
}
}
clob_prnt(c);
unxs_clr(c.exe);
} else {
printf("Element not found\n");
}
Hi @hroptatyr
Can you please help me how to build CLOB and run in windows OS through eclipse ide.
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.