Closed ghost closed 9 years ago
@faizkhan00: please help me to understand and correct me where I'm wrong:
metadex_obj
are created by add_mdex_fields()
metadex_obj
are used to describes or represents an offersort_mdex_obj()
sorts an array of metadex_objs
metadex_objs
are sorted based on metadex_obj[10]
metadex_obj[10]
is the block height of an offersort_mdex_obj()
therefore sorts metadex_objs
based on their block heightmetadex_objs
at similar height are further sorted based on the lexical value of metadex_objs[1]
metadex_obj[1]
is the txid of an offermetadex_objs
at similar height are therefore further lexically sorted based on txids of an offersort_mdex_obj()
is used by gettradessince_MP
and gettradehistory_MP
sort_mdex_obj()
is also used by getorderbook_MP
I think I got this.
I'm wondering about three points:
Dexx, your understanding is correct:
I'm wondering about three points:
*an orderbook should primarily be sorted by price, not chronologically based on height
*it seems as if this approach ignores position of an order within a block
*what's the purpose of sorting based on txids?
1 - An orderbook UI should be sorted by price, but the RPC layer is for integrators who almost always will use the RPC as a starting point for seeding their data management layer. I'm pretty much expecting that integrators add UI niceties on their own after they consume the data at the RPC, and thus the sort by blockheight seemed like a reasonable ordering to go with.
2 & 3 - I initially was looking to sort by the mp_tx_idx (mp tx index within a block) since that information is readily available, but ended up using lexical sorting because the mp_tx_idx data isn't always accurate (sometimes the same number is tagged per tx per block). I didn't try attaching more data to the CMPMetaDEx object for use (such as txindex) because the internals are already suffering from major changes, but could be changed down the line
Ah, I see your point and reasoning and I believe it's based on terminology and how things are implemented at the moment.
gettradessince_MP, gettradehistory_MP and getorderbook_MP currently show offers, not trades. In fact they mostly differ by one or two lines.
There are three relevant things imho:
sometimes the same number is tagged per tx per block
How is that possible? It the method broken?
How is that possible? It the method broken?
Perhaps not broken, I looked at the code a little closer and it may be that I was seeing something else at the time. I think sorting by idx is ideal so I'm all for revisiting this (possibly removing lexical sort?), because having some kind of determinism in the output is important, and I might have just confused myself looking at all the numbers :X
You can see the code to generate idx here: https://github.com/mastercoin-MSC/mastercore/blob/mscore-0.0.9/src/mastercore.cpp#L1539-L1544
gettradessince_MP, gettradehistory_MP and getorderbook_MP currently show offers, not trades. In fact they mostly differ by one or two lines.
This should change soon, there was a recent series of commits by Zathras that made historical trades accessible, I should be working on that over the weekend so these calls display trade data similar to the new gettrade_MP
good points on unmatched offers, currently there isn't any storage of active/inactive (orders are simply removed when filled) but there should be detection and exposure of the data on some level (not quite sure where but as you alluded to getopenorders_MP could be the place for it)
Ah thanks.
I found something odd by the way while testing those calls, maybe it's just me, but you could try the following:
mastercore-cli gettradessince_MP 1407437168 | grep '"block" :'
This looks fine, an ordered list of block numbers from the trades. And then:
mastercore-cli gettradessince_MP 1407437167 | grep '"block" :'
Or any number less than 1407437168. All blocks have a height of -1 for me.
Yep good discussion - as per our Skype chats I only make completed trades available in tradelistdb which fits with DexX's comments...
To recap that discussion: Trades are matched offers that have actually traded tokens Offers are expressions of willingness to trade that may or may not have been traded (open / closed)
Thus gettradessince and gettradehistory are reflective of trades and thus can reference the historic tradelistdb, but getorderbook are reflective of offers so must reference the current metadex map.
Hope that helps :) On 08/11/2014 3:56 PM, "Faiz Khan" notifications@github.com wrote:
gettradessince_MP, gettradehistory_MP and getorderbook_MP currently show offers, not trades. In fact they mostly differ by one or two lines.
This should change soon, there was a recent series of commits by Zathras that made historical trades accessible, I should be working on that over the weekend so these calls display trade data similar to the new gettrade_MP
good points on unmatched offers, currently there isn't any storage of active/inactive (orders are simply removed when filled) but there should be detection and exposure of the data on some level (not quite sure where but as you alluded to getopenorders_MP could be the place for it)
— Reply to this email directly or view it on GitHub https://github.com/mastercoin-MSC/mastercore/pull/197#issuecomment-62245868 .
Yep good discussion - as per our Skype chats I only make *completed* trades
available in tradelistdb which fits with DexX's comments...
Are there any plans to make offers available anywhere? from Dexx's comments that information will be needed eventually (and not having it would be an oversight), just wondering about your 0.02c there...
edit: I guess there won't be getoffershistory? Or a historical offer list (including empty/unmatched). This seems like an oversight in my view, but then again what do I know :)
Offers are always available from the blockchain so no need to store a second time - I already modified your metadex case in populateRPCTransactionObject to use parsing off the wire - tl:dr you can get any metadex offer past/present just with regular gettransction_MP like any other tx :)
Thanks Z On 08/11/2014 4:20 PM, "Faiz Khan" notifications@github.com wrote:
Yep good discussion - as per our Skype chats I only make completed trades available in tradelistdb which fits with DexX's comments...
Are there any plans to make offers available anywhere? from Dexx's comments that information will be needed eventually (and not having it would be an oversight), just wondering about your 0.02c there...
— Reply to this email directly or view it on GitHub https://github.com/mastercoin-MSC/mastercore/pull/197#issuecomment-62246454 .
What's your interpretation of an offer? I actually assumed the results of gettradessince_MP, gettradehistory_MP and getorderbook_MP are offers, at least at the moment.
I see an offer as a message offering trade terms, but it does not become an actual 'trade' until tokens are exchanged.
Trade history for example should show your history of trades not history of offers - offers aren't trades and thus shouldn't be part of any gettrade calls imo.
Thanks Z On 08/11/2014 5:00 PM, "dexX7" notifications@github.com wrote:
What's your interpretation of an offer? I actually assumed the results of gettradessince_MP, gettradehistory_MP and getorderbook_MP are offers, at least at the moment.
— Reply to this email directly or view it on GitHub https://github.com/mastercoin-MSC/mastercore/pull/197#issuecomment-62247301 .
Well yeah, I was just wondering about "Are there any plans to make offers available anywhere?".
Or it's because I'm not aware of the whole picture and there is an obstacle, for example the permanent deletion of offers that were matched.
@zathras-crypto: the reason why I'm actually not such a mega huge fan of gettransaction_MP is because parsing and interpretation are done on the fly. "Parse once, verify and seal" seems more robust.
Regarding this PR: Sorting of CMPMetaDEx in vectors can be done with bool MetaDEx_compare::operator() in combination with std::sort:
std::vector<CMPMetaDEx> vMetaDexObjs; // holds unordered data
...
MetaDEx_compare compareByHeight; // in mastercore_dex.h
std::sort (vMetaDexObjs.begin(), vMetaDexObjs.end(), compareByHeight); // blk height + tx pos
Dexx, can you remake your PR onto this repo directly? I'm not sure the merge of your code + my code makes sense now that I look at it ( from dexX7/mcore-order-last-since-by-position to mastercore/0.0.9)
Thank you sir :)
Yup, I can. Are you fine with the MetaDexObjectToJSON function and the rest?
I think so, I came here to review the fully merged code and it was a mess, so once we have something clean it'll be easier to tell if something needs to be fixed :)
depends/includes on https://github.com/mastercoin-MSC/mastercore/pull/196