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 main | |
import ( | |
"fmt" | |
"log" | |
"time" | |
"github.com/Shopify/sarama" | |
cluster "github.com/bsm/sarama-cluster" | |
"github.com/kailashyogeshwar85/slim-orderbook/cmd/slim-orderbook/engine" |
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" | |
type Trade struct { | |
TakerOrderID string `json:"taker_order_id"` | |
MakerOrderID string `json:"maker_order_id"` | |
Quantity uint64 `json:"quantity"` | |
Price uint64 `json:"price"` | |
Timestamp int64 `json:"timestamp"` |
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" | |
"reflect" | |
) | |
type Side int | |
// 0 = sell 1 = buy |
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 ( | |
"log" | |
) | |
// Process an order and return the trades generated before adding the remaining amount to the market | |
func (book *OrderBook) Process(order Order) []Trade { | |
if order.Side.String() == "buy" { | |
return book.processLimitBuyOrder(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 | |
// making field lowercase makes it private property | |
type OrderBook struct { | |
Bids []Order `json:"bids"` | |
Asks []Order `json:"asks"` | |
} | |
// APIs | |
// addBuyOrder(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 { |
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
# ====================================== | |
# RabbitMQ broker section | |
# ====================================== | |
## Related doc guide: https://rabbitmq.com/configure.html. See | |
## https://rabbitmq.com/documentation.html for documentation ToC. | |
## Networking | |
## ==================== | |
## |
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
<system> | |
workers 1 | |
log_level trace | |
</system> | |
# logs for api | |
<source> | |
@type tail | |
format json | |
tag cli.stdout |
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
const bunyan = require('bunyan'); | |
const format = require('bunyan-format'); | |
const express = require('express'); | |
const bodyParser = require('body-parser') | |
const FS = require('fs'); | |
const _ = require('lodash'); | |
global.logger = configureLogger(); | |
const app = express(); |
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
{ | |
"bold_folder_labels": true, | |
"caret_style": "blink", | |
"color_scheme": "Packages/Boxy Theme/schemes/Boxy Monokai.tmTheme", | |
"font_size": 9, | |
"highlight_line": true, | |
"ignored_packages": | |
[ | |
"Vintage" | |
], |
NewerOlder