Giter Club home page Giter Club logo

openapi-proto-messages's People

Contributors

amusleh-spotware-com avatar evgenisedin avatar karnauskas avatar shkhannanov avatar vesofx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openapi-proto-messages's Issues

P&L calculation pseudo-code correction

Hello,
at https://spotware.github.io/open-api-docs/profit-loss-calculation/
the following pseudo code is indicated to calculate rate for converting P&L to deposit currency

fromAsset = "JPY"
toAsset = "USD"

// rate will be our conversion result
rate = 1

// symbols are the ProtoOASymbolsForConversionRes symbols field
symbols[] = ProtoOASymbolsForConversionRes(fromAsset,toAsset)

asset = fromAsset 

FOR symbol in symbols:
    IF symbol.baseAsset == asset:
        rate = rate * symbol.price
        asset = symbol.quoteAsset
    ELSE:
        rate = rate * 1 / symbol.price
        asset = symbol.baseAsset

However from the pseudo code indicated it's not clear to me if symbol.price represents the bid price or the ask price of the symbol? I should consider it the ask price since I'm supposed to buy the deposit currency with the symbol quote asset?
For now this is my solution but I'm not 100% sure if it's totally correct.

fromAsset = "JPY"
toAsset = "USD"

// rate will be our conversion result
rate = 1

// symbols are the ProtoOASymbolsForConversionRes symbols field
symbols[] = ProtoOASymbolsForConversionRes(fromAsset,toAsset)

asset = fromAsset 

FOR symbol in symbols:
    IF positionDirection == SHORT:
        closePrice = symbol.ask
    ELSE:
        closePrice = symbol.bid


    IF symbol.baseAsset == asset:
        rate = rate * closePrice
        asset = symbol.quoteAsset
    ELSE:
        rate = rate * 1 / closePrice
        asset = symbol.baseAsset

Open API Suggestions

Hello there,
following my tests on Open API I would suggest:

  • Create a request for retrieving the deals related to a position: given a position id, I would like to retrieve all the deals pointed to the position; This helps retrieving historic positions and their profit; Currently we have to request all deals in a time interval and then search for the ones linked to a position id. But this is imited to a certain interval of time and returns unused deals.
  • Add leverage field for each symbol. The account leverage is only indicative: each symbol has its own leverage, and quite often leverage is different across asset classes;
  • Create a request or add a field indicating if the market of a symbol is open. The scheduled openings/closings are not enough. Markets can be closed also on unexpected conditions and it's not very rare situation;
  • I'm user (and big fan) of cTrader Web. On cTrader Web you indicate interesting information for deals. For example when I see the description of a deal, if the deal is opening volume then it's possibile to check the deals that closed the current deal/volume. On the opposite if the deal is closing volume then it's possibile to see the deals being closed by the current deal. It's possible to get this information also on Open API?
  • Please create a Req to retrieve the last known tick with last known bid and ask for a symbol. Doing this now requires a lot of implementation work on client side.
  • Why you don't provide request for retrieving equity and P&L for position? I understand that it can be inferred and calculated manually by using your interfaces, but this complicates implementations. I would suggest providing a "grossProfit" field for each position. For open positions it will provide the real time gross profit while for closed positions it will contain the gross profit at position close time. If you think this is expensive consumption of resources on your side I would say to probably rethink this as now calculating P&L from client side requires sending approximately 5-6 requests to your server. Doing this every second/tick could be expensive for you. I would like to add that you are already calculating swap and commission in deposit currency so why not provide unrealized gross profit directly calculated in deposit currency.

Some ambigous circumstances:

  • The "closePositionDetail" field of a deal is defined if the deal is a closing deal. And this is the only field I can rely on to understand if the deal is a closing deal. What if the deal is rejected/missed? In this case the "closePositionDetail" field is still defined with the position id or not? Would be useful to track also failed deals and the relative target position.
  • When making multiple asynchronous NewOrderReq, it's impossible to distinguish them during errors. When ExecutionEvent occurs we can associate event to request by using the order "label" or "comment" fields. But when errors occur it's not possible to associate a request to an event response.

Just some suggestions. I understand that your API already provides the fundamental functionalities to operate in markets.
I'm creating a framework for operating with NodeJS which uses Open API under the hood: I'm glad to contribute if you need me.

Node.js usage

Thank you for publishing the updated protobuf structure. What about updating also the Node.js usage examples?

Regards,
Vasile.

Tag new version

The last tag is 80 and the different from master is just documentation and the Go package configuration at the proto files, which I need. It's possible to release a new tag?

80...main

API Request

Since you have introduced ProtoOADealListByPositionIdReq I would suggest creating also a ProtoOAOrderListByPositionIdReq which would allow reconstructing the entire life cycle of a position without the need to make deep search and perform many requests to ProtoOAOrderListReq.

I would also suggest a ProtoOAPositionHistoryReq
which should return all the the position orders, deals, swaps... all information about a position. This will avoid sending 5-10 requests to different ProtoOA methods for composing the whole situtation of a position.

Whad do you think?

Thank you for your great job ๐Ÿ‘

Request for retrieving orders by position id

It would be great to have the following interfaces

OrderListByPositionIdReq
DealListByPositionIdReqย 
DealListByOrderIdReqย 

This would avoid sending multiple OrderListReq and DealListReq requests to your servers to link positions, orders and deals.

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.