Unable to place orders in GDAX with the sample
Closed this issue · 6 comments
Unable to place orders based on the sample t005_alertTrader.ts
/***************************************************************************************************************************
* @license *
* Copyright 2017 Coinbase, Inc. *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
* with the License. You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on *
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the *
* License for the specific language governing permissions and limitations under the License. *
***************************************************************************************************************************/
import * as GTT from "gdax-trading-toolkit";
import { Big } from "gdax-trading-toolkit/build/src/lib/types";
import { GDAX_WS_FEED, GDAXFeed, GDAXFeedConfig } from "gdax-trading-toolkit/build/src/exchanges";
import { GDAX_API_URL } from "gdax-trading-toolkit/build/src/exchanges/gdax/GDAXExchangeAPI";
import { PlaceOrderMessage, TickerMessage } from "gdax-trading-toolkit/build/src/core";
import { LiveOrder } from "gdax-trading-toolkit/build/src/lib";
const logger = GTT.utils.ConsoleLoggerFactory();
const product = 'ETH-USD';
/**
* Remember to set GDAX_KEY, GDAX_SECRET and GDAX_PASSPHRASE envars to allow trading
*/
const gdaxAPI = GTT.Factories.GDAX.DefaultAPI(logger);
const [base, quote] = product.split('-');
const spread = Big('0.05');
GTT.Factories.GDAX.getSubscribedFeeds(options, [product]).then((feed: GDAXFeed) => {
GTT.Core.createTickerTrigger(feed, product)
.setAction((ticker: TickerMessage) => {
const currentPrice = ticker.price;
GTT.Core.createPriceTrigger(feed, product, currentPrice.minus(spread))
.setAction((event: TickerMessage) => {
console.log('Price Trigger', `${base} price has fallen and is now ${event.price} ${quote} on ${product} on GDAX`);
submitTrade('buy', '0.005');
});
});
});
function submitTrade(side: string, amount: string) {
const order: PlaceOrderMessage = {
type: 'order',
time: null,
productId: product,
orderType: 'limit',
side: side,
size: amount
};
console.log('Order executed', `Order to ${order.side} 0.1 ${base} placed.`);
console.log(order);
gdaxAPI.placeOrder(order).then((result: LiveOrder) => {
console.log('Order executed', `Order to ${order.side} 0.1 ${base} placed. Result: ${result.status}`);
});
}
This is the error I am getting on the place order.
2017-11-24T20:32:26.533Z - error: The websocket feed to wss://ws-feed.gdax.com (authenticated) has reported an error. If necessary, we will reconnect.
{
"type": "ticker",
"sequence": 1538048915,
"product_id": "ETH-USD",
"price": "462.76000000",
"open_24h": "417.52000000",
"volume_24h": "316236.70621607",
"low_24h": "462.76000000",
"high_24h": "469.50000000",
"volume_30d": "4030617.08136485",
"best_bid": "462.75",
"best_ask": "462.76",
"side": "buy",
"time": "2017-11-24T20:30:52.968000Z",
"trade_id": 16874695,
"last_size": "0.00032317"
}
How do I debug the error? Thanks
Oops. There's a typo in the tutorial. the type
field should be placeOrder
@CjS77 Tried to change that but still running into an error. How do I get the actual error message? Thanks
I am running into the error as well. I also see this error when using Trader.
I am running into the same error. I was wondering if anyone had figured out how to debug the error or a workaround.
Hi, we are closing out PRs + Issues as this project is being archived.