Skip to content

Commit

Permalink
Messages clean up ordertype property (coinbase#170)
Browse files Browse the repository at this point in the history
* Messages.ts: documentation improvements.

Remove documentation on the orderType property which NewOrderMessage
doesn't have.

orderType only appears in PlaceOrderMessage and TradeExecutedMessage,
so add it there.

Also add comments on TradeFinalizedMessage and MyOrderPlacedMessage.

* Remove MyOrderPlacedMessage's orderType field.

GDAX's 'open' feed message doesn't contain an order type:

  { type: 'open',
    side: 'buy',
    price: '10015.99000000',
    order_id: '3c551481-c7c1-48e9-a820-d7287348f861',
    remaining_size: '0.01000000',
    product_id: 'BTC-USD',
    sequence: 16899268,
    user_id: '59c806a6e71206025e1e274c',
    profile_id: '12ad580d-81b8-4ee1-b4dc-ad6d02206412',
    time: '2018-03-11T00:26:16.842000Z' } }

Additionally, the code as it currently stands always sets the
orderType field to 'open' which has no meaning, so delete the
property.

* Add OrderType type and use it in {PlaceOrder,TradeExecuted}Message.
  • Loading branch information
blair authored and fb55 committed Apr 14, 2018
1 parent fdb7fd7 commit 73e5d5f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
18 changes: 13 additions & 5 deletions src/core/Messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
import { OrderbookState } from '../lib/Orderbook';
import { Side } from '../lib/sides';
import { Ticker } from '../exchanges/PublicExchangeAPI';

export type OrderType = 'limit' | 'market' | 'stop';

/**
* Interfaces for the GTT Stream message types. These messages are generated and passed on my the GTT streaming
* infrastructure. The `type` field is conventionally named after the interface, first letter lowercased, with the word Message
Expand Down Expand Up @@ -106,8 +109,6 @@ export function isBaseOrderMessage(msg: any): msg is BaseOrderMessage {

/**
* In order-level books, represents a new order.
*
* `orderType` is market, limit, stop
*/
export interface NewOrderMessage extends BaseOrderMessage {
type: 'newOrder';
Expand Down Expand Up @@ -186,7 +187,7 @@ export interface PlaceOrderMessage extends StreamMessage {
productId: string;
clientId?: string;
side: Side;
orderType: string;
orderType: OrderType;
price?: string;
postOnly?: boolean;
size?: string;
Expand All @@ -208,11 +209,15 @@ export interface TradeExecutedMessage extends StreamMessage {
orderId: string;
side: Side;
price: string;
orderType: string;
orderType: OrderType;
tradeSize: string;
remainingSize: string;
}

/**
* Emitted when my order is finalized. (An authenticated feed is
* required).
*/
export interface TradeFinalizedMessage extends StreamMessage {
type: 'tradeFinalized';
productId: string;
Expand All @@ -223,13 +228,16 @@ export interface TradeFinalizedMessage extends StreamMessage {
reason: string;
}

/**
* Emitted when my order is placed. (An authenticated feed is
* required).
*/
export interface MyOrderPlacedMessage extends StreamMessage {
type: 'myOrderPlaced';
productId: string;
orderId: string;
side: Side;
price: string;
orderType: string;
size: string;
sequence: number;
}
Expand Down
1 change: 0 additions & 1 deletion src/exchanges/gdax/GDAXFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,6 @@ export class GDAXFeed extends ExchangeFeed {
orderId: feedMessage.order_id,
side: feedMessage.side,
price: feedMessage.price,
orderType: feedMessage.type,
size: feedMessage.remaining_size,
sequence: feedMessage.sequence
};
Expand Down

0 comments on commit 73e5d5f

Please sign in to comment.