Skip to content

Refactor f-string formatting. #166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
Closed

Conversation

Alex-CodeLab
Copy link

@Alex-CodeLab Alex-CodeLab commented Oct 31, 2020

Use f-string formatting where useful.

Fixes #161

kernc
kernc previously approved these changes Nov 1, 2020
Comment on lines 428 to 429
f"(index datetime resolution: '{time_resolution}'). "
"Skipping.",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f"(index datetime resolution: '{time_resolution}'). "
"Skipping.",
f"(index datetime resolution: '{time_resolution}'). Skipping.",

Comment on lines 427 to 428
If size is a value between 0 and 1, it is interpreted as a fraction
of current available liquidity (cash plus `Position.pl` minus used margin).
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If size is a value between 0 and 1, it is interpreted as a fraction
of current available liquidity (cash plus `Position.pl` minus used margin).
If size is a value between 0 and 1, it is interpreted as a fraction of current
available liquidity (cash plus `Position.pl` minus used margin).

assert 0 < cash, "cash shosuld be >0, is {}".format(cash)
assert 0 <= commission < .1, "commission should be between 0-10%, is {}".format(commission)
assert 0 < margin <= 1, "margin should be between 0 and 1, is {}".format(margin)
assert 0 < cash, f"cash shosuld be >0, is {cash}"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert 0 < cash, f"cash shosuld be >0, is {cash}"
assert 0 < cash, f"cash should be >0, is {cash}"

Comment on lines 708 to 709
raise ValueError(f"Long orders require: "
f"SL ({sl}) < LIMIT ({limit or stop or self.last_price}) < TP ({tp})")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
raise ValueError(f"Long orders require: "
f"SL ({sl}) < LIMIT ({limit or stop or self.last_price}) < TP ({tp})")
raise ValueError(
"Long orders require: "
f"SL ({sl}) < LIMIT ({limit or stop or self.last_price}) < TP ({tp})")

The usual style guidelines say either hanging or indented, but not mixed. Thought flake8 catches that. 🤔

Comment on lines 712 to 713
raise ValueError(f"Short orders require: "
f"TP ({tp}) < LIMIT ({limit or stop or self.last_price}) < SL ({sl})")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
raise ValueError(f"Short orders require: "
f"TP ({tp}) < LIMIT ({limit or stop or self.last_price}) < SL ({sl})")
raise ValueError(
"Short orders require: "
f"TP ({tp}) < LIMIT ({limit or stop or self.last_price}) < SL ({sl})")

@kernc
Copy link
Owner

kernc commented Nov 5, 2020

Would you care to rebase on / merge in the current master? The PR went out of sync. Also welcome to address the proposed amendments. 😁

@kernc kernc dismissed their stale review November 7, 2020 02:11

requested changes

@kernc kernc closed this in 5e1accc Nov 12, 2020
Goblincomet pushed a commit to Goblincomet/forex-trading-backtest that referenced this pull request Jul 5, 2023
Fixes: kernc/backtesting.py#161
Closes: kernc/backtesting.py#166

Thanks @Alex-CodeLab

Squashed commit of the following:

commit 363641d2b827957338ff338564323ebf1ee0e98e
Merge: aad278c 773a85f
Author: Kernc <kerncece@gmail.com>
Date:   Thu Nov 12 21:35:41 2020 +0100

    Merge branch 'master'

commit aad278cb1fe3f206a011817ac9047afc737eb70d
Author: Kernc <kerncece@gmail.com>
Date:   Thu Nov 12 20:42:30 2020 +0100

    add some more f-strings where useful

commit 4fd6ac51b54a924791fee34c49301fe5618d3769
Author: Kernc <kerncece@gmail.com>
Date:   Thu Nov 12 20:24:08 2020 +0100

    address comments

commit 5ab6cb343d768a3874407b85b7bf7c8dd2c6f743
Author: Alex ⚡ <1678423+Alex-CodeLab@users.noreply.github.com>
Date:   Sat Oct 31 19:40:57 2020 +0100

    Update _plotting.py

commit 00bb39e5d24f0fd1e47e94062d87ce268834c8cc
Author: Alex ⚡ <1678423+Alex-CodeLab@users.noreply.github.com>
Date:   Sat Oct 31 19:40:02 2020 +0100

    Update backtesting.py

commit 6c633bcbccd750960d5e5219a6d09b890f3c1639
Author: Alex ⚡ <1678423+Alex-CodeLab@users.noreply.github.com>
Date:   Sat Oct 31 19:35:55 2020 +0100

    Update backtesting.py

commit 732068a6a5a3d152584ae32179a355b3611bb6a9
Author: Alex ⚡ <1678423+Alex-CodeLab@users.noreply.github.com>
Date:   Sat Oct 31 19:26:55 2020 +0100

    Update backtesting.py

commit 21fed39e3e323cc399194f9e3d4485fb01182346
Author: Alex ⚡ <1678423+Alex-CodeLab@users.noreply.github.com>
Date:   Sat Oct 31 19:19:25 2020 +0100

    Update backtesting.py

commit e0b929e308996f41df81ff8339bce94adf4a53aa
Author: Alex ⚡ <1678423+Alex-CodeLab@users.noreply.github.com>
Date:   Sat Oct 31 18:49:30 2020 +0100

    Update backtesting.py

commit 696669a71f90a355d44d61c4f0e53510b2e68163
Author: Alex ⚡ <1678423+Alex-CodeLab@users.noreply.github.com>
Date:   Sat Oct 31 18:02:10 2020 +0100

    Update backtesting.py

commit e38b25f3e7afdfccd5e9aa5fdf5241b95f9cc78c
Author: Alex ⚡ <1678423+Alex-CodeLab@users.noreply.github.com>
Date:   Sat Oct 31 17:42:43 2020 +0100

    Update backtesting.py

commit 6bd749296ddc9e5202c7765dde0a79323eda2e9b
Author: alex <alex.sd3@gmail.com>
Date:   Sat Oct 31 16:29:38 2020 +0100

    Refactor f-string formating.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Python 3.5 "end of life"
2 participants