Server for Pragyan's Dalal Street

Overview

CircleCI build status Go Report Card

Server for Dalal Street

Prerequisites

Check prerequisites

  • Check the go version installed.
go version
  • Check protobuf installation.
protoc --help
  • Setup SECRET_KEY environment variable to some string

Build instructions

  • Download the repository and cd into it.
go get github.com/delta/dalal-street-server
cd $GOPATH/src/github.com/delta/dalal-street-server
  • Install dependencies
cd ../
go get -v github.com/gemnasium/migrate
go get -u github.com/golang/protobuf/{proto,protoc-gen-go}
cd $GOPATH/src/github.com/golang/protobuf/protoc-gen-go/
git reset --hard ed6926b37a637426117ccab59282c3839528a700
go install github.com/golang/protobuf/protoc-gen-go
cd $GOPATH/src/github.com/delta/dalal-street-server/
go get
  • Setup submodules
git submodule init
git submodule update --recursive
  • Create databases and run migrations
mysql -u root -p -e "CREATE DATABASE dalalstreet_dev; CREATE DATABASE dalalstreet_test;"
migrate -url "mysql://root:[email protected]/dalalstreet_dev" -path ./migrations up
  • Generate proto files
./build_proto.sh
  • Run cp config.json.example config.json
  • Fill in the database credentials in the Dev section of config.json.
  • Run go run main.go

Create Migrations

migrate -url "mysql://root:[email protected]/dalalstreet_dev" -path ./migrations create migration_file_xyz

Tests

  • Run the test script locally before pushing commits.
./test.sh

Docker usage instructions

  • Install docker and docker-compose.
  • Run cp .env.example .env. Fill in the DB_NAME and DB_PASS in .env. These are the credentials for the database container.
  • Use the same credentials in Docker section config.json (DbName and DbPassword) and docker-entry.sh (in the migrate command).
  • Run docker-compose up.
  • Once the containers are up, you can get shell access by using
docker exec -it <CONTAINER_ID> bash

GoMock usage instructions

  • To generate mock for a file using mockgen, place this comment after import statement
 //go:generate mockgen -source {YOUR_FILE_NAME}.go -destination ../mocks/{YOUR_FILE_NAME}.go -package mocks
  • To generate mocks for all packages that has above comment
go generate ./...

  • To manually generate a mock package
mockgen -destination=mocks/{YOUR_FILE_NAME}.go -package=mocks {PATH_TO_YOUR_FILE}

