-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Overmuse/SR/initial_dev
create initial release
- Loading branch information
Showing
7 changed files
with
511 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'Cargo.toml' | ||
- 'Cargo.lock' | ||
- 'Dockerfile' | ||
- 'src/**' | ||
pull_request: | ||
paths: | ||
- 'Cargo.toml' | ||
- 'Cargo.lock' | ||
- 'Dockerfile' | ||
- 'src/**' | ||
|
||
name: Continuous integration | ||
|
||
jobs: | ||
cancel-previous: | ||
name: Cancel Previous Runs | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Cancel actions | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
|
||
fmt: | ||
name: Rustfmt | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Cache | ||
uses: actions/cache@v2 | ||
id: cache | ||
with: | ||
path: | | ||
~/.cargo/registry | ||
~/.cargo/git | ||
target | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
- name: Setup git credentials | ||
uses: fusion-engineering/setup-git-credentials@v2 | ||
with: | ||
credentials: ${{secrets.GIT_USER_CREDENTIALS}} | ||
- name: Setup toolchain | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
override: true | ||
- name: Install rustfmt | ||
run: rustup component add rustfmt | ||
- name: Run check | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: fmt | ||
args: --all -- --check | ||
|
||
clippy: | ||
name: Clippy | ||
runs-on: ubuntu-latest | ||
needs: [fmt] | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Cache | ||
uses: actions/cache@v2 | ||
id: cache | ||
with: | ||
path: | | ||
~/.cargo/registry | ||
~/.cargo/git | ||
target | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
- name: Setup git credentials | ||
uses: fusion-engineering/setup-git-credentials@v2 | ||
with: | ||
credentials: ${{secrets.GIT_USER_CREDENTIALS}} | ||
- name: Setup toolchain | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
override: true | ||
- name: Install clippy | ||
run: rustup component add clippy | ||
- name: Run clippy | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: clippy | ||
args: -- -D warnings | ||
|
||
coverage: | ||
name: Test & Coverage | ||
runs-on: ubuntu-latest | ||
needs: [fmt, clippy] | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Cache | ||
uses: actions/cache@v2 | ||
id: cache | ||
with: | ||
path: | | ||
~/.cargo/registry | ||
~/.cargo/git | ||
target | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
- name: Setup git credentials | ||
uses: fusion-engineering/setup-git-credentials@v2 | ||
with: | ||
credentials: ${{secrets.GIT_USER_CREDENTIALS}} | ||
- name: Install toolchain | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
- name: Install tarpaulin | ||
run: cargo install cargo-tarpaulin | ||
- name: Generate coverage | ||
run: cargo tarpaulin --out Xml | ||
- name: Upload to codecov | ||
uses: codecov/codecov-action@v1 | ||
with: | ||
token: ${{secrets.CODECOV_TOKEN}} | ||
fail_ci_if_error: true |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Release | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
deploy: | ||
name: Tag if new release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Read version number | ||
id: read_toml | ||
uses: SebRollen/[email protected] | ||
with: | ||
file: Cargo.toml | ||
field: package.version | ||
- name: Set tag env variable | ||
run: echo IMAGE_TAG=v${{steps.read_toml.outputs.value}} >> $GITHUB_ENV | ||
- uses: ncipollo/release-action@v1 | ||
continue-on-error: true | ||
with: | ||
allowUpdates: false | ||
tag: ${{ env.IMAGE_TAG }} | ||
token: ${{ secrets.GITHUB_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/target | ||
Cargo.lock |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[package] | ||
name = "trading-base" | ||
version = "0.1.0" | ||
edition = "2018" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
chrono = { version = "0.4", features = ["serde"] } | ||
rust_decimal = "1.14" | ||
serde = { version = "1.0", features = ["derive"] } | ||
thiserror = "1.0" | ||
uuid = { version = "0.8", features = ["v4", "serde"] } | ||
|
||
[dev-dependencies] | ||
serde_json = "1.0.64" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use chrono::{DateTime, Utc}; | ||
use thiserror::Error; | ||
|
||
mod position_intents; | ||
pub use position_intents::{ | ||
AmountSpec, PositionIntent, PositionIntentBuilder, TickerSpec, UpdatePolicy, | ||
}; | ||
mod trade_intents; | ||
pub use trade_intents::{OrderType, TimeInForce, TradeIntent}; | ||
|
||
#[derive(Error, Clone, Debug)] | ||
pub enum Error { | ||
#[error( | ||
"Non-`Zero` `AmountSpec`s of different type cannot be merged.\nLeft: {0:?}, Right: {1:?}" | ||
)] | ||
IncompatibleAmountError(AmountSpec, AmountSpec), | ||
#[error("Cannot create PositionIntent with `before` < `after`. \nBefore: {0}, After: {1}")] | ||
InvalidBeforeAfter(DateTime<Utc>, DateTime<Utc>), | ||
#[error("TickerSpec `All` can only be used with the `Dollars` and `Shares` `AmountSpec`s")] | ||
InvalidCombination, | ||
} |
Oops, something went wrong.