-
-
Notifications
You must be signed in to change notification settings - Fork 179
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
Does it support multi data feeds ? #282
Comments
you can plot multiple informations in the chart, you have to include a chart indicator inside the strategy func (e CrossEMA) Indicators(df *ninjabot.Dataframe) []strategy.ChartIndicator {
df.Metadata["custom-data"] = fetchYourCustomData()
return []strategy.ChartIndicator{
{
Overlay: true, // plot over the price
GroupName: "Custom Data",
Time: df.Time,
Metrics: []strategy.IndicatorMetric{
{
Values: df.Metadata["custom-data"]
Name: "Custom",
Color: "red",
Style: strategy.StyleLine,
},
},
},
}
}
`` |
What I meant to say was that I can feed multiple data souces into one strategy. Let's say that my strategy find out pairs with top 3 chg and buy in. So I should import all live datas of trading pairs and ranking them. |
@rodrigo-brito How can we implement this feature? We should generate multiple dataframes by timeframe or maybe a single dataframe that has some child dataframes? I think the goal is to have something like this in strategies: if df.Metadata["rsi"] < 30 && df.OtherDFs["weekly"].Metadata["rsi"] > 60 {
// buy
} @evanlaw3 Correct me if I'm wrong. |
For the same currency pair, you can resample the data if you are in a smaller dataframe and want to view a larger one. // exchange initalization
binance, err = exchange.NewBinance(ctx,
exchange.WithBinanceCredentials(cfg.BinanceKey, cfg.BinanceSecret),
exchange.WithMetadataFetcher(fetchFundingRate), // FETCH CUSTOM DATA
)
// your custom data
func fetchFundingRate(pair string, t time.Time) (string, float64) {
fr, err := futureClient.NewPremiumIndexService().Symbol(pair).Do(context.Background())
if err != nil {
log.Printf("error fetching funding rate: %s", err)
return "fr", 0
}
if len(fr) == 0 {
return "fr", 0
}
value, err := strconv.ParseFloat(fr[0].LastFundingRate, 64)
if err != nil {
log.Printf("error fetching funding rate: %s", err)
return "fr", 0
}
return "fr", value
} The function must return the name of the index and the current value. |
For backtesting with custom metadata, your CSV must have a custom column with the same index name |
Somethings like https://www.backtrader.com/blog/posts/2017-04-09-multi-example/multi-example/
The text was updated successfully, but these errors were encountered: