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

WIP: Recreate infinity grid #735

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ksidenko
Copy link
Contributor

@bbgokarma-bot
Copy link

Welcome back! @ksidenko, This pull request may get 824 BBG.

order := types.SubmitOrder{
Symbol: s.Symbol,
Side: types.SideTypeBuy,
Type: types.OrderTypeLimit,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@c9s if I set market order, backtest fail with error:
image

can you help me to fix it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe you forgot to sync first?

Copy link
Owner

Choose a reason for hiding this comment

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

yes, you're missing the kline data, you need to sync first.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried, but have the same error:
go run ./cmd/bbgo backtest -v --sync --config config/infinity-grid.yaml --base-asset-baseline --output output --subdir

Copy link
Owner

Choose a reason for hiding this comment

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

The reason is that you submit an order before the first kline is processed.

image

Copy link
Owner

Choose a reason for hiding this comment

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

check if your db loaded all the binance klines, also you might need to rebase to the latest main branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I already rebase my branch, make some fixes, but error not left.

Can you pls debug locally? just run

go run ./cmd/bbgo backtest -v --sync --config config/infinity-grid.yaml --base-asset-baseline --output output --subdir

I think it's bug, couse I have last price https://github.com/c9s/bbgo/pull/735/files#diff-378c135c835046a31b907fc9e387f6d6a287d76248e6261d87689b4147772108R138 and use it in this stage, but I can evaluates market order in stream onStart stage.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If the post order action happens in OnStart, you should get the error "SubmitOrders should be called after UserDataStream been initialized"

@c9s
Copy link
Owner

c9s commented Jun 17, 2022

👍

@@ -186,7 +186,7 @@ const ordersToMarkets = (interval: string, orders: Array<Order> | void): Array<M
position: 'aboveBar',
color: '#e91e63',
shape: 'arrowDown',
text: ''+order.price
text: ''+order.price.toFixed(0),
Copy link
Owner

Choose a reason for hiding this comment

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

This might truncate the precision for price like 1.0003355

Orders []types.SubmitOrder `json:"orders,omitempty"`
FilledBuyGrids map[fixedpoint.Value]struct{} `json:"filledBuyGrids"`
FilledSellGrids map[fixedpoint.Value]struct{} `json:"filledSellGrids"`
Position *types.Position `json:"position,omitempty"`
Copy link
Owner

Choose a reason for hiding this comment

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

You can check how to use the persistence tag, it's a new feature.

it's applied in the bollmaker strategy.

@c9s c9s changed the title WIP. Recreate infinity grid WIP: Recreate infinity grid Jun 17, 2022
@jnlin
Copy link
Contributor

jnlin commented Jun 17, 2022

👍👍👍

@ksidenko
Copy link
Contributor Author

@c9s i have such output
image

There are many records like this:

INFO 📝 Submitting ETHUSDT LIMIT BUY order with quantity: 0.051546 @ 1119.296010, order: %!v(MISSING)

  1. Can we do this memo message with log level Debug?
  2. %!v(MISSING) - some error fmt in logic

INFO →submitting following order: SubmitOrder ETHUSDT LIMIT BUY 0.05154639 @ 1187.46113646
How can I change precise 1187.46113646 → 1187 ?

@bbgokarma-bot
Copy link

Re-estimated karma: this pull request may get 985 BBG

@bbgokarma-bot
Copy link

Re-estimated karma: this pull request may get 1049 BBG

@@ -430,6 +430,10 @@ func (a Value) MulExp(exp int) Value {
return Value(int64(float64(a) * math.Pow(10, float64(exp))))
}

func (a Value) MulPow(v Value, exp Value) Value {
return Value(int64(float64(a) * math.Pow(v.Float64(), exp.Float64())))
Copy link
Collaborator

Choose a reason for hiding this comment

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

You need also implement the same method for dnum fixedpoint.
Otherwise strategies compiled using dnum tag won't be able to pass the compilation

@bbgokarma-bot
Copy link

Re-estimated karma: this pull request may get 1075 BBG

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

None yet

6 participants