Skip to content

added extra optional parameter "bid_amount_money" to "order.put_market_stock" RPC. - #36

Open
djpnewton wants to merge 6 commits into
viabtc:masterfrom
djpnewton:order_put_market_stock
Open

added extra optional parameter "bid_amount_money" to "order.put_market_stock" RPC.#36
djpnewton wants to merge 6 commits into
viabtc:masterfrom
djpnewton:order_put_market_stock

Conversation

@djpnewton

Copy link
Copy Markdown
Contributor

Default value is true and has no change to behavior. If the value is false then the "amount" parameter of a market bid is treated as "stock" instead of "money"

see also issue #32

replaces #35

djpnewton added a commit to djpnewton/via_jsonrpc that referenced this pull request Nov 22, 2017
@avemeva

avemeva commented Dec 24, 2017

Copy link
Copy Markdown

@djpnewton @haipome Any plans to merge it? 😄

@djpnewton

Copy link
Copy Markdown
Contributor Author

its up to @haipome but I would be happy

@avemeva

avemeva commented Feb 26, 2018

Copy link
Copy Markdown

@djpnewton Hey, any updates on this guys?

@djpnewton

Copy link
Copy Markdown
Contributor Author

I guess I just need some feedback from @haipome on whether he is ok with the direction of this PR

Comment thread matchengine/me_market.c
}
} else {
if (mpd_cmp(taker->left, maker->left, &mpd_ctx) < 0) {
mpd_copy(amount, taker->left, &mpd_ctx);

@HumanSwissArmyKnifeQP HumanSwissArmyKnifeQP May 25, 2018

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(More of a stylistic and lower priority comment than anything else.)

For a file of this size, could we not replace many of the if/else blocks with a ternary operator, to improve code readability?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure but perhaps that kind of stylistic change should probably be in a dedicated PR

@compdzwio

compdzwio commented Aug 26, 2018

Copy link
Copy Markdown

fuck, me_loader.c int ret = market_put_market_order(false, NULL, market, user_id, side, amount, taker_fee, source, /* bid_amount_money what to do? */);

me_loader.c Market records for loading databases, but the database does not have bid_amount_money, How to fill bid_amount_money when loading?

@djpnewton
djpnewton force-pushed the order_put_market_stock branch from ec54fa4 to 158d832 Compare November 22, 2018 21:56
@djpnewton

Copy link
Copy Markdown
Contributor Author

I have rebased this PR to master

@jkmaina

jkmaina commented Dec 14, 2018

Copy link
Copy Markdown

when i check the deal.stock and deal.money on finished orders using the change with the optional parameter market orders, the returned values are zero. Is this expected behavior?

@haipome

haipome commented Mar 12, 2019

Copy link
Copy Markdown
Member

This function is useful. I will read and test careful before merge it into master

@mahdi13

mahdi13 commented Aug 6, 2019

Copy link
Copy Markdown

This code has a serious bug. Sometimes the deal's money exceeds the user's balance. Because of the calculation problem on these lines of code:

        } else {
            if (mpd_cmp(taker->left, maker->left, &mpd_ctx) < 0) {
                mpd_copy(amount, taker->left, &mpd_ctx);
            } else {
                mpd_copy(amount, maker->left, &mpd_ctx);
            }
        }

Then matching engine try to subtract this money value from the balance:

balance_sub(taker->user_id, BALANCE_TYPE_AVAILABLE, m->money, deal);

But the balance is not enough and the balance_sub method return NULL value. No one checks the returned value after this method call. So we'll have a duplicated balance value on the user balance history table. Actually, we'll have a subtract record (minus change value) on db, but the balance field of this record is the same as the previous record's balance field. The result is that the user put a bid market order and receive the requested stock amount without any change in it's money balance

@mahdi13

mahdi13 commented Aug 7, 2019

Copy link
Copy Markdown

The problem is on balance calculation. This line should be moved after the balance check:

mpd_del(money_required);

@djpnewton

Copy link
Copy Markdown
Contributor Author

oh i see, money_required is being freed too soon

@djpnewton

Copy link
Copy Markdown
Contributor Author

updated

@djpnewton
djpnewton force-pushed the order_put_market_stock branch from f49f462 to 1a5541a Compare August 24, 2019 23:44
@djpnewton

Copy link
Copy Markdown
Contributor Author

rebased

the "amount" parameter now refers to the order "stock"
…t_stock" RPC.

Default value is true and has no change to behavior. If the value is false then the "amount" parameter of a market bid is treated as "stock" instead of "money"
@djpnewton
djpnewton force-pushed the order_put_market_stock branch from 1a5541a to 3f789c2 Compare October 31, 2019 03:06
@ceyonur

ceyonur commented Nov 29, 2020

Copy link
Copy Markdown
Contributor

any update on this? currently this functionality cannot be used as: "I want to buy x amount stock from the market". I believe this is a de facto standard among exchange services. They all provide "stock amount" in market orders.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants