Created
September 2, 2021 14:21
-
-
Save kailashyogeshwar85/9ff3a48c35672326809abe3c43dc5e84 to your computer and use it in GitHub Desktop.
ome-order
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package engine | |
import ( | |
"encoding/json" | |
"github.com/shopspring/decimal" | |
) | |
// Order Type | |
type Order struct { | |
ID string `json:"id"` | |
Side Side `json:"side"` | |
Quantity decimal.Decimal `json:"quantity"` | |
Price decimal.Decimal `json:"price"` | |
Timestamp int64 `json:"timestamp"` | |
} | |
// Convert order to struct from json | |
func (order *Order) FromJSON(msg []byte) error { | |
return json.Unmarshal(msg, order) | |
} | |
// Convert order to json from order struct | |
func (order *Order) toJSON() []byte { | |
str, _ := json.Marshal(order) | |
return str | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment