Closed zahin-mohammad closed 3 years ago
func (repo *RepositoryImpl) UpsertOHLCData( ohlcData []*models.OHLCMarketData, exchange string, pair *models.Symbol, ) { writeAPI := (*repo.influxClient).WriteAPI(repo.influxOrg, repo.ohlcBucket) tags := map[string]string{ "quote": pair.NormalizedQuote, "exchange": exchange, } for index := range ohlcData { ohlc := ohlcData[index] fields := map[string]interface{}{ "open": ohlc.OpenPrice, "high": ohlc.HighPrice, "low": ohlc.LowPrice, "close": ohlc.ClosePrice, "volume": ohlc.Volume, } p := influxdb2.NewPoint( pair.NormalizedBase, tags, fields, ohlc.StartTime) writeAPI.WritePoint(p) } }
We create a new writeAPI each time we upsert OHLC data, we should instead just make this a part of the RepositoryImpl type.
writeAPI
RepositoryImpl
We create a new
writeAPI
each time we upsert OHLC data, we should instead just make this a part of theRepositoryImpl
type.