Skip to content
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

this is a bug #8

Open
beaquant opened this issue Feb 16, 2019 · 3 comments
Open

this is a bug #8

beaquant opened this issue Feb 16, 2019 · 3 comments

Comments

@beaquant
Copy link

Hello sdcoffey,
Long time to see you here, I hope you're ok.
In this function, it's not satisfied to use close price divide CostBasis

func (slr stopLossRule) IsSatisfied(index int, record *TradingRecord) bool {
	if !record.CurrentPosition().IsOpen() {
		return false
	}

	openPrice := record.CurrentPosition().CostBasis()
	loss := slr.Indicator.Calculate(index).Div(openPrice).Sub(big.ONE)
	return loss.LTE(slr.tolerance)
}

openPrice := record.CurrentPosition().CostBasis()

@beaquant beaquant closed this as completed Mar 8, 2019
@beaquant beaquant reopened this Mar 8, 2019
@sdcoffey
Copy link
Owner

Hey @beaquant,

thanks for opening this issue. Can you explain your thinking? I'm afraid I don't follow.

@beaquant
Copy link
Author

beaquant commented Mar 11, 2019

thanks for your reply.
the stop rule you make it, it mean stop = (current close price / open cost) -1.
if i buy something 100 amount @ 3000 price, but now price is 2500, then stop=(2500/100*3000)-1, stop=-0.9916, what's mean for this -0.9916?
if i buy something 200 amount @ 3000 price, but now price is 2500, then stop=(2500/200*3000)-1, stop=-0.9958, what's mean for this -0.9958?

I think stop loss is a radio for the open price. stop = (open price / current close price) -1
stop=(2500/3000)-1, stop=-0.166, loss 16%
am i right to understand the rule?

@beaquant
Copy link
Author

BTW, do you have any advance plane to update this repo and release new version?

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

No branches or pull requests

2 participants