It was the Bitcointalk forum that inspired us to create Bitcointalksearch.org - Bitcointalk is an excellent site that should be the default page for anybody dealing in cryptocurrency, since it is a virtual gold-mine of data. However, our experience and user feedback led us create our site; Bitcointalk's search is slow, and difficult to get the results you need, because you need to log in first to find anything useful - furthermore, there are rate limiters for their search functionality.
The aim of our project is to create a faster website that yields more results and faster without having to create an account and eliminate the need to log in - your personal data, therefore, will never be in jeopardy since we are not asking for any of your data and you don't need to provide them to use our site with all of its capabilities.
We created this website with the sole purpose of users being able to search quickly and efficiently in the field of cryptocurrency so they will have access to the latest and most accurate information and thereby assisting the crypto-community at large.
/* This code implements a "fair market" algorithm for trading.
Instead of matching individual buy/sell orders for a particular
issue one at a time as they impinge on a bid/ask spread, the "fair
market" algorithm consolidates all buy and sell orders for an
issue over some interval and then finds a single price which
maximizes the number of shares traded. For that interval, ALL
purchases/sales which can be made are made at that price.
Using a fair market algorithm, it is possible to proceed on the
basis that the market opens every hour (or every ten minutes, or
whatever), determines a "best price" for all buy/sell orders
received during that hour, executes all trades that can be
executed at that price, and immediately closes again.
*/
#include
#include
struct order{
int minprice;
int maxprice;
int amount;
int buyorsell;
};
#define SELL 1
#define BUY 0
struct sortrec{
int keyprice;
struct order *ref;
};
int sortrecorder(const void *srpt1, const void *srpt2 ){
return(((struct sortrec*)srpt1)->keyprice -
((struct sortrec*)srpt2)->keyprice);
}
/* Sets *validresult to 0 for a malloc error or when finding that
there is no price at which trades can be made. Returns -1 for
a malloc error and 0 for no-acceptable-price.
Otherwise accepts a vector of orders and the length of that vector,
and returns the best price (ie, the price at which the greatest
amount of the issue can be traded) for that vector. If there is a
range of such prices, it returns the highest. */
int findprice(struct order *orders, int ordercount, int *validresult){
struct sortrec *ordervec;
struct order* item;
int index;
*validresult = 0;
/* if there are zero orders, or one order, then there cannot be any
price at which a valid trade can be made. */
if (ordercount <= 1)
return(0);
sortrec = calloc(ordercount * 2, sizeof(struct sortrec));
if (ordervec == NULL)
return (-1);
for (index = 0; index < ordercount; index++){
ordervec[index].keyprice = orders[index].minprice;
ordervec[index + ordercount].keyprice = orders[index].maxprice;
ordervec[index].ref = &(orders[index]);
ordervec[index + ordercount].ref = &(orders[index]);
}
qsort((void *)ordervec, 2 * ordercount, sizeof(struct sortrec), sortrecorder);
int loindex;
int hiindex = -1;
int buys;
int sells;
int trades;
int pricechanged;
int vlength = 2 * ordercount;
int lastprice;
int bestprice = lastprice;
int lastindex = -1;
int besttrades = 0;
int priceguess = ordervec[0].keyprice -1;
while (hiindex < vlength) {
pricechanged = 1;
if (lastprice + 1 == ordervec[hiindex+1].keyprice ){
lastprice = priceguess;
loindex = hiindex+1;
priceguess = ordervec[loindex].keyprice;
for (hiindex = loindex;
hiindex < vlength && ordervec[hiindex].keyprice == priceguess;
hiindex++);
}
else if (hiindex + 1 < vlength){
lastprice = priceguess;
priceguess = ordervec[hiindex+1].keyprice -1;
}
else pricechanged = 0;
if (pricechanged){
for (index = loindex; index <= hiindex; index++){
item = ordervec[index].ref;
if (item->buyorsell == BUY){
if (item->minprice == priceguess)
buys += item->amount;
else if ( priceguess > item->maxprice
&& lastprice <= item->maxprice)
buys -= item->amount;
}
else{
if (item->minprice == priceguess)
sells += item->amount;
else if (priceguess > item->maxprice
&& lastprice <= item->maxprice)
sells -= item->amount;
}
}
trades = buys > sells ? sells : buys;
if (trades >= besttrades){
bestprice = priceguess;
besttrades = trades;
}
}
}
if (besttrades == 0)
/* no trades can be made at any one price. */
return(0);
*validresult = 1;
return(bestprice);
}