Created
December 28, 2020 11:49
-
-
Save ysv/b2fc09485df03f4ba6f52270d38ea5f5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "influxdb" | |
| require "active_support/all" | |
| require "pry-byebug" | |
| username = 'admin' | |
| password = 'changeme' | |
| database = 'dex_poc' | |
| name = 'sins' | |
| influxdb = InfluxDB::Client.new database, username: username, password: password, host: "127.0.0.1" | |
| beginning = Time.now.end_of_year | |
| # 71.85MB - 10k | |
| # 75.69MB - 110k | |
| # 4MB = 100K points | |
| # 40MB = 1M points | |
| # 400MB = 10M points | |
| # | |
| # 100k = 82.84MB | |
| # 1M = 125.8MB | |
| # | |
| # 42MB = 1M OHLC points ~ 2 years of 1m points | |
| 10.times do | |
| Array.new(100_000) do |i| | |
| { | |
| series: "ohlcv", | |
| values: { o: rand * 20_000, h: rand * 20_000, l: rand * 20_000, c: rand * 20_000, v: rand * 20_000 }, | |
| tags: { market: "btcusd" }, | |
| timestamp: (beginning + 10 * i).to_i | |
| } | |
| end.yield_self { |datas| influxdb.write_points(datas) } | |
| end | |
| # Enumerator that emits a sine wave | |
| # Value = (0..360).to_a.map {|i| Math.send(:sin, i / 10.0) * 10 }.each | |
| # | |
| # loop do | |
| # data = { | |
| # values: { value: Value.next }, | |
| # tags: { wave: 'sine' } # tags are optional | |
| # } | |
| # | |
| # influxdb.write_point(name, data) | |
| # | |
| # sleep 1 | |
| # end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment