Pages:
Author

Topic: [Nxt] API of Nxt - page 7. (Read 37336 times)

legendary
Activity: 2142
Merit: 1010
Newbie
January 22, 2014, 11:36:46 AM
Also the API for this asset exchange test system doesnt allow most API commands.  for example, we cannot even get balance or view transaction details.

It does. U can.
full member
Activity: 238
Merit: 100
January 22, 2014, 09:33:29 AM
Core doesn't prevent from doing dumb things, client soft is supposed to do it.

I'll add asset balance API.

Also the API for this asset exchange test system doesnt allow most API commands.  for example, we cannot even get balance or view transaction details.  Im assuming that there will be details available for asset exchange transactions to the level that there are of the regular API of getTransaction where account to/from is  shown as well as the amount transferred and fee, etc?
legendary
Activity: 2142
Merit: 1010
Newbie
January 22, 2014, 05:37:37 AM

quick question re. balance: what's the deal about these three different replies:

effectiveBalance - 0
unconfirmedBalance - 791500
balance - 791500

is the 'effectiveBalance' something old that should be dropped?



Effective balance shows ur forging power.
legendary
Activity: 1181
Merit: 1018
January 22, 2014, 05:36:22 AM

quick question re. balance: what's the deal about these three different replies:

effectiveBalance - 0
unconfirmedBalance - 791500
balance - 791500

is the 'effectiveBalance' something old that should be dropped?

legendary
Activity: 1181
Merit: 1018
January 22, 2014, 05:21:23 AM

Thanks!
legendary
Activity: 2142
Merit: 1010
Newbie
January 22, 2014, 04:53:34 AM

mwoa.. what are the matching engine rules? how does it work? now I am getting really curious and excited! 

Standard matching algo:

Code:
    static void matchOrders(long assetId) {

        TreeSet sortedAskOrders = Nxt.sortedAskOrders.get(assetId);
        TreeSet sortedBidOrders = Nxt.sortedBidOrders.get(assetId);

        while (!sortedAskOrders.isEmpty() && !sortedBidOrders.isEmpty()) {

            AskOrder askOrder = sortedAskOrders.first();
            BidOrder bidOrder = sortedBidOrders.first();

            if (askOrder.price > bidOrder.price) {

                break;

            }

            int quantity = askOrder.quantity < bidOrder.quantity ? askOrder.quantity : bidOrder.quantity;
            long price = askOrder.height < bidOrder.height || (askOrder.height == bidOrder.height && askOrder.id < bidOrder.id) ? askOrder.price : bidOrder.price;

            if ((askOrder.quantity -= quantity) == 0) {

                askOrders.remove(askOrder.id);
                sortedAskOrders.remove(askOrder);

            }

            askOrder.account.addToBalanceAndUnconfirmedBalance(quantity * price);

            if ((bidOrder.quantity -= quantity) == 0) {

                bidOrders.remove(bidOrder.id);
                sortedBidOrders.remove(bidOrder);

            }

            bidOrder.account.addToAssetAndUnconfirmedAssetBalance(assetId, quantity);

        }

    }
legendary
Activity: 1181
Merit: 1018
January 22, 2014, 04:50:56 AM

mwoa.. what are the matching engine rules? how does it work? now I am getting really curious and excited! 
legendary
Activity: 2142
Merit: 1010
Newbie
January 22, 2014, 04:44:15 AM

an asset exchange needs a 'matching engine' with rules coded into it, that determine how buy and sell orders are matched and assets are transferred.

I don't know if anything such like is already in place or planned for the nxt asset exchange.  Huh  Shocked

Please enter coments and discussion here !

Matching engine is launched each time someone places an order.
legendary
Activity: 1181
Merit: 1018
January 22, 2014, 04:24:50 AM

an asset exchange needs a 'matching engine' with rules coded into it, that determine how buy and sell orders are matched and assets are transferred.

I don't know if anything such like is already in place or planned for the nxt asset exchange.  Huh  Shocked

Please enter coments and discussion here !
legendary
Activity: 1181
Merit: 1018
January 22, 2014, 04:08:44 AM

