mirror of
https://github.com/KhizarImran/backtestingfx.git
synced 2026-08-14 12:38:05 +00:00
Merge pull request #1 from KhizarImran/chore/clippy-clean
chore: fix clippy warnings and enforce clippy in CI
This commit is contained in:
@@ -11,10 +11,13 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: dtolnay/rust-toolchain@stable
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
|
with:
|
||||||
|
components: clippy
|
||||||
- uses: actions/setup-python@v5
|
- uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: "3.12"
|
python-version: "3.12"
|
||||||
- run: cargo check
|
# clippy does everything cargo check does, so it replaces it rather than adding to it
|
||||||
|
- run: cargo clippy --all-targets -- -D warnings
|
||||||
- run: cargo test
|
- run: cargo test
|
||||||
- run: python -m pip install ".[report]"
|
- run: python -m pip install ".[report]"
|
||||||
- run: python -m unittest discover -s "$GITHUB_WORKSPACE/tests"
|
- run: python -m unittest discover -s "$GITHUB_WORKSPACE/tests"
|
||||||
|
|||||||
+4
-4
@@ -23,8 +23,8 @@ impl Broker {
|
|||||||
let fill = {
|
let fill = {
|
||||||
let p = &self.positions[i];
|
let p = &self.positions[i];
|
||||||
if p.is_long {
|
if p.is_long {
|
||||||
let sl_hit = p.stop_loss.map_or(false, |sl| bar.low <= sl);
|
let sl_hit = p.stop_loss.is_some_and(|sl| bar.low <= sl);
|
||||||
let tp_hit = p.take_profit.map_or(false, |tp| bar.high >= tp);
|
let tp_hit = p.take_profit.is_some_and(|tp| bar.high >= tp);
|
||||||
if sl_hit {
|
if sl_hit {
|
||||||
p.stop_loss
|
p.stop_loss
|
||||||
} else if tp_hit {
|
} else if tp_hit {
|
||||||
@@ -33,8 +33,8 @@ impl Broker {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let sl_hit = p.stop_loss.map_or(false, |sl| bar.high >= sl);
|
let sl_hit = p.stop_loss.is_some_and(|sl| bar.high >= sl);
|
||||||
let tp_hit = p.take_profit.map_or(false, |tp| bar.low <= tp);
|
let tp_hit = p.take_profit.is_some_and(|tp| bar.low <= tp);
|
||||||
if sl_hit {
|
if sl_hit {
|
||||||
p.stop_loss
|
p.stop_loss
|
||||||
} else if tp_hit {
|
} else if tp_hit {
|
||||||
|
|||||||
Reference in New Issue
Block a user