Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
mclaudt committed Nov 9, 2018
1 parent 4304514 commit 575f02e
Show file tree
Hide file tree
Showing 19 changed files with 8,747 additions and 2 deletions.
148 changes: 148 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@

# Created by https://www.gitignore.io/api/sbt,scala,intellij+iml,intellij+all
# Edit at https://www.gitignore.io/?templates=sbt,scala,intellij+iml,intellij+all

### Intellij+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Intellij+all Patch ###
# Ignores the whole .idea folder and all .iml files
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360

.idea/

# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023

*.iml
modules.xml
.idea/misc.xml
*.ipr

### Intellij+iml ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff

# Generated files

# Sensitive or high-churn files

# Gradle

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules

# CMake

# Mongo Explorer plugin

# File-based project format

# IntelliJ

# mpeltonen/sbt-idea plugin

# JIRA plugin

# Cursive Clojure plugin

# Crashlytics plugin (for Android Studio and IntelliJ)

# Editor-based Rest Client

# Android studio 3.1+ serialized cache file

### Intellij+iml Patch ###
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023


### SBT ###
# Simple Build Tool
# http://www.scala-sbt.org/release/docs/Getting-Started/Directories.html#configuring-version-control

dist/*
target/
lib_managed/
src_managed/
project/boot/
project/plugins/project/
.history
.cache
.lib/

### Scala ###
*.class
*.log

# End of https://www.gitignore.io/api/sbt,scala,intellij+iml,intellij+all
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
# ordersmatcher
Stock orders matcher based on Akka Actors.
# Stock Orders Matcher

## Intro

Reads client.txt and orders.txt from resources.
Produces result.txt with final account states.

## How to run
```
sbt run
```

## Features
* self-orders prevention (covered by unit-test also).
* Negative stock accounts are allowed for simplicity.
* Implemented in Akka Actors to make parallelization of operations possible.
* Features `become` and `stash` patterns from Akka Actors.
* Debug level is on by default, to play with market evolution.
19 changes: 19 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Stock Matcher

## Intro

Reads client.txt and orders.txt from resources.
Produces result.txt with final account states.

## How to run
```
sbt run
```



## Features
* self-orders are not allowed (covered by unit-test also).
* Negative stock accounts are allowed for simplicity.
* Debug is on by default, to play market evolution.
* Implemented in Akka Actors to make parallelization of operations possible.
12 changes: 12 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name := "orders-matcher"

version := "0.1"

scalaVersion := "2.12.7"

libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % "2.5.17",
"org.scalatest" % "scalatest_2.12" % "3.0.5" % "test",
"com.typesafe.akka" %% "akka-slf4j" % "2.5.17",
"ch.qos.logback" % "logback-classic" % "1.2.3"
)
1 change: 1 addition & 0 deletions project/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version = 1.2.6
9 changes: 9 additions & 0 deletions result.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
C1 -5999 170 411 1087 567
C2 2002 386 -19 1105 767
C3 10048 -221 -167 -200 -289
C4 -14016 856 1053 724 1872
C5 1760 -110 -114 526 72
C6 -7176 1672 556 61 -119
C7 -4123 -29 -43 1231 -66
C8 23054 -397 -26 -522 -601
C9 20920 -187 -51 -532 7
17 changes: 17 additions & 0 deletions src/main/resources/application.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
akka {

# Loggers to register at boot time (akka.event.Logging$DefaultLogger logs
# to STDOUT)
loggers = ["akka.event.slf4j.Slf4jLogger"]

# Log level used by the configured loggers (see "loggers") as soon
# as they have been started; before that, see "stdout-loglevel"
# Options: OFF, ERROR, WARNING, INFO, DEBUG
loglevel = "DEBUG"

# Log level for the very basic logger activated during ActorSystem startup.
# This logger prints the log messages to stdout (System.out).
# Options: OFF, ERROR, WARNING, INFO, DEBUG
stdout-loglevel = "DEBUG"

}
9 changes: 9 additions & 0 deletions src/main/resources/clients.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
C1 1000 130 240 760 320
C2 4350 370 120 950 560
C3 2760 0 0 0 0
C4 560 450 540 480 950
C5 1500 0 0 400 100
C6 1300 890 320 100 0
C7 750 20 0 790 0
C8 7000 90 190 0 0
C9 7250 190 190 0 280
Loading

0 comments on commit 575f02e

Please sign in to comment.