C-f-B or Klee:

I am a bit slow to catch up here - things are moving fast. I know a bit about CME commodities futures trading, and the FIX API: http://en.wikipedia.org/wiki/Financial_Information_eXchange

In principal, asset exchange functions like this:

There are TWO fundamental order types: Market Orders and Limit Orders.

Limit Orders have a guaranteed price - hence 'limit order', but they don't have guaranteed execution: if there is no counteraprty at that price, the order will just hang there until it expires (if ever)

Market Orders have a guaranteed fast execution, but no guaranteed price. You get your execution 'immediately', for 'next best' price, whatever that may be.

So a market BUY order is matched againt the next best limit SELL order - i.e. the LOWEST sell price, and a market SELL order is matched against the HIGHEST buy order.

The LOWEST sell price is one tick above the HIGHEST buy price. The difference between these two is the 'spread'. Now if there are only limit orders, nothing much happens. The HIGHEST limit buy order does not just suddenly jump up on its own and buys for the LOWEST sell price - it can't, because it is a limit order. It may be that a new limit order or is entered, that crosses up or down to where another limit order of the opposite order book happens to lurking around - but that is rather rare.

The real action comes from the interplay between market orders and limit orders, and the fact that a trade is always sort of an annihilation of opposing particles: SellOrder + BuyOrder ->TradeExecution. Sort of like positron+electron -> photon


Apologies if I should be preaching to the choir here - I have no idea about you guys backgrounds. But latching on to opticalcarriers question there, I'd also be interersted in getting to know how to use MARKET orders and create assets ledgers and stuff like that in order to make a powerful asset exchange on nxt ...
 



legendary
Activity: 2142
Merit: 1010
Newbie
January 22, 2014, 01:33:02 AM
ah. I backtraced and found where/how I did a copy/paste error.

ok so the system doesnt prevent you from doing anything dumb.  will this be fixed in the future?

And it really would be useful to see the balance of assets, not just of NXT.

Core doesn't prevent from doing dumb things, client soft is supposed to do it.

I'll add asset balance API.
full member
Activity: 238
Merit: 100
January 21, 2014, 06:54:21 PM
ah. I backtraced and found where/how I did a copy/paste error.

ok so the system doesnt prevent you from doing anything dumb.  will this be fixed in the future?

And it really would be useful to see the balance of assets, not just of NXT.
legendary
Activity: 2142
Merit: 1010
Newbie
January 21, 2014, 04:06:24 PM
but then you cannot look up that asset 7126304194855053556:

ncli getAsset holms.cloudapp.net 7126304194855053556

    errorCode: 5
    errorDescription: Unknown asset

Come to find out that 7126304194855053556 that gets returned as "asset" from getBidOrder is really the account that issued the asset in question:

This is coz u placed an order with asset set to 7126304194855053556:

http://holms.cloudapp.net:6874/nxt?requestType=getTransaction&transaction=4771732437964521054

{"sender":"16155265664111966451","fee":1,"amount":0,"timestamp":5039362,"referencedTransaction":"0","confirmations":1,"subtype":3,"block":"1624353333851565570","attachment":{"price":1,"asset":"7126304194855053556","quantity":10},"senderPublicKey":"0db87c178e62699c467a8e90977fb2e95782dfafc7dee65ffa6ba5143743023e","type":2,"deadline":100,"signature":"38483a6099ff71b103defcead8c42195e0e10b8492d2e5bc5004a9c4fe95390f94b976315343106 7005312431118d611373516194c7b2372c101a2f01e89aac1","recipient":"1739068987193023818"}
full member
Activity: 238
Merit: 100
January 21, 2014, 03:55:03 PM
Im testing the Asset Exchange using my CLI based API interface and there doesnt appear to be a way currently to determine which assets are owned by which accounts.  Also, Ive found something odd with how get bid/ask order ID API works:

#  ncli getBidOrder holms.cloudapp.net 4771732437964521054

    account: 16155265664111966451
    asset: 7126304194855053556
    price: 1
    quantity: 10

but then you cannot look up that asset 7126304194855053556:

