0

I'm making a CoinBasePro TradingBot and I've got some error with trying to make a position.

class Trader():
    def __init__(self):
        self.public = 'Public'
        self.passphrase = 'Passphrase'
        self.secret = 'Secret'
        self.auth_client = cbpro.AuthenticatedClient(key= self.public, b64secret= self.secret, passphrase= self.passphrase)

Then, there is some RSI calculation function (float output) and direction function.

Next thing is to make a position function:

def make_pos(self, ticker):
    rsi = self.RSI_calc(ticker)
    direction = self.set_direction(ticker)
    if rsi <= 42 and direction == 'buy':
        position = self.auth_client.place_market_order(product_id= ticker, side=direction, size= self.QUANTITY)
        print(position)

You know, it should output something like { "id": "d0c5340b-6d6c-49d9-b567-48c4bfca13d2", "price": "0.10000000", "size": "0.01000000", "product_id": "BTC-USD", "side": "buy", "stp": "dc", "type": "limit", "time_in_force": "GTC", "post_only": false, "created_at": "2016-12-08T20:02:28.53864Z", "fill_fees": "0.0000000000000000", "filled_size": "0.00000000", "executed_value": "0.0000000000000000", "status": "pending", "settled": false }

, but it returns {'message': 'Forbidden'}

Any hints please?

My thanks.

Matthew Barlowe
  • 2,229
  • 1
  • 14
  • 24
Remotay
  • 3
  • 1
  • 3
  • 1
    authorization fails. are the keys correct? – leoOrion Sep 24 '21 at 05:55
  • Fix indentation after class definition. – PCM Sep 24 '21 at 05:55
  • This has nothing to do with the dictionary. It is an API problem. Whatever API you are using is returning a forbidden error that is being printed. If you fix that, you'll get the results there. https://stackoverflow.com/questions/40988051/getting-message-forbidden-reply-from-aws-api-gateway – Amal Sailendran Sep 24 '21 at 05:55
  • 1
    Your client isn't being authenticated or you don't have permission for that endpoint. I would double check your credentials would be my first guess – Matthew Barlowe Sep 24 '21 at 05:55
  • maybe read the api documentation and see the response/message code – sahasrara62 Sep 24 '21 at 06:17
  • Nice, it was because of the api key, now I am trying to buy and code colapses, because of : {'message': 'Limit only mode'} – Remotay Sep 24 '21 at 10:39
  • If you have a new question, ask a new question. People will not see your comment buried in a list of comments here. – Robert Oct 01 '21 at 18:52

0 Answers0