Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orders not placed in gdax even though the script says it did #2

Open
Lasterie opened this issue Aug 9, 2017 · 20 comments
Open

Orders not placed in gdax even though the script says it did #2

Lasterie opened this issue Aug 9, 2017 · 20 comments

Comments

@Lasterie
Copy link

Lasterie commented Aug 9, 2017

Hi!

Love the script. I got buy orders working, but sell orders won't execute:

Wednesday, Aug 09, 2017 at 02:44:52 PM UTC || TWEET MATCHED || xxxxxxxxx
Wednesday, Aug 09, 2017 at 02:44:52 PM UTC || Available to trade: {{notzero}} LTC, {{notzero}}  ETH, {{notzero}} BTC, {{notzero}}  EUR
Wednesday, Aug 09, 2017 at 02:44:52 PM UTC || PLACING ORDER
{
    "size": "0.001",
    "type": "market",
    "side": "sell",
    "product_id": "BTC-EUR"
}
Wednesday, Aug 09, 2017 at 02:44:52 PM UTC || One of {"price", "funds", "size"} is zero! Order not placed.

This is the relevant part of the config:

    {
     	'handles' : ['edited'],
        'condition' : '"edited',
        'orders' : [
            { 
              	'side' : 'sell',
                'type' : 'market',
                'product_id' : 'BTC-EUR',
                'size' : '{available[BTC]}*0.01'
            }
	]
    }

Can anyone point me in the right direction?

@nellore
Copy link
Owner

nellore commented Aug 9, 2017

"The smallest order you can place for a buy or sell trade on GDAX is 0.01 BTC, ETH, or LTC," from https://support.gdax.com/customer/en/portal/articles/2426595-gdax-limits-for-deposits-withdrawals-trades-and-balances, so that particular order isn't possible. But you're right, the reported error isn't accurate, and I think the code that handles checking for this is off too. (Looking to see if one of price, funds, or size is too close to zero is wrong; it should be checking only size.) If you'd like vickitrix to attempt to place all your orders anyway, remove the if statement here: https://github.com/nellore/vickitrix/blob/master/vickitrix/__init__.py#L212 .

@Lasterie
Copy link
Author

Lasterie commented Aug 9, 2017

Thanks! I ran into another issue though. Could it be correct that Gdax requires the input for "size" to have a maximum number of decimals? I have orders placed via the script, but they don't show up in gdax. When I put "0.1" hard coded as the size (instead of {{available[BTC]}*0.1), it works.

@nellore
Copy link
Owner

nellore commented Aug 9, 2017

{available[BTC}*0.1 means "how much BTC you have available to trade times 0.1"; right now, you have so little available to trade (note that limit orders you've already placed will make your BTC unavailable to trade!) that multiplying it by 0.1 gives a value < 0.01.

@Lasterie
Copy link
Author

Lasterie commented Aug 9, 2017

That makes sense, but I place an order > 0.01:

Wednesday, Aug 09, 2017 at 03:56:07 PM UTC || PLACING ORDER
{
    "size": "0.015",
    "type": "market",
    "side": "sell",
    "product_id": "BTC-EUR"
}
Wednesday, Aug 09, 2017 at 03:56:07 PM UTC || Order placed.

And the order doesn't show up on gdax.

@nellore
Copy link
Owner

nellore commented Aug 9, 2017

You've placed a market order: http://www.investopedia.com/terms/m/marketorder.asp . It's executed immediately. To see what went down, click your gravatar in the upper right on GDAX, then click Fills.

@Lasterie
Copy link
Author

Lasterie commented Aug 9, 2017

Yes, I checked but the orders are not there. There is one: an order of 0.01000000. It is placed by the vickitrix script. But by hard setting the "size" to "0.01" like this. This works immediatly and I see the order get filled.

   	'side' : 'sell',
                'type' : 'market',
                'product_id' : 'BTC-EUR',
                'size' : '0.01'

Instead of this (which doens't work):

   	'side' : 'sell',
                'type' : 'market',
                'product_id' : 'BTC-EUR',
                'size' : '{available[BTC]}*0.1'

Thanks so much for your quick replies!

@Lasterie
Copy link
Author

Lasterie commented Aug 9, 2017

Quick follow-up, I even tried with a larger amount, but the market order didn't get placed:

Wednesday, Aug 09, 2017 at 04:12:30 PM UTC || PLACING ORDER
{
    "size": "0.0287318114758",
    "type": "market",
    "side": "sell",
    "product_id": "BTC-EUR"
}
Wednesday, Aug 09, 2017 at 04:12:31 PM UTC || Order placed.

@Lasterie
Copy link
Author

Lasterie commented Aug 9, 2017

When I copy/paste the size in Gdax (the website itself, not via the API), it displays this error:

https://i.imgur.com/4TxjcaH.png

"Enter a valid value. The two closest values are 0,02873181 and 0,02873182"

Which led me to think, is there a maximum number of digits?

@nellore
Copy link
Owner

nellore commented Aug 9, 2017

No idea what's going on here! Maybe we can debug live in the Gitter at some point? https://gitter.im/nellore/vickitrix .

@Lasterie
Copy link
Author

Yeah sure, can you point me to a doc with info how to setup live debugging?

@Lasterie Lasterie changed the title Order not placed because "One of {"price", "funds", "size"} is zero" Orders not placed in gdax even though the script says it did Aug 10, 2017
@Lasterie
Copy link
Author

I tried it with a limit order, but the issue remains: the order doesnt get placed in Gdax, while the script says it said it did:

Config:

        'orders' : [
            { 
              	'side' : 'sell',
                'price' : '{inside_ask}',
                'type' : 'limit',
                'product_id' : 'BTC-EUR',
                'size' : '{available[BTC]}*0.1'
            }

Output:

Thursday, Aug 10, 2017 at 06:39:01 AM UTC || PLACING ORDER
{
    "price": "2885",
    "size": "0.0163228137379",
    "type": "limit",
    "side": "sell",
    "product_id": "BTC-EUR"
}
Thursday, Aug 10, 2017 at 06:39:01 AM UTC || Order placed.

@Lasterie
Copy link
Author

I even tried it without the "*0.1", so with the entire btc funds. Script said it placed the order, but it didn't make it to gdax. Again, it does work when setting the size to a fixed value like "0.1".

@Lasterie
Copy link
Author

I found it. As I thought, the problem is the number of decimals of "size" when the order is placed. I "hacked" this into init.py on line 127 to ensure the size is of a length of maximum 7 digits.

dough[account['currency']] = (account['available'][:7]) if len(account['available']) > 7 else account['available']

Now it works, the order is placed! Question: is this the proper way to do it? (I guess not, I'm not a good developer)

@nellore
Copy link
Owner

nellore commented Aug 10, 2017

Interesting! I do not think the issue is that the size must be a maximum of seven characters; if that were true, you could not for example trade more than 9999999 of a given currency at once. It is possible not more than five decimal places are permitted here. You could try

dough[account['currency']] = '{0:.5f}'.format(float(dough[account['available']]))

. I'll look into this a bit more soon.

@Lasterie
Copy link
Author

Lasterie commented Aug 10, 2017

Thanks, that's a better approach indeed! I fixed the typo (the second "currency" should be "available"), but I still get this error when I run the script:

[Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/vickitrix/__init__.py", line 596, in go
    get_dough(gdax_client, status_update=True)
  File "/usr/local/lib/python2.7/site-packages/vickitrix/__init__.py", line 127, in get_dough
    dough[account['currency']] = '{0:.5f}'.format(float(dough[account['available']]))
KeyError: u'_MYETHERBALANCE_'
]

@nellore
Copy link
Owner

nellore commented Aug 10, 2017

Oh, sorry, the code shouldn't be changed there at all! Instead, try changing L195-L202 to

order[money] = '{0:.5f}'.format(float(eval(
                                    order[money].format(
                                            tweet='status.text',
                                            available=self.available,
                                            inside_bid=inside_bid,
                                            inside_ask=inside_ask
                                        )
                                )))

@Lasterie
Copy link
Author

Lasterie commented Aug 11, 2017

Thanks, tried that. The number of )))) is one too many in your last line.

@nellore
Copy link
Owner

nellore commented Aug 11, 2017

Fixed! Thanks; I'll put this in the next version of vickitrix.

@Lasterie
Copy link
Author

There's a small problem with this fix, it rounds the number to 5 decimals, but sometimes this leads to trying to sell a stack that is higher than you have. For instance:

Wednesday, Aug 16, 2017 at 02:46:21 AM UTC || Available to trade: 0.0000000000000000 LTC, 0.0000000000000000 ETH, 0.2076559273792344 BTC, 0.0000268925485000 EUR
Wednesday, Aug 16, 2017 at 02:46:22 AM UTC || PLACING ORDER
{   
    "size": "0.20766",
    "type": "market",
    "side": "sell",
    "product_id": "BTC-EUR"
}

You see that the available btc is 0.2076559273792344 but it tries to sell 0.20766, which you don't have.

@razorberry
Copy link

I am having a similar problem, but i'm not sure that its down to rounding errors.

Monday, Sep 04, 2017 at 06:31:55 PM EDT || TWEET MATCHED || @Vickibotethbtc: ETH
BTC  I am going long ETHBTC #eth #ethereum
Monday, Sep 04, 2017 at 06:31:55 PM EDT || Available to trade: 0.000000000000000
0 LTC, 0.0000000000000000 ETH, 0.0050250894717000 USD, 0.0281246047054000 BTC
Monday, Sep 04, 2017 at 06:31:56 PM EDT || PLACING ORDER
{
    "price": "0.07155",
    "size": "0.0281246047054",
    "type": "limit",
    "side": "buy",
    "product_id": "ETH-BTC"
}
Monday, Sep 04, 2017 at 06:31:56 PM EDT || Order placed.
Monday, Sep 04, 2017 at 06:31:56 PM EDT || Available to trade: 0.000000000000000
0 LTC, 0.0000000000000000 ETH, 0.0050250894717000 USD, 0.0281246047054000 BTC

The size is the correct amount, but the order still didn't go through. Perhaps the limit price changed before it went through. Does gdax provide an error in this case in order to retry?

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

No branches or pull requests

3 participants