ncli getAsset holms.cloudapp.net 7126304194855053556

    errorCode: 5
    errorDescription: Unknown asset

Come to find out that 7126304194855053556 that gets returned as "asset" from getBidOrder is really the account that issued the asset in question:

# foobar getAsset holms.cloudapp.net 7527606552308067548

    account: 7126304194855053556
    description: nxTestAsset
    name: nxTest
    quantity: 60000


Ive implemented 40 APIs in my bash script that lets you run CLI commands:

Usage:  ncli APIcmd server option1 option2...
where server is IP/DNS or use l to query localhost and options are APIcmd specific

It uses http not https due to limitation of curl.  http://pastebin.com/JAzy5RuX

EDIT:  Ive hardcoded the testnet port 6874 in there for the assetexchange APIs commands.  all others are 7874
legendary
Activity: 1181
Merit: 1018
January 18, 2014, 08:10:58 AM


ah - I seem to have made a misconception there from the 'Diffie–Hellman–Merkle key exchange' definition, which has Merkle's name in it, but appears to be different form a Merkle tree.  Shocked
Thanks!
legendary
Activity: 2142
Merit: 1010
Newbie
January 18, 2014, 06:55:47 AM

NRS question -

maybe someone who knows (probably one of the core edevelopers) can give me a liitle hint here in respect to the blockchain operations:

as I understand the blockchain is an implementain of a Merkle tree, as is with Bitcoin.
Am I right with the assumption that the blockchain of NXT works in a similar manner as the blockchain of Bitcoin (hence the quick appearance of NXT blockchain explorers, etc),
and that the the difference between NXT and bitcoin lies in the crypto (curve25519, incl PoS & transparent forging) BEHIND the blockchain?

So that if I want to get a grip on the internals of NXT, I could start out by getting a grip on the blockchain operations, which I could do by consulting Bitcoin blockchain documentation?  Grin

Cheers,
l8orre

[ or is there a special thread for this that I may have missed?    Huh posted this to the general thread, but it seems to be getting lost a bit there..]
   

Nxt does NOT use Merkle tree. Payload hash is calculated by sorting all transactions in ascending order according to their IDs represented as SIGNED 64bit numbers.
legendary
Activity: 1181
Merit: 1018
January 18, 2014, 06:53:48 AM
 
NRS question -

maybe someone who knows (probably one of the core edevelopers) can give me a liitle hint here in respect to the blockchain operations:

as I understand the blockchain is an implementain of a Merkle tree, as is with Bitcoin.
Am I right with the assumption that the blockchain of NXT works in a similar manner as the blockchain of Bitcoin (hence the quick appearance of NXT blockchain explorers, etc),
and that the significant difference between NXT and bitcoin lies in the crypto (curve25519, incl PoS & transparent forging) BEHIND the blockchain?

So that if I want to get a grip on the internals of NXT, I could start out by getting a grip on the blockchain operations, which I could do by consulting Bitcoin blockchain documentation?  Grin

Cheers,
l8orre

[ or is there a special thread for this that I may have missed?    Huh posted this to the general thread, but it seems to be getting lost a bit there..]
   
full member
Activity: 224
Merit: 100
January 16, 2014, 09:13:22 AM
It would be cool if getBalance would accept a timestamp parameter so that you could get an account balance at a certain point in time.

You can do it with getAccountTransactionIds and getAccountBlockIds with a timestamp.

Thanks, that'll work. Not handy, but ok.
legendary
Activity: 2142
Merit: 1010
Newbie
January 16, 2014, 08:29:33 AM
It would be cool if getBalance would accept a timestamp parameter so that you could get an account balance at a certain point in time.

You can do it with getAccountTransactionIds and getAccountBlockIds with a timestamp.

Also getGuaranteedBalance could be used.
full member
Activity: 168
Merit: 100
IDEX - LIVE Real-time DEX
January 16, 2014, 08:22:04 AM
It would be cool if getBalance would accept a timestamp parameter so that you could get an account balance at a certain point in time.

You can do it with getAccountTransactionIds and getAccountBlockIds with a timestamp.
Pages:
Jump to: