Documentation ¶
Index ¶
- type Loader
- type Order
- type OrderItem
- func NewCryptoOrderItem(direction constants.Direction, symbol string, amount, price float64) *OrderItem
- func NewOptionOrderItem(direction constants.Direction, symbol string, amount, price float64) *OrderItem
- func NewStockOrderItem(direction constants.Direction, symbol string, amount, price float64) *OrderItem
- func NewUSDOrderItem(direction constants.Direction, symbol string, amount, price float64) *OrderItem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Loader ¶
type Loader interface { Read(ctx context.Context, input io.Reader) ([]*Order, error) Write(ctx context.Context, output io.Writer, input []*Order) error }
Loader reads and writes the Order data to the desired format. There are several loaders to choose from, each of which are self-contained with their own schemas: 1. CSV 2. Avro 3. Proto
func NewAvroLoader ¶
func NewAvroLoader() Loader
func NewCSVLoader ¶
func NewCSVLoader() Loader
func NewJsonNewLineLoader ¶
func NewJsonNewLineLoader() Loader
func NewProtoLoader ¶
func NewProtoLoader() Loader
type Order ¶
type Order struct { // UnixTime the order was placed, for back-testing we will assume all orders are filled immediately. UnixTime int64 `csv:"time" avro:"time" json:"time"` // OrderItems are all of the items that are purchased or sold OrderItems []*OrderItem `csv:"items" avro:"items" json:"items"` }
Order represents a collection of the items that are purchased or sold in a single batch
func (*Order) RemoveItem ¶
type OrderItem ¶
type OrderItem struct { // Direction - are we buying or selling? constants.Direction `csv:"direction" avro:"direction" json:"direction"` // ItemType - what type of item is this? constants.ItemType `csv:"item_type" avro:"item_type" json:"item_type"` // Symbol or ID of the item we are buying or selling Symbol string `csv:"symbol" avro:"symbol" json:"symbol"` // Amount - How many of the items are you buying or selling? // Ex 100 shares of stock, or 1x option contract Amount float64 `csv:"amount" avro:"amount" json:"amount"` // QuantityPerAmount - how many items are included amount we buy or sell? // Stock == 1 // Option == 10, 100, or some other customer number // Crypto == Variable, depending on the currency QuantityPerAmount float64 `csv:"quantity_per_amount" avro:"quantity_per_amount" json:"quantity_per_amount"` // Price - How much is it per item? // 1. A stock is $10 so it's $10 per share // 2. An option is $1 per 100 shares, so it's $100 for the contract Price float64 `csv:"price" avro:"price" json:"price"` }
func NewCryptoOrderItem ¶
func NewOptionOrderItem ¶
func NewStockOrderItem ¶
func NewUSDOrderItem ¶
func (*OrderItem) CalculatePrice ¶
func (*OrderItem) MarginRequirement ¶
Click to show internal directories.
Click to hide internal directories.