elective-stereophonic
elective-stereophonic
InstantDEX beta singapore
Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest Stable Nxt Client: Nxt 1.11.15 | Latest Experimental Nxt Client: Nxt 1.12.0e

Author Topic: InstantDEX beta  (Read 6799 times)

jl777

  • Hero Member
  • *****
  • Karma: +718/-123
  • Offline Offline
  • Posts: 6170
    • View Profile
InstantDEX beta
« on: April 14, 2015, 12:56:43 am »

pushed a new version with a few changes

"POLLGAP":10,"DEFAULT_MAXDEPTH":4 are now supported

POLLGAP is the default time between orderbook poll for a specific orderbook and it will apply to the NXT AE orderbooks

there is also "exchanges":[{},..] array

within the array: {"name":"poloniex","pollgap:N} and you can override the default on a per exchange basis. note the pollgap is tracked on a per orderbook basis

{ "poloniex", ramparse_poloniex, poloniex_supports, poloniex_trade },
       { "bittrex", ramparse_bittrex, bittrex_supports, bittrex_trade },
       { "bter", ramparse_bter, bter_supports, bter_trade },
       { "btce", ramparse_btce, btce_supports, btce_trade },
       { "bitfinex", ramparse_bitfinex, bitfinex_supports, 0 },
       { "bitstamp", ramparse_bitstamp, bitstamp_supports, 0 },
       { "okcoin", ramparse_okcoin, okcoin_supports, 0 },
       { "huobi", ramparse_huobi, huobi_supports, 0 },
       { "bityes", ramparse_bityes, bityes_supports, 0 },
       { "lakebtc", ramparse_lakebtc, lakebtc_supports, 0 },
       { "exmo", ramparse_exmo, exmo_supports, 0 },
       { "btc38", ramparse_btc38, btc38_supports, 0 },

the above are the supported exchanges. for the ones with an exchange_trade entry, if you have "key" and "secret" fields set to the API key and API secret for that exchange, live trading will be enabled. BE CAREFUL! things are very early as this is the first version that didnt fail my InstantDEX orderbook internal tests

if you specify an exchange, even without the API key/secret, it will create orderbook entries for them and I still try to submit the order, so I still need to do a bunch of error checks, but I wanted to make a release so you can all be testing the zillion possible combinations

I did test NXT AE asset/NXT and NXT/asset trades
and InstantDEX assetA/assetB trades

In addition, I support combining orderbook pairs so assetA/assetB + assetB/assetC == assetA/assetC, of course you will get confused as to which direction the trade is and it is quiet possible I have things inthe wrong directions in some cases

Fees are reduced so that if InstantDEX is just acting as order entry to a single NXT AE (or central exchange) order, there is no InstantDEX fee. If there are two orderbook entries combined, it will cost 2.5 NXT, unless the two that are combined are both InstantDEX orderbook entries

each exchange is usually limited to having a trading pair with the denominator being BTC, NXT, USD, CNY, but of course InstantDEX can have any assetA/assetB

any such entry is "half" and can be combined. Currently when you ask for an orderbook, I combinatorically combine all the related orderbooks to find the best price possible, so it is possible to trade assetA/assetA and get prices that are not 1.0000 and maybe arbitrages are possible with one click!

I also implemented equivalent assetids, so all the MGW BTC assets are linked automatically, just ask for any of them and all of the orderbooks are checked
for the few exchanges that support NXT assets, this equivalence is also supported

possible orderbook halves: "InstantDEX", "nxtae", "unconf", "poloniex", "bittrex", "btce", "bter" (until more exchanges are supported with the exchange plugin functions)

I am generating "jumpbooks" using NXT, BTC and BTCD so whenever you make an assetA/assetB orderbook, it will also make assetA/NXT, assetA/BTC, assetA/BTCD, assetB/NXT, assetB/BTC, assetB/BTCD orderbooks in addition to the direct assetA/assetB orderbooks

at ALL exchanges that support these combinations
and then the best bids and asks are combined to create the best possible combined price for assetA/assetB

I think well worth the 2.5 NXT fee

plz let me know of any issues, I dont have time to fully test all the combinations. start with the simple cases, eg. directly filling orders from nxtae and exchanges

then progressively more ambitious ones until you are testing assetA/assetB InstantDEX orders combined with assetB/assetC

James
Logged
There are over 1000 people in SuperNET slack! http://slackinvite.supernet.org/ automatically sends you an invite

I am just a simple C programmer

jl777

  • Hero Member
  • *****
  • Karma: +718/-123
  • Offline Offline
  • Posts: 6170
    • View Profile
Re: InstantDEX beta
« Reply #1 on: April 14, 2015, 01:21:30 am »

How to add support for a new exchange:

1. Add a line for the exchange to:
    static void *exchangeptrs[][4] =
    {
        { "poloniex", ramparse_poloniex, poloniex_supports, poloniex_trade },
        { "bittrex", ramparse_bittrex, bittrex_supports, bittrex_trade },
        { "bter", ramparse_bter, bter_supports, bter_trade },
        { "btce", ramparse_btce, btce_supports, btce_trade },
        { "bitfinex", ramparse_bitfinex, bitfinex_supports, 0 },
        { "bitstamp", ramparse_bitstamp, bitstamp_supports, 0 },
        { "okcoin", ramparse_okcoin, okcoin_supports, 0 },
        { "huobi", ramparse_huobi, huobi_supports, 0 },
        { "bityes", ramparse_bityes, bityes_supports, 0 },
        { "lakebtc", ramparse_lakebtc, lakebtc_supports, 0 },
        { "exmo", ramparse_exmo, exmo_supports, 0 },
        { "btc38", ramparse_btc38, btc38_supports, 0 },
    };

Now the exchange will be recognized in the "exchanges":[] array in the SuperNET.conf. of course there needs to be a parse and trade function along with a function that returns supported assetid pairs

I have written a lot of support functions so for most exchanges it is a matter of a few lines to make the exchange_supports function, even complicated cases where they are trading NXT assets is handled:

int32_t bter_supports(int32_t exchangeid,uint64_t *assetids,int32_t n,uint64_t baseid,uint64_t relid)
{
    static char *symbolmap[][8] = { { "UNITY", "12071612744977229797" },  { "ATOMIC", "11694807213441909013" },  { "DICE", "18184274154437352348" },  { "MRKT", "134138275353332190" },  { "MGW", "10524562908394749924" } };
    uint64_t unityid = calc_nxt64bits("12071612744977229797");
    n = add_exchange_assetids(assetids,n,BTC_ASSETID,baseid,relid,exchangeid,symbolmap,(int32_t)(sizeof(symbolmap)/sizeof(*symbolmap)));
    if ( baseid == unityid || relid == unityid )
    {
        n = add_exchange_assetid(assetids,n,unityid,BTC_ASSETID,exchangeid);
        n = add_exchange_assetid(assetids,n,unityid,NXT_ASSETID,exchangeid);
        n = add_exchange_assetid(assetids,n,unityid,CNY_ASSETID,exchangeid);
    }
    return(n);
}

I push down to each exchange to return what assetid pairs it supports to make a global list of assetA/assetB/exchangeid orderbooks. native crypto assets have special assetids that are simply the 64bit (0 filled) of the string (capped at 8 bytes)

Now we need a parse function, but again I have built in parsers so for most exchanges the parse function is something like this:

void ramparse_coinbase(struct rambook_info *bids,struct rambook_info *asks,int32_t maxdepth,char *gui)
{
    if ( bids->url[0] == 0 )
        sprintf(bids->url,"https://api.exchange.coinbase.com/products/%s-%s/book?level=2",bids->base,bids->rel);
    ramparse_standard("coinbase",bids->url,bids,asks,0,0,maxdepth,gui);
}

the supports and parse functions are all that are needed to display an exchange's orderbook, but of course we need a trading function too:


uint64_t poloniex_trade(struct exchange_info *exchange,char *base,char *rel,int32_t dir,double price,double volume)
{
    static CURL *cHandle;
    char *sig,*data,cmdbuf[8192],hdr1[1024],hdr2[1024],pairstr[512],dest[SHA512_DIGEST_SIZE*2 + 1]; cJSON *json; uint64_t txid = 0;
    dir = flip_for_exchange(pairstr,"%s_%s","BTC",dir,&price,&volume,base,rel);
    sprintf(cmdbuf,"command=%s&nonce=%ld&currencyPair=%s&rate=%.8f&amount=%.8f",dir>0?"buy":"sell",time(NULL),pairstr,price,volume);
    if ( (sig = hmac_sha512_str(dest,exchange->apisecret,(int32_t)strlen(exchange->apisecret),cmdbuf)) != 0 )
        sprintf(hdr2,"Sign:%s",sig);
    else hdr2[0] = 0;
    sprintf(hdr1,"Key:%s",exchange->apikey);
    printf("cmdbuf.(%s) h1.(%s) h2.(%s)\n",cmdbuf,hdr2,hdr1);
    if ( (data= curl_getorpost(&cHandle,"https://poloniex.com/tradingApi",cmdbuf,hdr2,hdr1)) != 0 )
    {
        printf("cmd.(%s) [%s]\n",cmdbuf,data);
        if ( (json= cJSON_Parse(data)) != 0 )
        {
            txid = (get_API_nxt64bits(cJSON_GetObjectItem(json,"orderNumber")) << 32) | get_API_nxt64bits(cJSON_GetObjectItem(json,"tradeID"));
            free_json(json);
        }
        free(data);
    }
    return(txid);
}

With average of ~100 lines a new exchange can be supported, assuming it is using a previously supported authentication. The first version of an authentication method might be a bit tricky, but I think most all of them are available in Standard C. I can offer small bounty of 100 InstantDEX for the first exchange_trade C function that uses a specific authentication. libtom is the preferred library to use, but any self-contained C is acceptable.

James
Logged
There are over 1000 people in SuperNET slack! http://slackinvite.supernet.org/ automatically sends you an invite

I am just a simple C programmer

jl777

  • Hero Member
  • *****
  • Karma: +718/-123
  • Offline Offline
  • Posts: 6170
    • View Profile
Re: InstantDEX beta
« Reply #2 on: April 14, 2015, 01:29:32 am »

current GUI pic:

Logged
There are over 1000 people in SuperNET slack! http://slackinvite.supernet.org/ automatically sends you an invite

I am just a simple C programmer

BTCDDev

  • Full Member
  • ***
  • Karma: +20/-4
  • Offline Offline
  • Posts: 148
    • View Profile
Re: InstantDEX beta
« Reply #3 on: April 14, 2015, 02:47:00 am »

Windows isn't far behind!

Matthew
Logged

Sebastien256

  • Hero Member
  • *****
  • Karma: +169/-24
  • Offline Offline
  • Posts: 2823
  • ^LOOK UP^ = Nxt community!
    • View Profile
Re: InstantDEX beta
« Reply #4 on: June 17, 2015, 07:37:15 pm »

Is beta far away? Now that phasing is out. What still missing for instantdex to go live?
Logged
Please drop your ideas concerning Nxt and/or NRS in this topic -> List of feature request for Nxt and/or NRS (with the full list in OP).

jl777

  • Hero Member
  • *****
  • Karma: +718/-123
  • Offline Offline
  • Posts: 6170
    • View Profile
Re: InstantDEX beta
« Reply #5 on: June 18, 2015, 12:44:12 am »

Is beta far away? Now that phasing is out. What still missing for instantdex to go live?
testers
Logged
There are over 1000 people in SuperNET slack! http://slackinvite.supernet.org/ automatically sends you an invite

I am just a simple C programmer

MrCluster87

  • Hero Member
  • *****
  • Karma: +81/-3
  • Offline Offline
  • Posts: 855
    • View Profile
    • youtube
Re: InstantDEX beta
« Reply #6 on: July 06, 2015, 10:43:45 am »

jl777

  • Hero Member
  • *****
  • Karma: +718/-123
  • Offline Offline
  • Posts: 6170
    • View Profile
Re: InstantDEX beta
« Reply #7 on: August 27, 2015, 04:59:37 am »

Logged
There are over 1000 people in SuperNET slack! http://slackinvite.supernet.org/ automatically sends you an invite

I am just a simple C programmer

yassin54

  • Hero Member
  • *****
  • Karma: +240/-14
  • Offline Offline
  • Posts: 2503
  • I am Homer, Sorry my english is Bad!!
    • View Profile
Re: InstantDEX beta
« Reply #8 on: August 27, 2015, 08:52:58 am »

bidji29

  • Sr. Member
  • ****
  • Karma: +53/-11
  • Offline Offline
  • Posts: 250
    • View Profile
Re: InstantDEX beta
« Reply #9 on: August 27, 2015, 01:14:48 pm »

Logged

abctc

  • Hero Member
  • *****
  • Karma: +148/-13
  • Offline Offline
  • Posts: 1396
    • View Profile
Logged
Welcome to the Nxt generation of crypto!   Magis quam Moneta (More than a Coin)
"Do not worry, it is an attack" (c) Jean-Luc

jl777

  • Hero Member
  • *****
  • Karma: +718/-123
  • Offline Offline
  • Posts: 6170
    • View Profile
Re: InstantDEX beta
« Reply #11 on: September 10, 2015, 05:47:59 pm »

Just released a version of InstantDEX core that adds support for a meta-exchange called "wallet"
This is not really an exchange, but orderbooks are maintained for all the "wallet" exchanges and it enables direct BTC <-> NXT atomic exchanges for NXT and NXT assets for BTC.

Any coin that support custom p2sh redeemscripts would work also, but for now BTC is the main gen1 coin I have tested with.

James
Logged
There are over 1000 people in SuperNET slack! http://slackinvite.supernet.org/ automatically sends you an invite

I am just a simple C programmer

lucky88888

  • Hero Member
  • *****
  • Karma: +42/-14
  • Offline Offline
  • Posts: 694
  • NXT-E328-UJDF-KTGH-9C6YQ
    • View Profile
Re: InstantDEX beta
« Reply #12 on: September 11, 2015, 01:56:09 am »

you are incredible james.

i had lots of doubt since the beginning of your many endeavors as i never would have thought someone as passionate as you would pop out in our lives.

for my doubts and mistakes i missed out on all the profitable assets you have released. especially when i first heard of supernet, i thought wow, its a really really huge project and things are bound to mess up, i mean i thought these are the kind of things that huge corporations usually tackles, but you did a great job and have a really strong management skill and overcome all sorts of problems that arises.

you are starting to feel like bcnext, a genius in all aspects.
wished i had bought in many of the early assets, well i hope im still early  ;).
Logged
NXT-E328-UJDF-KTGH-9C6YQ
8897013707391239174

