Skip to content

Instantly share code, notes, and snippets.

View kailashyogeshwar85's full-sized avatar

kailash k yogeshwar kailashyogeshwar85

View GitHub Profile
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"
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"`
package engine
import (
"encoding/json"
"reflect"
)
type Side int
// 0 = sell 1 = buy
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)
@kailashyogeshwar85
kailashyogeshwar85 / orderbook.go
Created September 2, 2021 14:23
OrderBook Type
package engine
// making field lowercase makes it private property
type OrderBook struct {
Bids []Order `json:"bids"`
Asks []Order `json:"asks"`
}
// APIs
// addBuyOrder(order)
@kailashyogeshwar85
kailashyogeshwar85 / order.go
Created September 2, 2021 14:21
ome-order
package engine
import (
"encoding/json"
"github.com/shopspring/decimal"
)
// Order Type
type Order struct {
@kailashyogeshwar85
kailashyogeshwar85 / rabbitmq.conf
Created November 20, 2019 10:08
RabbitMQ Server Configuration
# ======================================
# RabbitMQ broker section
# ======================================
## Related doc guide: https://rabbitmq.com/configure.html. See
## https://rabbitmq.com/documentation.html for documentation ToC.
## Networking
## ====================
##
@kailashyogeshwar85
kailashyogeshwar85 / td-agent.conf
Created November 18, 2019 07:04
td-agent custom config
<system>
workers 1
log_level trace
</system>
# logs for api
<source>
@type tail
format json
tag cli.stdout
@kailashyogeshwar85
kailashyogeshwar85 / server.js
Created November 16, 2019 11:30
NodeJS server with Bunyan
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();
{
"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"
],