ExchangeUnion / market-maker-bot

MM Bot for OpenDEX. Make profits via arbitrage between OpenDEX and a connected CEX account like Binance 🤖
GNU Affero General Public License v3.0
104 stars 20 forks source link

Add basic accounting capabilities #85

Open ghost opened 4 years ago

ghost commented 4 years ago

This issue is about adding basic accounting capabilities to arby for the end user. Details below.

kilrau commented 3 years ago

We just discussed adding a basic /trades endpoint which takes a date range as filter and accepts above proposed granularity, e.g. as /trades?startDate=20200101&endDate=20201231 returning data of the executed CEX trades, along with the uuid of the related OpenDEX trade + arbitrage profit.

Data fields this should return:

kilrau commented 3 years ago

This feature is needed for the "Closed CEX Trades" view in the Arby/MM Bot secion in xud-ui, which only shows closed arby trades on the CEX side + how much profit was made with the arbitrage to the OpenDEX trade: image

It also composes some of this info into a graph: image

ghost commented 3 years ago

What does order side mean under closed trades? It's always both - either buy on CEX and sell on DEX or vice versa.

kilrau commented 3 years ago

Very good point! How about now?

ghost commented 3 years ago

For the chart we'll need to data in the following format:

/profit?startDate=xyz&endDate=zyx&granularity=day

{
  result: [
    { label: '1st of Jan', profit: 0.1},
    { label: '2nd of Jan', profit: 0.025},
    ...
  ]
}

Thinking it might make sense to have a separate endpoint for the closed trades info since it's on a separate screen and does not need granularity.

ghost commented 3 years ago

Very good point! How about now?

That works.

Same question for the amount. Is it always the non-BTC asset?

kilrau commented 3 years ago

Thinking it might make sense to have a separate endpoint for the closed trades info since it's on a separate screen and does not need granularity.

It might in future...

ghost commented 3 years ago

Thinking it might make sense to have a separate endpoint for the closed trades info since it's on a separate screen and does not need granularity.

It might in future...

It just needs the date range though? startDate and endDate?

Or limit (show last 100 trades).

kilrau commented 3 years ago

Same question for the amount. Is it always the non-BTC asset?

Oh damn, that took a while. So we discussed at some point to expose CEX data only here on that mm bot page along with the profit info, since all OpenDEX trade data can be looked up in Tradehistory and we don't want to have that double.

Updated.

kilrau commented 3 years ago

Thinking it might make sense to have a separate endpoint for the closed trades info since it's on a separate screen and does not need granularity.

It might in future...

It just needs the date range though? startDate and endDate?

Or limit (show last 100 trades).

True. Adjusted to date range only in https://github.com/ExchangeUnion/market-maker-bot/issues/85#issuecomment-743145652

kilrau commented 3 years ago

I just onboarded @rsercano to this @erkarl - any questions/implementation proposal - let's track it here

rsercano commented 3 years ago

Hi, this's complicated for a single issue imo, and I guess either we need to split it into PRs, or sub issues somehow. So I was thinking to split into below PRs.

or maybe two by combining implementing & introducing parts

wdyt? @erkarl @kilrau

ghost commented 3 years ago

Introducing sequelize and a new db type arby-order.ts

Let's start with adding sequelize support and define what we're going to save to the database.

rsercano commented 3 years ago

Edited my comment to be brief, @erkarl started to implement db model

kilrau commented 3 years ago

As just discussed with @erkarl and @rsercano :

Removed Wireframe adjusted too.