Jose

  • Global Moderator
  • Sr. Member
  • *****
  • Karma: +78/-1
  • Offline Offline
  • Posts: 403
    • View Profile
Re: InstantDEX beta
« Reply #13 on: October 18, 2015, 11:06:37 am »

Related to this post I've just seen:
https://nxtforum.org/index.php?topic=10095.0

Will it be possible (in the future, if ever ;D) to trade on leverage in Instandex?
Maybe some 3rd party coin/asset holders could lend them in some way, so that traders could use those units to trade, in exchange for some fee?
Logged

JZA

  • Full Member
  • ***
  • Karma: +18/-0
  • Offline Offline
  • Posts: 147
  • Looking for the NXT big thing
    • View Profile
Re: InstantDEX beta
« Reply #14 on: August 06, 2016, 08:05:46 am »

whatis the status on InstantDEX why is it still beta? any 1.0 Launch prediction?
Logged
NXT stufff, NXT-TUAH-6PVY-S2KR-AW4RK

sigwo

  • Full Member
  • ***
  • Karma: +14/-0
  • Offline Offline
  • Posts: 128
  • Founder, Darcrus
    • View Profile
    • Sigwo Technologies
Re: InstantDEX beta
« Reply #15 on: August 20, 2016, 07:55:25 pm »

Tuesday, you should know this by now...
Logged
 

elective-stereophonic
elective-stereophonic
assembly
assembly