Coder Social home page Coder Social logo

Comments (2)

shekenahglory avatar shekenahglory commented on June 24, 2024

The output is from the specification used for rippleAPI https://ripple.com/build/rippleapi/#order, where direction is determined solely by the tfSell flag https://ripple.com/build/transactions/#offercreate-flags - if this flag is not set, its considered a buy. Note that some offers here have XRP as the quantity and totalPrice in USD, while others have the quantity in USD and totalPrice in XRP. One or the other is probably what you are thinking of as a sell, as they'd show up on opposite sides of the orderbook.

from rippled-historical-database.

professorhantzen avatar professorhantzen commented on June 24, 2024

In this case, the "direction" should not be included. It is misleading and provides no useful information. The correct implementation of the current behaviour would be to include a "tfSell" boolean in the responses (but it's doubtful many would be interested in the state of this flag anyway).

As I understand it, the tfSell flag does not relate to the users perceived "direction" of a given trade. That is determined by the users arbitrarily-chosen perspective on the two currencies about which they are requesting information. Unfortunately, for a response that may include a variety of currency pairs, returning "correct" results may require some kind of widespread architectural change.

What users would generally expect of a "direction" field would be as @ihomp described - the "buy" or "sell" would be reported as relative to the user-attributed "order" of the base/counter pairing of the supplied currencies. In this case however, a discrepancy between the way rippled internally stores transactions, and the way most users expect to see them would need to be addressed in the historical database (and presumably also the rippleAPI, though I am not familiar with if/how it does that as I don't use it).

What I'm meaning, is something such as an array called "trade_perspective", that contains the two currencies involved in the request, that could be used to determine the "buy" or "sell" direction returned to the user: { trade_perspective: [ "XRP", "USD" ] }

However, a simpler solution that could work for all cases is to simply rely on a canonical "order", and provide a user-requestable "flip" for such default results that do not match user expectation. Eg, resort to "alphabetise" as the system-wide canonical/default "order" for base/currency pairs, and enable the user to specify "flip"'s of either single currencies (to affect many results), or currency pairs (to affect specific results) in request headers to return whichever don't match their expectations to the order they expect.

It's arguable however that almost everyone expects XRP to be the base in most requests, so perhaps pairings involving XRP could be the only exemption from the base/counter alphabetising rule, and "flip" could default to on for XRP paired currencies.

This is an unfortunate situation - but I can't see how a "direction" can be established usefully without involving the user to determine their perspective in order to provide meaningful results.

from rippled-historical-database.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.