Issues
  • [orders]: Add 3 percent ordering fee on all orders placed

    [orders]: Add 3 percent ordering fee on all orders placed

    Currently people are placing orders mindlessly. To prevent random orders from being placed, a fee of 3 % is charged on whatever the order is worth (price x quantity).

    I'm not a 100% sure on the kind of effect this will have on the game but atleast for the demo, we can see how this works out. Can be removed if it doesn't add any positive effect.

    opened by PaiAkshay998 14
  • [Orders] Add tax to earnings

    [Orders] Add tax to earnings

    For the game to adjust in terms of difficulty for relatively wealthy players, we could have tax instead of mortage interest over time. I feel this solves the issue better. We could have tax brackets based on net worth.

    High Priority Feature need to think 
    opened by PaiAkshay998 10
  • Update Mortgage Logic

    Update Mortgage Logic

    Mortgage reselling price should not be based on current price but on the price the mortgage was taken at.

    enhancement High Priority need to think 
    opened by PaiAkshay998 8
  • Add proto files for socketapi

    Add proto files for socketapi

    These are modified version of the files on DalalStreetv3 repo. I'm updating those too with this commit.

    Actions for getting data aren't available yet. But the structure is laid out in this commit.

    opened by thakkarparth007 7
  • Plot volume in stock history graphs

    Plot volume in stock history graphs

    Also change the styling of the line graph. It's honestly terrible.

    Volume already arrives with the stock history data, but doesn't get plotted. It'll be cool to show the volume on the charts as well to show which periods are most active, etc.

    enhancement 
    opened by thakkarparth007 6
  • [Orders] Cancel all non-executed orders at the end of the day

    [Orders] Cancel all non-executed orders at the end of the day

    This is how the real stock market works. It could also helps us out with the pending market orders.

    Feature need to think 
    opened by PaiAkshay998 6
  • [tax]: Add taxes to player's earnings

    [tax]: Add taxes to player's earnings

    This PR addresses #236 - check this issue for an explanation on the implementation.

    Issues that still exist :-

    • After a tax is charged, there is no indication on the frontend that a tax was charged.
    • The cash and stock value changes in the Nav Bar immediately after a trade happens but this doesn't reflect the tax that was charged. Only after refreshing the page does it update correctly.
    opened by gauthamk97 6
  • [Reserved-Assets]: Sending reserved-assets updates to frontend

    [Reserved-Assets]: Sending reserved-assets updates to frontend

    This is bad. The first thing to do for next year is to undo whatever this issue asks you to. Since we now reserve assets prior to execution of requests, all subsequent OrderFillTransactions received to the frontend will only contain partial information. OrderFillTransactions will no longer have details like how much stocks were sold for an AskOrder, how much cash was taken from reserved cash for a BidOrder.

    Solution

    1. Create a new type of Transaction. Call it ReserveUpdateTransaction
    2. These transactions WILL NOT be saved in the database. This is to maintain the sum(...) integrity.
    3. For an AskOrder being matched, the transaction will have how much stocks were matched.
    4. For an BidOrder being matched, the transaction will have how much cash was taken out of reserve.
    5. Send this transaction to the frontend.
    Refactor High Priority 
    opened by PaiAkshay998 5
  • Market Orders Logic

    Market Orders Logic

    Right now Market Orders can be heavily exploited. Either clear pending Market or add a Market Order fee for getting (if margin of profit is large enough, then this doesn't help). Or something else?

    enhancement High Priority need to think 
    opened by PaiAkshay998 4
  • Modify ts-protoc-gen to simplify making requests

    Modify ts-protoc-gen to simplify making requests

    Adding some syntax sugar to grpc-web by modifying ts-protoc-gen will simplify coding a lot.

    opened by thakkarparth007 4
  • [Admin Panel] Edit news from admin panel

    [Admin Panel] Edit news from admin panel

    Have a new feature for admin users to edit news items already sent.

    enhancement Feature 
    opened by avikumar15 0
  • [Matching engine]: refactor server matching engine

    [Matching engine]: refactor server matching engine

    We faced some weird issues like market sell orders not getting matched for some time even though there was a matching buy order for that. On looking upon the matching engine code, we found out that there is some issues regarding the implementation of that. Try to refactor that

    bug High Priority need to think 
    opened by abesheknarayan 0
  • [Admin Panel]: Add feature for adding/modifying/deleting stocks and also clearing a particular stock's exchange stocks

    [Admin Panel]: Add feature for adding/modifying/deleting stocks and also clearing a particular stock's exchange stocks

    This might be useful during testing and in prod also if you find that people are manipulating the market then we can clear it from the admin panel itself

    Medium Priority Feature 
    opened by abesheknarayan 0
  • [Cheat]: New method for finding users who cheat

    [Cheat]: New method for finding users who cheat

    We tried to find people who played in groups using Strongly Connected Components by taking transactions between users as the edge but during event , we saw that it wasnt effective in finding groups as even a small number of random transactions were making them come into the SCC. Try to come up with new idea for that

    enhancement High Priority 
    opened by abesheknarayan 0
  • [Transactions]: Add constraint for preventing short selling after some extent

    [Transactions]: Add constraint for preventing short selling after some extent

    This year , we tried to add a constraint where we check in each transaction if the user has enough cash to retrieve the stocks after short selling, but in the main event as the no of transactions were high, we faced some sql lock timed out issues during first day. Have to think about better way of doing this and also we need to write stress tests to check with lot of concurrent transactions.

    enhancement High Priority 
    opened by abesheknarayan 0
  • Dockerise for '21

    Dockerise for '21

    opened by sakthi-prasath 0
  • Remove hackynotif from login response

    Remove hackynotif from login response

    opened by nimishagarwal76 0
  • [Orders] : Cancel order

    [Orders] : Cancel order

    ERRO[0009] Unknown error while saving that bid is cancelled isAsk=false method=CancelOrder module=models orderId=19 userId=1

    opened by nimishagarwal76 1
Owner
Delta Force
The Official Programming Club of NIT Trichy
Delta Force
A toy MMO example built using Ebiten and WebRTC DataChannels (UDP)

Ebiten WebRTC Toy MMO ⚠️ This is a piece of incomplete hobby work and not robust. Please read the "Why does this project exist?" section. What is this

Jae Bentvelzen 8 Jun 3, 2021
Hprose 1.0 for Golang (Deprecated). Hprose 2.0 for Golang is here:

Hprose for Golang Introduction Installation Usage Http Server Http Client Synchronous Invoking Synchronous Exception Handling Asynchronous Invoking As

Hprose 138 Jun 28, 2021
Access more HTTP ports over CDN with this application.

More-Ports More Ports is a proxy service to establish all web-based applications on different ports on the server-side over a well known TCP port. It

Ahmet ÖZER 3 May 16, 2021
Chisel is a fast TCP/UDP tunnel, transported over HTTP, secured via SSH.

Chisel is a fast TCP/UDP tunnel, transported over HTTP, secured via SSH. Single executable including both client and server. Written in Go (golang). Chisel is mainly useful for passing through firewalls, though it can also be used to provide a secure endpoint into your network.

Jaime Pillora 6.3k Sep 12, 2021
Fast time-series data storage server accessible over gRPC

tstorage-server Persistent fast time-series data storage server accessible over gRPC. tstorage-server is lightweight local on-disk storage engine serv

Bartlomiej Mika 4 Aug 3, 2021
🚀Gev is a lightweight, fast non-blocking TCP network library based on Reactor mode. Support custom protocols to quickly and easily build high-performance servers.

gev 中文 | English gev is a lightweight, fast non-blocking TCP network library based on Reactor mode. Support custom protocols to quickly and easily bui

徐旭 1.2k Sep 7, 2021
A fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet.

frp README | 中文文档 What is frp? frp is a fast reverse proxy to help you expose a local server behind a NAT or firewall to the Internet. As of now, it s

null 48.2k Sep 12, 2021
Ethr is a Comprehensive Network Measurement Tool for TCP, UDP & ICMP.

Ethr Ethr is a cross platform network performance measurement tool written in golang. The goal of this project is to provide a native tool for compreh

Microsoft 5k Sep 7, 2021
In memory Key/Value store in go using gRPC.

In memory cache, using gRPC Contents About Running Server Local Docker Kubernetes Example Helm Terraform API Add Get GetByPrefix GetAllItems DeleteKey

Kautilya Tripathi 137 Sep 3, 2021
CoAP Client/Server implementing RFC 7252 for the Go Language

Canopus Canopus is a client/server implementation of the Constrained Application Protocol (CoAP) Updates 25.11.2016 I've added basic dTLS Support base

Zubair Hamed 146 Aug 26, 2021
webrpc is a schema-driven approach to writing backend services for modern Web apps and networks

webrpc is a schema-driven approach to writing backend servers for the Web. Write your server's api interface in a schema format of RIDL or JSON, and t

null 386 Aug 23, 2021
Glue - Robust Go and Javascript Socket Library (Alternative to Socket.io)

Glue - Robust Go and Javascript Socket Library Glue is a real-time bidirectional socket library. It is a clean, robust and efficient alternative to so

DesertBit 383 Aug 10, 2021
High-performance, non-blocking, event-driven, easy-to-use networking framework written in Go, support tls/http1.x/websocket.

High-performance, non-blocking, event-driven, easy-to-use networking framework written in Go, support tls/http1.x/websocket.

lesismal 316 Sep 11, 2021
Application written in Go which polls Time-series data at specific intervals and saves to persistent storage

TPoller Server Overview The purpose of this application is to poll time-series data per time interval from any (telemetry) application running a gRPC

Bartlomiej Mika 3 Aug 1, 2021
A golang library about socks5, supports all socks5 commands. That Provides server and client and easy to use. Compatible with socks4 and socks4a.

socks5 This is a Golang implementation of the Socks5 protocol library. To see in this SOCKS Protocol Version 5. This library is also compatible with S

chenhao zhang 29 Aug 27, 2021
Group peer to peer video calls for everyone written in Go and TypeScript

Peer Calls v4 WebRTC peer to peer calls for everyone. See it live in action at peercalls.com. The server has been completely rewriten in Go and all th

Peer Calls 979 Sep 10, 2021
Use Consul to do service discovery, use gRPC +kafka to do message produce and consume. Use redis to store result.

目录 gRPC/consul/kafka简介 gRPC+kafka的Demo gRPC+kafka整体示意图 限流器 基于redis计数器生成唯一ID kafka生产消费 kafka生产消费示意图 本文kafka生产消费过程 基于pprof的性能分析Demo 使用pprof统计CPU/HEAP数据的

null 38 Jan 31, 2021
Multiplexer over TCP. Useful if target server only allows you to create limited tcp connections concurrently.

tcp-multiplexer Use it in front of target server and let your client programs connect it, if target server only allows you to create limited tcp conne

许嘉华 3 May 27, 2021