Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Exchange ¶
type Exchange string
func NewTradingViewToExchange ¶
NewTradingViewToExchange maps trading exchanges to exchanges that this system can read
type Exec ¶
type Exec struct {
// ID is the identifier for execution
ID string
// ExchangeExecID is an ID generated by the exchange. It may not exist
ExchangeExecID string
// ExchangeOrdID is the original order id. There can be 1 Order (OrdID) to n Exec
OrdID string
// Side of trade
Side Side
// Px is the price of trade
Px string
// Qty is the qty of trade
Qty string
// Timestamp is the time of execution
Timestamp time.Time
}
Exec is a single Execution
func NewExecWithFloat ¶
NewExecWithFloat creates new execution from float value
func (Exec) GetFloatPx ¶
func (Exec) GetFloatQty ¶
type OrdStatus ¶
type OrdStatus string
const ( OrdStatusDraft OrdStatus = "draft" OrdStatusPendingNew OrdStatus = "pending_new" OrdStatusNew OrdStatus = "new" OrdStatusPartiallyFilled OrdStatus = "partially_filled" OrdStatusFilled OrdStatus = "filled" OrdStatusPendingCancel OrdStatus = "pending_cancel" OrdStatusCanceled OrdStatus = "canceled" OrdStatusRejected OrdStatus = "rejected" )
type Order ¶
type Order struct {
// ID is the identifier on the database
ID string
// account ID is the account of this user
AccountID string
// StrategyID is the strategy identifier
StrategyID string
// SignalID is the signal that is generated by the strategy
SignalID string
// ExchangeOrderID is the order ID on the exchange
ExchangeOrderID string
// OrderStatus is the status of the order
OrderStatus OrdStatus
// Side is the side of the trade
Side Side
// Symbol is the symbol to trade
Symbol string
// Qty is the quantity to be sent
Qty string
// FilledQty is the quantity that has been filled
FilledQty string
// Exchange is the exchange name
Exchange Exchange
// OrderStructure is the structure of the order on the exchange
OrderStructure OrderStructure
// OrderMethod is the native method in which orders are executed
OrderMethod OrderMethod
// Px is the price used for limit
Px string
// FilledPx is the average fill price
FilledPx string
// TriggerPx is the price used to trigger a stop
TriggerPx string
// IFDOCO is if-done-one-cancels-other order
IFDOCO *OrderMethodParamIFDOCO
// TimeInForce is the time limit of the order on the exchange
TimeInForce TimeInForce
}
Order is an order planned or sent to the exchange
func NewchildOrder ¶
func NewchildOrder( exch Exchange, symbol, signalID, strategyID string, om OrderMethod, side Side, px, qty string, tif TimeInForce, status OrdStatus, ) (*Order, error)
NewChildOrder creates a new child order
type OrderChange ¶
type OrderChangeAction ¶
type OrderChangeAction string
const ( OrderChangeActionNew OrderChangeAction = "new" OrderChangeActionUpdate OrderChangeAction = "update" OrderChangeActionCancel OrderChangeAction = "cancel" OrderChangeActionCancelAndClose OrderChangeAction = "cancel_close" )
type OrderMethod ¶
type OrderMethod string
const ( OrderMethodIFD OrderMethod = "ifd" OrderMethodIFDOCO OrderMethod = "ifdoco" OrderMethodLimit OrderMethod = "limit" OrderMethodStop OrderMethod = "stop" OrderMethodMarket OrderMethod = "market" )
type OrderMethodParamIFD ¶
OrderMethodParamIFDOCO defines the parameter for IFDOCO order
type OrderMethodParamIFDOCO ¶
OrderMethodParamIFDOCO defines the parameter for IFDOCO order
type OrderStructure ¶
type OrderStructure string
const ( OrderStructureParentOrder OrderStructure = "parent_order" OrderStructureChildOrder OrderStructure = "child_order" )
type Signal ¶
type Signal struct {
// Src is the source of the signal. E.g. TradingView
Src string
// ID is a unique signal ID
ID string
// Px is the target price of the strategy
Px string
// Strategy is a grouping identifier for the strategy. E.g. my-strategy
Strategy string
// Side is either LONG or SHORT
Side Side
// Symbol is the symbol to trade
Symbol string
// Exchange is the exchange to send the order to
Exchange Exchange
// Extra is an additional parameter
Extra string
// Generated is the generated timestamp of the strategy signal
Generated time.Time
// PrevSignalID is a previous signal ID
PrevSignalID string
// Status is the signal status
Status SignalStatus
// TargetAvgEntryPx is the target avg entry px
TargetAvgEntryPx string
// TargetStopLossPx is the target stop loss px
TargetStopLossPx string
// TargetTakeProfitPx is the target take profit px
TargetTakeProfitPx string
// FilledEntryPx is the actual filled avg entry px
FilledEntryPx string
// FilledExitPx is the actual filled exit px
FilledExitPx string
// FilledQty is the actual filled qty
FilledQty string
// CancelCompleteOrdID is the cancel completed request's order IDs
CancelCompleteOrdID map[string]bool
// ClosePositionOrdID is the close position's order IDs
ClosePositionOrdID map[string]bool
}
Signal is a generated instruction on what to trade
func NewSignalFromTradingView ¶
NewSignalFromTradingView generates signal from tradingview alert
func (Signal) IsAllCancelComplete ¶
IsAllCancelComplete returns true if all cancel complete requests are acked
func (Signal) IsAllClosePositionComplete ¶
IsAllClosePositionComplete returns true if all close position requests are acked
type SignalStatus ¶
type SignalStatus string
const ( SignalStateDraft SignalStatus = "DRAFT" SignalStateOpen SignalStatus = "OPEN" SignalStateCloseInit SignalStatus = "CLOSE_INIT" SignalStateCloseWaitingOrderCancel SignalStatus = "CLOSE_WAITING_ORDER_CANCEL" SignalStateCloseWaitingPositionCancel SignalStatus = "CLOSE_WAITING_POSITION_CLOSE" SignalStateCloseComplete SignalStatus = "CLOSE_WAITING_POSITION_CLOSE" )
type TimeInForce ¶
type TimeInForce string
const ( TimeInForceGTC TimeInForce = "gtc" TimeInForceFOC TimeInForce = "foc" )