kandi background
Explore Kits

moneta | a unified interface to key/value stores | Database library

 by   moneta-rb Ruby Version: v1.5.1 License: MIT

 by   moneta-rb Ruby Version: v1.5.1 License: MIT

Download this library from

kandi X-RAY | moneta Summary

moneta is a Ruby library typically used in Database applications. moneta has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.
Moneta provides a standard interface for interacting with various kinds of key/value stores. Moneta supports the well-known NoSQL and document based stores.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • moneta has a medium active ecosystem.
  • It has 1019 star(s) with 84 fork(s). There are 21 watchers for this library.
  • There were 2 major release(s) in the last 6 months.
  • There are 11 open issues and 117 have been closed. On average issues are closed in 204 days. There are 2 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of moneta is v1.5.1
moneta Support
Best in #Database
Average in #Database
moneta Support
Best in #Database
Average in #Database

quality kandi Quality

  • moneta has 0 bugs and 50 code smells.
moneta Quality
Best in #Database
Average in #Database
moneta Quality
Best in #Database
Average in #Database

securitySecurity

  • moneta has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • moneta code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
moneta Security
Best in #Database
Average in #Database
moneta Security
Best in #Database
Average in #Database

license License

  • moneta is licensed under the MIT License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
moneta License
Best in #Database
Average in #Database
moneta License
Best in #Database
Average in #Database

buildReuse

  • moneta releases are available to install and integrate.
  • Installation instructions, examples and code snippets are available.
  • moneta saves you 5517 person hours of effort in developing the same functionality from scratch.
  • It has 11557 lines of code, 754 functions and 296 files.
  • It has high code complexity. Code complexity directly impacts maintainability of the code.
moneta Reuse
Best in #Database
Average in #Database
moneta Reuse
Best in #Database
Average in #Database
Top functions reviewed by kandi - BETA

Coming Soon for all Libraries!

Currently covering the most popular Java, JavaScript and Python libraries. See a SAMPLE HERE.
kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.

moneta Key Features

Indicates that the adapter is expected to work on this platform. Most adapters will at least work on MRI, but some are curently considered unstable, in which case they are not supported on any platform.

Make adapters thread-safe by using Moneta::Lock or by passing the option threadsafe: true to Moneta#new. There is also Moneta::Pool which can be used to share a store between multiple threads if the store is multi-process safe. I recommend to add the option :threadsafe to ensure thread-safety since for example under JRuby and Rubinius even the basic datastructures are not thread safe due to the lack of a global interpreter lock (GIL). This differs from MRI where some adapters might appear thread safe already but only due to the GIL.

Share a Moneta store between multiple processes using Moneta::Shared (See below).

If a store provides atomic increment it can be used with Moneta::Semaphore. You can add weak #increment support using the Moneta::WeakIncrement proxy.

If a store provides atomic creation it can be used with Moneta::Mutex. You can add weak #create support using the Moneta::WeakCreate proxy.

Add expiration support by using Moneta::Expires or by passing the option expires: true (or expires: <seconds> if you want all values to expire by default) to Moneta#new.

This indicates that there is some performance gain when fetching multiple values at once using #values_at/#fetch_values or #slice. For instance, the MGET instruction in Redis, or the ability to retrieve several rows in one query in SQL.

This indicates that there is some performance gain when storing multiple key/value pairs at once using #merge!/#update.

Sqlite/YAML/PStore are multiprocess safe, but the performance suffers badly since the whole database file must be locked for writing. Use a key/value server if you want multiprocess concurrency!

There are some servers which use the memcached protocol but which are persistent (e.g. MemcacheDB, Kai, IronCache, Roma, Flare and Kumofs)

This feature is only available if the dalli backend is selected

Store is multi-process safe because it is an in-memory store, values are not shared between multiple processes

Depends on server

Getting started

copy iconCopydownload iconDownload
$ gem install moneta

Moneta API

copy iconCopydownload iconDownload
#initialize(options)                      options differs per-store, and is used to set up the store.

#[](key)                                  retrieve a key. If the key is not available, return nil.

#load(key, options = {})                  retrieve a key. If the key is not available, return nil.

#fetch(key, options = {}, &block)         retrieve a key. If the key is not available, execute the
                                          block and return its return value.

#fetch(key, value, options = {})          retrieve a key. If the key is not available, return the value,

#[]=(key, value)                          set a value for a key. If the key is already used, clobber it.
                                          keys set using []= will never expire.

#store(key, value, options = {})          same as []=, but you can supply options.

#delete(key, options = {})                delete the key from the store and return the current value.

#key?(key, options = {})                  true if the key exists, false if it does not.

#increment(key, amount = 1, options = {}) increment numeric value. This is an atomic operation
                                          which is not supported by all stores. Returns current value.

#decrement(key, amount = 1, options = {}) increment numeric value. This is an atomic operation
                                          which is not supported by all stores. Returns current value.
                                          This is just syntactic sugar for incrementing with a negative value.

#create(key, value, options = {})         create entry. This is an atomic operation which is not supported by all stores.
                                          Returns true if the value was created.

#values_at(*keys, **options)              retrieve multiple keys. Returns an array of equal length to the keys.
                                          Each entry in the array is either the value corresponding to the key
                                          in the same position, or nil if the key is not available.

#fetch_values(*keys, **options, &block)   retrieve multiple keys. Return is identical to values_at, except that
                                          when a block is given it will be called once for each key that is not
                                          available, and the return value of the block will be used in place of
                                          nil in the array.

#slice(*keys, **options)                  retrieve multiple keys. Returns an enumerable of key-value pairs,
                                          one for each of the supplied keys that is present in the store.

#merge!(pairs, options = {})              set values for multiple keys. "pairs" must be an enumerable of
                                          key-value pairs to be stored. Any existing keys will be clobbered.

#merge!(pairs, options = {}, &block)      set values for multiple keys. For each existing key, execute the block
                                          passing the key, existing value and new value, and store the return
                                          value.

#update(pairs, options = {}, &block)      same as merge!

#each_key                                 return an enumerable which will yield all keys in the store, one at a
                                          time. This method is present if and only if the store supports the
                                          :each_key feature.

#each_key(&block)                         yield all keys in the store to the block, one at a time. Again, this
                                          method is present if and only if the store supports the :each_key
                                          feature.

#clear(options = {})                      clear all keys in this store.

#close                                    close database connection.

#features                                 return array of features, e.g. [:create, :expires, :increment]

#supports?(feature)                       returns true if store supports a given feature

Creating a Store

copy iconCopydownload iconDownload
store = Moneta.new(:Memcached, server: 'localhost:11211')
store['key'] = 'value'
store['hash_key'] = {a: 1, b: 2}
store['object_key'] = MarshallableRubyObject.new

Expiration

copy iconCopydownload iconDownload
cache = Moneta::Adapters::Memcached.new

# Or using the builder...
cache = Moneta.build do
  adapter :Memcached
end

# Expires in 60 seconds
cache.store(key, value, expires: 60)

# Never expire
cache.store(key, value, expires: 0)
cache.store(key, value, expires: false)

# Update expires time if value is found
cache.load(key, expires: 30)
cache.key?(key, expires: 30)

# Or remove the expiration if found
cache.load(key, expires: false)
cache.key?(key, expires: 0)

Key traversal

copy iconCopydownload iconDownload
store.each_key # returns an Enumerable
store.each_key do |key|
  store.load(key)  # read operations are supported within the block
  store[key] = "x" # behaviour of write operations is undefined
end

Atomic operations

copy iconCopydownload iconDownload
store.increment('counter')     # returns 1, counter created
store.increment('counter')     # returns 2
store.increment('counter', -1) # returns 1
store.increment('counter', 13) # returns 14
store.increment('counter', 0)  # returns 14
store.decrement('counter')     # returns 13
store['name'] = 'Moneta'
store.increment('name')        # raises an Exception

Syntactic sugar and option merger

copy iconCopydownload iconDownload
# All methods after 'with' get the options passed
store.with(raw: true).load('key')

# You can also specify the methods
store.with(raw: true, only: :load).load('key')
store.with(raw: true, except: [:key?, :increment]).load('key')

# Syntactic sugar for raw access
store.raw.load('key')

# Access substore where all keys get a prefix
substore = store.prefix('sub')
substore['key'] = 'value'
store['key']    # returns nil
store['subkey'] # returns 'value'

# Set expiration time for all keys
short_lived_store = store.expires(60)
short_lived_store['key'] = 'value'

Add proxies to existing store

copy iconCopydownload iconDownload
compressed_store = store.with(prefix: 'compressed') do
  use :Transformer, value: :zlib
end

store['key'] = 'this value will not be compressed'
compressed_store['key'] = 'value will be compressed'

Rack

copy iconCopydownload iconDownload
require 'rack/session/moneta'

# Use only the adapter name
use Rack::Session::Moneta, store: :Redis

# Use Moneta.new
use Rack::Session::Moneta, store: Moneta.new(:Memory, expires: true)

# Set rack options
use Rack::Session::Moneta, key: 'rack.session',
domain: 'foo.com',
path: '/',
expire_after: 2592000,
store: Moneta.new(:Memory, expires: true)

# Use the Moneta builder
use Rack::Session::Moneta do
  use :Expires
  adapter :Memory
end

Rails

copy iconCopydownload iconDownload
require 'action_dispatch/middleware/session/moneta_store'

# Only by adapter name
config.cache_store :moneta_store, store: :Memory

# Use Moneta.new
config.cache_store :moneta_store, store: Moneta.new(:Memory)

# Use the Moneta builder
config.cache_store :moneta_store, store: Moneta.build do
  use :Expires
  adapter :Memory
end

Padrino

copy iconCopydownload iconDownload
# Global Padrino caching
# Don't forget the expires: [true, Integer] if you want expiration support!
Padrino.cache = Moneta.new(:Memory, expires: true)

# Application caching
# Don't forget the expires: [true, Integer] if you want expiration support!
set :cache, Moneta.new(:Memory, expires: true)

Build your own key value server

copy iconCopydownload iconDownload
require 'moneta'

store = Moneta.build do
  use :Transformer, key: :marshal, value: :marshal
  use :Shared do
    use :Cache do
      cache do
        adapter :LRUHash
      end
      backend do
        adapter :GDBM, file: 'shared.db'
      end
    end
  end
end

ToyStore ORM

copy iconCopydownload iconDownload
# Use the Moneta Redis backend
Person.adapter :memory, Moneta.new(:Redis)

How to use cumulative sum function for grouped data with missing observations

copy iconCopydownload iconDownload
library(dplyr)
df1 <- df1 %>%
     group_by(CP) %>%
     mutate(AKTUALNI.MNOZSTVI  = cumsum(MNOZSTVI))
df1$AKTUALNI.MNOZSTVI <- with(df1, ave(MNOZSTVI, CP, FUN = cumsum))
-----------------------
library(dplyr)
df1 <- df1 %>%
     group_by(CP) %>%
     mutate(AKTUALNI.MNOZSTVI  = cumsum(MNOZSTVI))
df1$AKTUALNI.MNOZSTVI <- with(df1, ave(MNOZSTVI, CP, FUN = cumsum))
-----------------------
library(dplyr)
df %>%
  group_by(CP) %>%
  mutate(AKTUALNI.MNOZSTVI  = cumsum(MNOZSTVI))
   DATUM      CP                         SMER  TRH   MNOZSTVI  CENA POPLATKY OBJEM UCET  KVARTAL ROK.AKTUALNI..MNOZSTVI AKTUALNI.MNOZSTVI
   <chr>      <chr>                      <chr> <chr>    <int> <dbl> <chr>    <chr> <chr> <chr>   <chr>                              <int>
 1 2020-03-03 00:00:00 CEZ               K     BCPP        50 465   91.3     NA    CZK   Q1      2020 NA                               50
 2 2020-03-04 00:00:00 CEZ               K     BCPP        50 467   58.9     NA    CZK   Q1      2020 NA                              100
 3 2020-03-12 00:00:00 CEZ               P     BCPP        30 398   51.8     11940 CZK   Q1      2020                                 130
 4 2020-03-25 00:00:00 KOMERCNI BANKA    K     BCPP        40 542   85.9     -     CZK   Q1      2020                                  40
 5 2020-03-25 00:00:00 MONETA MONEY BANK K     BCPP       300  58.4 71.3     -     CZK   Q1      2020                                 300
 6 2020-03-30 00:00:00 CEZ               K     BCPP        10 391   50       -     CZK   Q1      2020                                 140
 7 2020-04-02 00:00:00 USD               K     NA        1000  25.8 0        -     CZK   Q2      2020                                1000
 8 2020-04-03 00:00:00 USD               K     NA        3000  26.1 0        -     CZK   Q2      2020                                4000
 9 2020-04-04 00:00:00 USD               K     NA        1000  26.4 0        -     CZK   Q2      2020                                5000
10 2020-04-06 00:00:00 AVAST             K     BCPP       150 125   75. 8    -     CZK   Q2      2020                                 150
df <- tibble::tribble(
        ~DATUM,                          ~CP, ~SMER,   ~TRH, ~MNOZSTVI, ~CENA, ~POPLATKY,  ~OBJEM, ~UCET, ~KVARTAL, ~ROK.AKTUALNI..MNOZSTVI,
  "2020-03-03",               "00:00:00 CEZ",   "K", "BCPP",       50L,   465,    "91.3",      NA, "CZK",     "Q1",               "2020 NA",
  "2020-03-04",               "00:00:00 CEZ",   "K", "BCPP",       50L,   467,    "58.9",      NA, "CZK",     "Q1",               "2020 NA",
  "2020-03-12",               "00:00:00 CEZ",   "P", "BCPP",       30L,   398,    "51.8", "11940", "CZK",     "Q1",                  "2020",
  "2020-03-25",    "00:00:00 KOMERCNI BANKA",   "K", "BCPP",       40L,   542,    "85.9",     "-", "CZK",     "Q1",                  "2020",
  "2020-03-25", "00:00:00 MONETA MONEY BANK",   "K", "BCPP",      300L,  58.4,    "71.3",     "-", "CZK",     "Q1",                  "2020",
  "2020-03-30",               "00:00:00 CEZ",   "K", "BCPP",       10L,   391,      "50",     "-", "CZK",     "Q1",                  "2020",
  "2020-04-02",               "00:00:00 USD",   "K",     NA,     1000L,  25.8,       "0",     "-", "CZK",     "Q2",                  "2020",
  "2020-04-03",               "00:00:00 USD",   "K",     NA,     3000L,  26.1,       "0",     "-", "CZK",     "Q2",                  "2020",
  "2020-04-04",               "00:00:00 USD",   "K",     NA,     1000L,  26.4,       "0",     "-", "CZK",     "Q2",                  "2020",
  "2020-04-06",             "00:00:00 AVAST",   "K", "BCPP",      150L,   125,   "75. 8",     "-", "CZK",     "Q2",                  "2020"
  )
-----------------------
library(dplyr)
df %>%
  group_by(CP) %>%
  mutate(AKTUALNI.MNOZSTVI  = cumsum(MNOZSTVI))
   DATUM      CP                         SMER  TRH   MNOZSTVI  CENA POPLATKY OBJEM UCET  KVARTAL ROK.AKTUALNI..MNOZSTVI AKTUALNI.MNOZSTVI
   <chr>      <chr>                      <chr> <chr>    <int> <dbl> <chr>    <chr> <chr> <chr>   <chr>                              <int>
 1 2020-03-03 00:00:00 CEZ               K     BCPP        50 465   91.3     NA    CZK   Q1      2020 NA                               50
 2 2020-03-04 00:00:00 CEZ               K     BCPP        50 467   58.9     NA    CZK   Q1      2020 NA                              100
 3 2020-03-12 00:00:00 CEZ               P     BCPP        30 398   51.8     11940 CZK   Q1      2020                                 130
 4 2020-03-25 00:00:00 KOMERCNI BANKA    K     BCPP        40 542   85.9     -     CZK   Q1      2020                                  40
 5 2020-03-25 00:00:00 MONETA MONEY BANK K     BCPP       300  58.4 71.3     -     CZK   Q1      2020                                 300
 6 2020-03-30 00:00:00 CEZ               K     BCPP        10 391   50       -     CZK   Q1      2020                                 140
 7 2020-04-02 00:00:00 USD               K     NA        1000  25.8 0        -     CZK   Q2      2020                                1000
 8 2020-04-03 00:00:00 USD               K     NA        3000  26.1 0        -     CZK   Q2      2020                                4000
 9 2020-04-04 00:00:00 USD               K     NA        1000  26.4 0        -     CZK   Q2      2020                                5000
10 2020-04-06 00:00:00 AVAST             K     BCPP       150 125   75. 8    -     CZK   Q2      2020                                 150
df <- tibble::tribble(
        ~DATUM,                          ~CP, ~SMER,   ~TRH, ~MNOZSTVI, ~CENA, ~POPLATKY,  ~OBJEM, ~UCET, ~KVARTAL, ~ROK.AKTUALNI..MNOZSTVI,
  "2020-03-03",               "00:00:00 CEZ",   "K", "BCPP",       50L,   465,    "91.3",      NA, "CZK",     "Q1",               "2020 NA",
  "2020-03-04",               "00:00:00 CEZ",   "K", "BCPP",       50L,   467,    "58.9",      NA, "CZK",     "Q1",               "2020 NA",
  "2020-03-12",               "00:00:00 CEZ",   "P", "BCPP",       30L,   398,    "51.8", "11940", "CZK",     "Q1",                  "2020",
  "2020-03-25",    "00:00:00 KOMERCNI BANKA",   "K", "BCPP",       40L,   542,    "85.9",     "-", "CZK",     "Q1",                  "2020",
  "2020-03-25", "00:00:00 MONETA MONEY BANK",   "K", "BCPP",      300L,  58.4,    "71.3",     "-", "CZK",     "Q1",                  "2020",
  "2020-03-30",               "00:00:00 CEZ",   "K", "BCPP",       10L,   391,      "50",     "-", "CZK",     "Q1",                  "2020",
  "2020-04-02",               "00:00:00 USD",   "K",     NA,     1000L,  25.8,       "0",     "-", "CZK",     "Q2",                  "2020",
  "2020-04-03",               "00:00:00 USD",   "K",     NA,     3000L,  26.1,       "0",     "-", "CZK",     "Q2",                  "2020",
  "2020-04-04",               "00:00:00 USD",   "K",     NA,     1000L,  26.4,       "0",     "-", "CZK",     "Q2",                  "2020",
  "2020-04-06",             "00:00:00 AVAST",   "K", "BCPP",      150L,   125,   "75. 8",     "-", "CZK",     "Q2",                  "2020"
  )
-----------------------
library(dplyr)
df %>%
  group_by(CP) %>%
  mutate(AKTUALNI.MNOZSTVI  = cumsum(MNOZSTVI))
   DATUM      CP                         SMER  TRH   MNOZSTVI  CENA POPLATKY OBJEM UCET  KVARTAL ROK.AKTUALNI..MNOZSTVI AKTUALNI.MNOZSTVI
   <chr>      <chr>                      <chr> <chr>    <int> <dbl> <chr>    <chr> <chr> <chr>   <chr>                              <int>
 1 2020-03-03 00:00:00 CEZ               K     BCPP        50 465   91.3     NA    CZK   Q1      2020 NA                               50
 2 2020-03-04 00:00:00 CEZ               K     BCPP        50 467   58.9     NA    CZK   Q1      2020 NA                              100
 3 2020-03-12 00:00:00 CEZ               P     BCPP        30 398   51.8     11940 CZK   Q1      2020                                 130
 4 2020-03-25 00:00:00 KOMERCNI BANKA    K     BCPP        40 542   85.9     -     CZK   Q1      2020                                  40
 5 2020-03-25 00:00:00 MONETA MONEY BANK K     BCPP       300  58.4 71.3     -     CZK   Q1      2020                                 300
 6 2020-03-30 00:00:00 CEZ               K     BCPP        10 391   50       -     CZK   Q1      2020                                 140
 7 2020-04-02 00:00:00 USD               K     NA        1000  25.8 0        -     CZK   Q2      2020                                1000
 8 2020-04-03 00:00:00 USD               K     NA        3000  26.1 0        -     CZK   Q2      2020                                4000
 9 2020-04-04 00:00:00 USD               K     NA        1000  26.4 0        -     CZK   Q2      2020                                5000
10 2020-04-06 00:00:00 AVAST             K     BCPP       150 125   75. 8    -     CZK   Q2      2020                                 150
df <- tibble::tribble(
        ~DATUM,                          ~CP, ~SMER,   ~TRH, ~MNOZSTVI, ~CENA, ~POPLATKY,  ~OBJEM, ~UCET, ~KVARTAL, ~ROK.AKTUALNI..MNOZSTVI,
  "2020-03-03",               "00:00:00 CEZ",   "K", "BCPP",       50L,   465,    "91.3",      NA, "CZK",     "Q1",               "2020 NA",
  "2020-03-04",               "00:00:00 CEZ",   "K", "BCPP",       50L,   467,    "58.9",      NA, "CZK",     "Q1",               "2020 NA",
  "2020-03-12",               "00:00:00 CEZ",   "P", "BCPP",       30L,   398,    "51.8", "11940", "CZK",     "Q1",                  "2020",
  "2020-03-25",    "00:00:00 KOMERCNI BANKA",   "K", "BCPP",       40L,   542,    "85.9",     "-", "CZK",     "Q1",                  "2020",
  "2020-03-25", "00:00:00 MONETA MONEY BANK",   "K", "BCPP",      300L,  58.4,    "71.3",     "-", "CZK",     "Q1",                  "2020",
  "2020-03-30",               "00:00:00 CEZ",   "K", "BCPP",       10L,   391,      "50",     "-", "CZK",     "Q1",                  "2020",
  "2020-04-02",               "00:00:00 USD",   "K",     NA,     1000L,  25.8,       "0",     "-", "CZK",     "Q2",                  "2020",
  "2020-04-03",               "00:00:00 USD",   "K",     NA,     3000L,  26.1,       "0",     "-", "CZK",     "Q2",                  "2020",
  "2020-04-04",               "00:00:00 USD",   "K",     NA,     1000L,  26.4,       "0",     "-", "CZK",     "Q2",                  "2020",
  "2020-04-06",             "00:00:00 AVAST",   "K", "BCPP",      150L,   125,   "75. 8",     "-", "CZK",     "Q2",                  "2020"
  )

VBA force closes Excel 365 but works fine in Excel 2019

copy iconCopydownload iconDownload
Private Sub Worksheet_Change(ByVal Target As Range)
    Const RNG_TS As String = "F25"
    Const RNG As String = "F3"
    Dim stringa As String

    If Target.Cells.CountLarge > 1 Then Exit Sub
    'in a sheet module you can use `Me` to refer to the sheet...
    If Target.Address = Me.Range(RNG_TS).Address Then Exit Sub 'prevent re-entry
    
    Me.Range(RNG_TS).Value = "Aggiornamento giacenza: " & _
                             Format(Now(), "dd/mm/yyyy - hh:mm:ss")
    
    If Target.Address = Me.Range(RNG).Address Then
        stringa = UCase(Trim(Target.Value)) 'always worth adding Trim() for user-entered values
        If InStr(1, stringa, "cassa", vbTextCompare) = 0 Then stringa = "CASSA " & stringa
        On Error GoTo haveError
        Application.EnableEvents = False
        Target.Value = stringa
        Application.EnableEvents = True
    End If
    
    Exit Sub
    
haveError:
    'make sure this is re-enabled
    Application.EnableEvents = True

End Sub

KARATE: print statement doesn't write to console with log4j2

copy iconCopydownload iconDownload
appenders = console
appender.console.type = Console
appender.console.name = STDOUT
appender.console.layout = org.apache.log4j.PatternLayout


rootLogger.level = debug
rootLogger.appenderRefs = stdout
rootLogger.appenderRef.stdout.ref = STDOUT

MonetaryException: No MonetaryAmountsSingletonSpi loaded

copy iconCopydownload iconDownload
@Bean
public MonetaryAmountFactory<?> money() {
    return Monetary.getDefaultAmountFactory();
}


@Component
@RequiredArgsConstructor
public static class Runner implements CommandLineRunner {

    private final MonetaryAmountFactory<?> amountFactory;

    @Override
    public void run(String... args) {
        var monetaryAmount = this.amountFactory
            .setCurrency("EUR")
            .setNumber(1)
            .create();

        System.out.println("monetaryAmount = " + monetaryAmount);
    }
}
public static class Runner implements CommandLineRunner {

    @Override
    public void run(String... args) {
        var monetaryAmount = Monetary.getDefaultAmountFactory()
            .setCurrency("EUR")
            .setNumber(1)
            .create();

        System.out.println("monetaryAmount = " + monetaryAmount);
    }
}
Limits:
  cpu:     6
  memory:  20G
Requests:
  cpu:      3
  memory:   20G
Limits:
  cpu:     2
  memory:  2G
Requests:
  cpu:      2
  memory:   128Mi
-----------------------
@Bean
public MonetaryAmountFactory<?> money() {
    return Monetary.getDefaultAmountFactory();
}


@Component
@RequiredArgsConstructor
public static class Runner implements CommandLineRunner {

    private final MonetaryAmountFactory<?> amountFactory;

    @Override
    public void run(String... args) {
        var monetaryAmount = this.amountFactory
            .setCurrency("EUR")
            .setNumber(1)
            .create();

        System.out.println("monetaryAmount = " + monetaryAmount);
    }
}
public static class Runner implements CommandLineRunner {

    @Override
    public void run(String... args) {
        var monetaryAmount = Monetary.getDefaultAmountFactory()
            .setCurrency("EUR")
            .setNumber(1)
            .create();

        System.out.println("monetaryAmount = " + monetaryAmount);
    }
}
Limits:
  cpu:     6
  memory:  20G
Requests:
  cpu:      3
  memory:   20G
Limits:
  cpu:     2
  memory:  2G
Requests:
  cpu:      2
  memory:   128Mi
-----------------------
@Bean
public MonetaryAmountFactory<?> money() {
    return Monetary.getDefaultAmountFactory();
}


@Component
@RequiredArgsConstructor
public static class Runner implements CommandLineRunner {

    private final MonetaryAmountFactory<?> amountFactory;

    @Override
    public void run(String... args) {
        var monetaryAmount = this.amountFactory
            .setCurrency("EUR")
            .setNumber(1)
            .create();

        System.out.println("monetaryAmount = " + monetaryAmount);
    }
}
public static class Runner implements CommandLineRunner {

    @Override
    public void run(String... args) {
        var monetaryAmount = Monetary.getDefaultAmountFactory()
            .setCurrency("EUR")
            .setNumber(1)
            .create();

        System.out.println("monetaryAmount = " + monetaryAmount);
    }
}
Limits:
  cpu:     6
  memory:  20G
Requests:
  cpu:      3
  memory:   20G
Limits:
  cpu:     2
  memory:  2G
Requests:
  cpu:      2
  memory:   128Mi
-----------------------
@Bean
public MonetaryAmountFactory<?> money() {
    return Monetary.getDefaultAmountFactory();
}


@Component
@RequiredArgsConstructor
public static class Runner implements CommandLineRunner {

    private final MonetaryAmountFactory<?> amountFactory;

    @Override
    public void run(String... args) {
        var monetaryAmount = this.amountFactory
            .setCurrency("EUR")
            .setNumber(1)
            .create();

        System.out.println("monetaryAmount = " + monetaryAmount);
    }
}
public static class Runner implements CommandLineRunner {

    @Override
    public void run(String... args) {
        var monetaryAmount = Monetary.getDefaultAmountFactory()
            .setCurrency("EUR")
            .setNumber(1)
            .create();

        System.out.println("monetaryAmount = " + monetaryAmount);
    }
}
Limits:
  cpu:     6
  memory:  20G
Requests:
  cpu:      3
  memory:   20G
Limits:
  cpu:     2
  memory:  2G
Requests:
  cpu:      2
  memory:   128Mi

I can not log in to the site through curl

copy iconCopydownload iconDownload
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
'Content-Type: application/x-www-form-urlencoded'
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query( $post ) );
-----------------------
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
'Content-Type: application/x-www-form-urlencoded'
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query( $post ) );
-----------------------
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
'Content-Type: application/x-www-form-urlencoded'
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query( $post ) );

Convert MonetaryAmount to long of minor units (Javamoney)

copy iconCopydownload iconDownload
long minorUnits = monetaryAmount.query(MonetaryQueries.convertMinorPart()); //1234

Wildfly Swarm (Thorntail) cannot start - InvocationTargetException

copy iconCopydownload iconDownload
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
    <persistence-unit name="h2DataBase" transaction-type="JTA">
        <properties>
            <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
        </properties>
    </persistence-unit>
</persistence> 
<?xml version="1.0" encoding="UTF-8"?>
<persistence
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        version="2.1"
        xmlns="http://xmlns.jcp.org/xml/ns/persistence"
        xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">

    <persistence-unit name="test" transaction-type="JTA">
        <class>model.Account</class>
        <class>model.Owner</class>
        <class>model.payments.Payment</class>
        <properties>
            <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
            <property name="javax.persistence.jdbc.url"    value="jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" />
            <property name="javax.persistence.jdbc.user" value="sa" />
            <property name="javax.persistence.jdbc.password" value="" />

            <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
            <property name="hibernate.hbm2ddl.auto" value="create-drop" />
            <property name="show_sql" value="true"/>
            <property name="hibernate.temp.use_jdbc_metadata_defaults" value="false"/>
        </properties>
    </persistence-unit>
</persistence>
-----------------------
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
    <persistence-unit name="h2DataBase" transaction-type="JTA">
        <properties>
            <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
        </properties>
    </persistence-unit>
</persistence> 
<?xml version="1.0" encoding="UTF-8"?>
<persistence
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        version="2.1"
        xmlns="http://xmlns.jcp.org/xml/ns/persistence"
        xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">

    <persistence-unit name="test" transaction-type="JTA">
        <class>model.Account</class>
        <class>model.Owner</class>
        <class>model.payments.Payment</class>
        <properties>
            <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
            <property name="javax.persistence.jdbc.url"    value="jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" />
            <property name="javax.persistence.jdbc.user" value="sa" />
            <property name="javax.persistence.jdbc.password" value="" />

            <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
            <property name="hibernate.hbm2ddl.auto" value="create-drop" />
            <property name="show_sql" value="true"/>
            <property name="hibernate.temp.use_jdbc_metadata_defaults" value="false"/>
        </properties>
    </persistence-unit>
</persistence>

Issue with MT4 OHLC to .CSV file

copy iconCopydownload iconDownload
       WriteData( DoubleToStr( dSymClose, iDigits ) + ","
                + DoubleToStr( RSI5_c,    2 )       + ","
                + DoubleToStr( RSI5_p3,   2 )       + ","
                + DoubleToStr( MOM3_c,    2 )       + ","
                + DoubleToStr( MOM3_p3,   2 )       + ","
                + DoubleToStr( CCI11_c,   2 )       + ","
                + DoubleToStr( CCI11_p3,  2 )       + ","
                  );
       iDigits    = MarketInfo(  Symbol(),MODE_DIGITS );
       dSymOpen   = ( iOpen(    dSymbol,  Period(), i ) );
       dSymHigh   = ( iHigh(    dSymbol,  Period(), i ) );
       dSymLow    = ( iLow(     dSymbol,  Period(), i ) );
       dSymClose  = ( iClose(   dSymbol,  Period(), i ) );
       dSymVolume = ( iVolume(  dSymbol,  Period(), i ) );
       double RSI5_c   =  iRSI(      NULL, 0,  5, PRICE_CLOSE, i   );
       double RSI5_p3  =  iRSI(      NULL, 0,  5, PRICE_CLOSE, i+3 );
       double MOM3_c   =  iMomentum( NULL, 0, 21, PRICE_CLOSE, i   );
       double MOM3_p3  =  iMomentum( NULL, 0, 21, PRICE_CLOSE, i+3 );
       double CCI11_c  =  iCCI(      NULL, 0,  5, PRICE_CLOSE, i   );
       double CCI11_p3 =  iCCI(      NULL, 0,  5, PRICE_CLOSE, i+3 );
// #property copyright "Copyright © 2012, fxprotrader" #property link      "http://www.fxpro-trader.com"
// #property show_inputs

    // a number of bars to export per Symbol
   //  int    maxBars = 6418;
extern int    maxBars =  200;
       int    handle;
       string dSymbol;
       double Poin;

 // test first on several pairs
//     string Currencies[] = { "EURUSD", "AUDUSD", "GBPUSD", "EURJPY", "GBPJPY", "USDCAD" };
       string Currencies[] = { "#Corn",
                               "#France40",
                               "#Germany30",
                               "#NaturalGas",
                               "#Oil",
                               "#UK100",
                               "#USA30",
                               "#USA500",
                               "#USTECH100",
                               "#Wheat",
                               "#XAGUSD",
                               "#XAUUSD",
                               "58.com",
                               "ABENGOA",
                               "ABNAmro",  "ADIDAS",   "ADIDAS",   "AGRICOLE", "AIB",  "AIRBUS",   "Albemarle",    "ALCATEL",  "ALCOA",    "ALIBABA",  "ALLIANZ",  "ALPHA",    "AlticeUSA",    "Aluminium",    "AMADEUS",  "AMAZON",   "AMD",  "AMEX", "AMOVIL",   "Amsterdam25",  "Anglo",    "APACHE",   "APPLE",    "APPLE.",   "ARCELOR",  "Arconic",  "ASTRAZENECA",  "ATnT", "AUDBRL",   "AUDCAD",   "AUDCAD!",  "AUDCAD.",  "AUDCHF",   "AUDCHF!",  "AUDCHF.",  "AUDCNH",   "AUDCZK",   "AUDDKK",   "AUDHKD",   "AUDHRK",   "AUDHUF",   "AUDILS",   "AUDINR",   "AUDJPY",   "AUDJPY!",  "AUDJPY.",  "AUDMXN",   "AUDNOK",   "AUDNZD",   "AUDNZD!",  "AUDNZD.",  "AUDPLN",   "AUDPNC",   "AUDRON",   "AUDRUB",   "AUDSEK",   "AUDSGD",   "AUDTRY",   "AUDUSD",   "AUDUSD!",  "AUDUSD.",  "AUDZAR",   "Autodesk", "AVAGO",    "AVOLON",   "BAIDU",    "BancoBPM", "BASF", "BAYER",    "BBBeyond", "BBVA", "BerkshireB",   "BestBuy",  "Billiton", "BITCOIN",  "BITCOIN-D",    "BITCOIN-M",    "BITCOIN-W",    "BlackBerry",   "BMO",  "BMPS", "BMPSIENA", "BMW",  "BNPEU",    "BOA",  "BOEING",   "BP",   "BrentOil", "BRLJPY",   "BRLPLN",   "BTCUSD",   "Burberry", "BUZZI",    "CADBRL",   "CADCHF",   "CADCHF.",  "CADCNH",   "CADDKK",   "CADHKD",   "CADHRK",   "CADHUF",   "CADILS",   "CADINR",   "CADJPY",   "CADJPY.",  "CADMXN",   "CADNOK",   "CADPLN",   "CADRON",   "CADRUB",   "CADSEK",   "CADSGD",   "CADTRY",   "CADZAR",   "CAP",  "CARREFOUR",    "CATERPILLAR",  "CEMEX",    "CEZ",  "CHFJPY",   "CHFJPY.",  "CHFPLN",   "CHFPLN.",  "ChildrensPl",  "China300ETF",  "China50",  "ChinaMob", "CISCO",    "CitiGroup",    "CNHJPY",   "COCACOLA", "Cocoa",    "Cocoa!",   "Cocoa!",   "Coffee",   "Coffee!",  "Coffee!",  "Cognex",   "COMMERZBANK",  "Copper",   "CoreCivic",    "Corn", "Corn!",    "Corn!",    "Costco",   "Cotton",   "Cotton!",  "Ctrip.com",    "CZKPLN",   "DAIMLER",  "DanskeBank",   "DaveBuster",   "Deere",    "Denmark20",    "DeutschBank",  "DeutscheTel",  "DeutscheTel",  "Diamond",  "DIGICEL",  "DISNEY",   "DKKJPY",   "DKKPLN",   "DNB",  "doBank",   "Dollarindex",  "easyJet",  "EBAY", "EDF",  "EEE",  "ELECTRICA",    "Ellaktor", "ELPE", "EMPRESAS", "ENAGAS",   "ENEL", "ENI",  "EOAN", "Ericsson", "ERSTE",    "ETE",  "EURAUD",   "EURAUD!",  "EURAUD.",  "EURBRL",   "EURCAD",   "EURCAD!",  "EURCAD.",  "EURCHF",   "EURCHF!",  "EURCHF.",  "EURCNH",   "EURCZK",   "EURCZK.",  "EURDKK",   "EURDKK.",  "EURGBP",   "EURGBP!",  "EURGBP.",  "EURHKD",   "EURHRK",   "EURHUF",   "EURHUF.",  "EURILS",   "EURINR",   "EURJPY",   "EURJPY!",  "EURJPY.",  "EURMXN",   "EURNOK",   "EURNOK.",  "EURNZD",   "EURNZD.",  "EUROPCAR", "EUROPCAR", "Europe50", "EURPLN",   "EURPLN.",  "EURPNC",   "EURRON",   "EURRON.",  "EURRUB",   "EURSEK",   "EURSEK.",  "EURSGD",   "EURTRY",   "EURTRY.",  "EURUSD",   "EURUSD!",  "EURUSD.",  "EURZAR",   "Expedia",  "ExxonMobil",   "Facebook", "FAURECIA", "FCA",  "FERRARI",  "FIAT", "FirstData",    "FITBIT",   "FOMENTO",  "France40", "FSOLAR",   "GAMESA",   "GameStop", "Gap",  "GAZPROM",  "GBPAUD",   "GBPAUD!",  "GBPAUD.",  "GBPCAD",   "GBPCAD!",  "GBPCAD.",  "GBPCHF",   "GBPCHF!",  "GBPCHF.",  "GBPCNH",   "GBPCZK",   "GBPDKK",   "GBPHKD",   "GBPHRK",   "GBPHUF",   "GBPILS",   "GBPJPY",   "GBPJPY!",  "GBPJPY.",  "GBPMXN",   "GBPNOK",   "GBPNZD",   "GBPNZD.",  "GBPPLN",   "GBPRON",   "GBPRON.",  "GBPRUB",   "GBPSEK",   "GBPSGD",   "GBPSGD.",  "GBPTRY",   "GBPTRY.",  "GBPUSD",   "GBPUSD!",  "GBPUSD.",  "GBPZAR",   "GE",   "GEMALTO",  "GENERALI", "GER10YBond",   "germany30",    "GILEAD",   "Gilt10Y",  "GLENCORE", "GM",   "GoDaddy",  "GolarLNG", "GoldmnSachs",  "GOOGLE",   "GoPro",    "Greece20", "GRIFOLS",  "Grivalia", "Groupon",  "GRUMA",    "Handelsbank",  "Harley",   "HEINEKEN", "HEINEKEN", "Hermes",   "HewlettEnt",   "HILTON",   "HKDJPY",   "HKDPLN",   "HongKong45",   "HP",   "HRKJPY",   "HSBC", "HTO",  "HUBSPOT",  "HUFJPY",   "HUFPLN",   "IBERDROLA",    "IBM",  "Ikang",    "ILIAD",    "ILSBRL",   "ILSCNH",   "ILSCZK",   "ILSDKK",   "ILSHKD",   "ILSHUF",   "ILSINR",   "ILSJPY",   "ILSMXN",   "ILSNOK",   "ILSPLN",   "ILSPNC",   "ILSRON",   "ILSRUB",   "ILSSEK",   "ILSSGD",   "ILSTRY",   "ILSZAR",   "India50",  "INDITEX",  "INDRA",    "INFINEON", "INTEL",    "INTESA",   "Intuit",   "Italy40",  "JABIL",    "Japan225", "JAZZTEL",  "JCPenney", "JCPenney", "JD.com",   "JIMMYCHOO",    "JPMorgan", "JPN10yBond",   "JPYINR",   "Jumbo",    "K+S",  "K+S",  "KGHM", "KING", "KirbyCorp",    "KOMERCNI", "KRAFT",    "LEVTST",   "Line", "LineCorp", "LINKEDIN", "LionsGate",    "Lloyds",   "LockheedM",    "LUFTHANSA",    "LukoilUSD",    "Lululemon",    "LVMH", "Macys",    "MAGNIT",   "MANU", "MARRIOTT", "MARVELL",  "Mastercard",   "Match",    "McDonalds",    "MEGAFON",  "METRO",    "MGM",  "MICHELIN", "MICRON",   "MICROSOFT",    "MOL",  "MOMO", "MONDELEZ", "Moneta",   "MONSANTO", "MorganStan",   "Moscow50", "MotorOil", "MsciMexico",   "MSCITaiwan",   "MTELEKOM", "MTN",  "MXNJPY",   "MXNPLN",   "Mytilineos",   "Mytilineos",   "NaturalGas",   "NESTLE",   "NETFLIX",  "NewOriental",  "NIKE", "Nintendo", "NintendoJP",   "NOBLE",    "NOKIA",    "NOKJPY",   "NOKPLN",   "Norway25", "NovoNord", "Novozymes",    "NUANCE",   "NWR",  "NZDCAD",   "NZDCAD.",  "NZDCHF",   "NZDCHF.",  "NZDJPY",   "NZDJPY.",  "NZDUSD",   "NZDUSD!",  "NZDUSD.",  "Oil",  "OPAP", "ORACLE",   "OrangeFR", "OTP",  "Palladium",    "PartyCity",    "PayPal",   "PEKAO",    "PepsiCo",  "PetroChina",   "PetrolBras",   "PEUGEOT",  "PEUGEOT",  "PFIZER",   "PGE",  "PHILIPS",  "PIRELLI",  "PKNORLEN", "PKOBP",    "Platinum", "Play", "PLNCNH",   "PLNHRK",   "PLNINR",   "PLNJPY",   "PNCCAD",   "PNCJPY",   "PNCPLN",   "PNCUSD",   "Poland20", "POPOLARE", "POPULARESP",   "POSTEITALIA",  "POTASH",   "PPC",  "PRICELINE",    "PSBC", "PZU",  "Qualcomm", "QUNAR",    "RBS",  "REE",  "RegalBeloit",  "Renault",  "REPSOL",   "Rice", "RioTinto", "ROCKET",   "ROLLSROYCE",   "ROMGAZ",   "RONJPY",   "RONPLN",   "ROSNEFT",  "RUBJPY",   "RUBPLN",   "RWE",  "SABADELL", "SABMiller",    "SACYR",    "SafeBulkers",  "SAfrica40",    "SaintGobain",  "SALESFORCE",   "SAMSUNG",  "SANDISK",  "SANOFI",   "SANTANDER",    "SAP",  "Sasol",    "SBERBANK", "Scorpio",  "SEKJPY",   "SEKPLN",   "Severstal",    "SGDJPY",   "SGDPLN",   "ShakeShack",   "SHELL",    "SHOPIFY",  "SIEMENS",  "SINA", "Snap", "SOCIETE",  "SOLARCITY",    "SONY", "SouFun",   "soybeans", "Soybeans!",    "Soybeans!",    "Soybeans!",    "Spain35",  "Splunk",   "Square",   "STARBUCKS",    "Statoil",  "Sugar",    "Sweden30", "Swiss20",  "Sydney200",    "SYMANTEC", "Synaptics",    "Target",   "TDBank",   "TECK", "TECK.",    "TECK.",    "TELECOMITAL",  "TELEFONESP",   "TELEFONICA",   "Telenor",  "TeliaSonera",  "TerraForm",    "TESCO",    "TESLA",    "TEVA", "Tiffany",  "TitanCement",  "TOTAL",    "TOYOTA",   "TPSA", "TRIPADVISOR",  "TRYJPY",   "TRYPLN",   "Twilio",   "TWITTER",  "UBS",  "UK100",    "Unicredit",    "UNISTEEL", "US10YNote",    "US30YBond",    "USA2000",  "USA30",    "USA500",   "USDBRL",   "USDCAD",   "USDCAD!",  "USDCAD.",  "USDCHF",   "USDCHF!",  "USDCHF.",  "USDCNH",   "USDCZK",   "USDCZK.",  "USDDKK",   "USDDKK.",  "USDHKD",   "USDHRK",   "USDHUF",   "USDHUF.",  "USDILS",   "USDINR",   "USDJPY",   "USDJPY!",  "USDJPY.",  "USDMXN",   "USDNOK",   "USDNOK.",  "USDPLN",   "USDPLN!",  "USDPLN.",  "USDRON",   "USDRON.",  "USDRUB",   "USDSEK",   "USDSEK.",  "USDSGD",   "USDSGD.",  "USDTRY",   "USDTRY.",  "USDZAR",   "USFoods",  "USTECH100",    "VA",   "VALE", "VestasWind",   "VIG",  "VINCI",    "Vipshop",  "VISA", "VIVENDI",  "vixx", "VODAFONE", "VolksWagen",   "Volvo",    "WALMART",  "WEIBO",    "WellsFargo",   "Wheat",    "Wheat!",   "Wheat!",   "WIZZ", "WOWO", "WPP",  "XAGUSD",   "XAGUSD.",  "XAUUSD",   "XAUUSD.",  "Xylem",    "YAHOO",    "YamanaGold",   "YANDEX",   "Yara", "Yelp", "YYInc",    "ZARJPY",   "ZARPLN",   "Zinc", "ZTO",  "ZYNGA",
                                };

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init(){

    if (        Point == 0.00001 ) Poin = 0.0001;
    else { if ( Point == 0.001   ) Poin = 0.01;
           else                    Poin = Point;
    }
    return( 0 );
    }
//+------------------------------------------------------------------+
//| start function                                    |
//+------------------------------------------------------------------+
int start(){

    int count = ArraySize( Currencies );

    for ( int ii = 0; ii < count; ii++ ){

          dSymbol = Currencies[ii];   
          handle  = FileOpen( "Hist_" + dSymbol + "_" + Period() + ".csv", FILE_BIN | FILE_WRITE );

          if ( handle < 1 ){
               Print( "Err ", GetLastError() );
               return( 0 );
          }
          WriteHeader();

          for ( int i = 0; i < maxBars - 1; i++ ){
                WriteDataRow( i );
          }
          FileClose( handle );
     }
     Alert( "Done. "
          +  maxBars + " bars generated "
          +  TimeMonth( TimeLocal() )
          +  TimeDay(   TimeLocal() )
          +  TimeYear(  TimeLocal() )
          + "_"
          +  TimeHour(  TimeLocal() )
          +  TimeMinute(TimeLocal() )
             );

     return( 0 );
     }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void WriteData( string txt ){

     FileWriteString( handle, txt, StringLen( txt ) );

     return;
     }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void WriteHeader(){

     WriteData( "Symbol," );
     WriteData( "Date," );
     WriteData( "DayOfWeek," );
     WriteData( "DayOfYear," );
     WriteData( "Open," );
     WriteData( "High," );
     WriteData( "Low," );
     WriteData( "Close," );
     WriteData( "RSI5,RSI11,MOM3_c,CCI11_c," );
     WriteData( "\n" );

     return;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void WriteDataRow( int i ){

     double  dSymTime, dSymOpen, dSymHigh, dSymLow, dSymClose, dSymVolume;
     int     dDayofWk, dDayofYr, iDigits;

     dSymTime = ( iTime( dSymbol, Period(), i ) );
     dDayofWk = (  TimeDayOfWeek( dSymTime ) );
     dDayofYr =    TimeDayOfYear( dSymTime );

     dSymOpen = ( iOpen( dSymbol, Period(), i ) );

  // if (  TimeToStr( dSymTime, TIME_DATE ) != "1970." ){
     if (  dSymOpen >  0 ){

           WriteData( dSymbol + "," );
           WriteData( TimeToStr( dSymTime, TIME_DATE | TIME_MINUTES ) + "," );

           iDigits    = MarketInfo(  Symbol(),MODE_DIGITS );
           dSymOpen   = ( iOpen(    dSymbol,  Period(), i ) );
           dSymHigh   = ( iHigh(    dSymbol,  Period(), i ) );
           dSymLow    = ( iLow(     dSymbol,  Period(), i ) );
           dSymClose  = ( iClose(   dSymbol,  Period(), i ) );
           dSymVolume = ( iVolume(  dSymbol,  Period(), i ) );

       //  int    BarsInBox = 8;

       //  double PeriodHighest = High[iHighest( dSymbol, Period(), MODE_HIGH, BarsInBox + 1, i )];
       //  double PeriodLowest  = Low[ iLowest(  dSymbol, Period(), MODE_LOW,  BarsInBox + 1, i )];
       //  double PeriodRNG     = ( PeriodHighest - PeriodLowest ) / Poin;

           double RSI5_c   =  iRSI(      NULL, 0,  5, PRICE_CLOSE, i   );
           double RSI5_p3  =  iRSI(      NULL, 0,  5, PRICE_CLOSE, i+3 );
           double MOM3_c   =  iMomentum( NULL, 0, 21, PRICE_CLOSE, i   );
           double MOM3_p3  =  iMomentum( NULL, 0, 21, PRICE_CLOSE, i+3 );
           double CCI11_c  =  iCCI(      NULL, 0,  5, PRICE_CLOSE, i   );
           double CCI11_p3 =  iCCI(      NULL, 0,  5, PRICE_CLOSE, i+3 );

           WriteData( dDayofWk + "," + dDayofYr + "," );

           WriteData( DoubleToStr( dSymOpen,  iDigits ) + "," );
           WriteData( DoubleToStr( dSymHigh,  iDigits ) + "," );
           WriteData( DoubleToStr( dSymLow,   iDigits ) + "," );

       //  WriteData( DoubleToStr( dSymClose, iDigits ) + "," + PeriodHighest + "," + PeriodLowest + "," + PeriodRNG );
           WriteData( DoubleToStr( dSymClose, iDigits ) + ","
                    + DoubleToStr( RSI5_c,    2 )       + ","
                    + DoubleToStr( RSI5_p3,   2 )       + ","
                    + DoubleToStr( MOM3_c,    2 )       + ","
                    + DoubleToStr( MOM3_p3,   2 )       + ","
                    + DoubleToStr( CCI11_c,   2 )       + ","
                    + DoubleToStr( CCI11_p3,  2 )       + ","
                      );
           WriteData( "\n" );
     }
     return;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
string GetPeriodName() {

   switch( Period() ){

       case PERIOD_D1:  return( "Day" );
       case PERIOD_H4:  return( "4_Hour" );
       case PERIOD_H1:  return( "Hour" );
       case PERIOD_M1:  return( "Minute" );
       case PERIOD_M15: return( "15_Minute" );
       case PERIOD_M30: return( "30_Minute" );
       case PERIOD_M5:  return( "5_Minute" );
       case PERIOD_MN1: return( "Month" );
       case PERIOD_W1:  return( "Week" );
       }
   }
-----------------------
       WriteData( DoubleToStr( dSymClose, iDigits ) + ","
                + DoubleToStr( RSI5_c,    2 )       + ","
                + DoubleToStr( RSI5_p3,   2 )       + ","
                + DoubleToStr( MOM3_c,    2 )       + ","
                + DoubleToStr( MOM3_p3,   2 )       + ","
                + DoubleToStr( CCI11_c,   2 )       + ","
                + DoubleToStr( CCI11_p3,  2 )       + ","
                  );
       iDigits    = MarketInfo(  Symbol(),MODE_DIGITS );
       dSymOpen   = ( iOpen(    dSymbol,  Period(), i ) );
       dSymHigh   = ( iHigh(    dSymbol,  Period(), i ) );
       dSymLow    = ( iLow(     dSymbol,  Period(), i ) );
       dSymClose  = ( iClose(   dSymbol,  Period(), i ) );
       dSymVolume = ( iVolume(  dSymbol,  Period(), i ) );
       double RSI5_c   =  iRSI(      NULL, 0,  5, PRICE_CLOSE, i   );
       double RSI5_p3  =  iRSI(      NULL, 0,  5, PRICE_CLOSE, i+3 );
       double MOM3_c   =  iMomentum( NULL, 0, 21, PRICE_CLOSE, i   );
       double MOM3_p3  =  iMomentum( NULL, 0, 21, PRICE_CLOSE, i+3 );
       double CCI11_c  =  iCCI(      NULL, 0,  5, PRICE_CLOSE, i   );
       double CCI11_p3 =  iCCI(      NULL, 0,  5, PRICE_CLOSE, i+3 );
// #property copyright "Copyright © 2012, fxprotrader" #property link      "http://www.fxpro-trader.com"
// #property show_inputs

    // a number of bars to export per Symbol
   //  int    maxBars = 6418;
extern int    maxBars =  200;
       int    handle;
       string dSymbol;
       double Poin;

 // test first on several pairs
//     string Currencies[] = { "EURUSD", "AUDUSD", "GBPUSD", "EURJPY", "GBPJPY", "USDCAD" };
       string Currencies[] = { "#Corn",
                               "#France40",
                               "#Germany30",
                               "#NaturalGas",
                               "#Oil",
                               "#UK100",
                               "#USA30",
                               "#USA500",
                               "#USTECH100",
                               "#Wheat",
                               "#XAGUSD",
                               "#XAUUSD",
                               "58.com",
                               "ABENGOA",
                               "ABNAmro",  "ADIDAS",   "ADIDAS",   "AGRICOLE", "AIB",  "AIRBUS",   "Albemarle",    "ALCATEL",  "ALCOA",    "ALIBABA",  "ALLIANZ",  "ALPHA",    "AlticeUSA",    "Aluminium",    "AMADEUS",  "AMAZON",   "AMD",  "AMEX", "AMOVIL",   "Amsterdam25",  "Anglo",    "APACHE",   "APPLE",    "APPLE.",   "ARCELOR",  "Arconic",  "ASTRAZENECA",  "ATnT", "AUDBRL",   "AUDCAD",   "AUDCAD!",  "AUDCAD.",  "AUDCHF",   "AUDCHF!",  "AUDCHF.",  "AUDCNH",   "AUDCZK",   "AUDDKK",   "AUDHKD",   "AUDHRK",   "AUDHUF",   "AUDILS",   "AUDINR",   "AUDJPY",   "AUDJPY!",  "AUDJPY.",  "AUDMXN",   "AUDNOK",   "AUDNZD",   "AUDNZD!",  "AUDNZD.",  "AUDPLN",   "AUDPNC",   "AUDRON",   "AUDRUB",   "AUDSEK",   "AUDSGD",   "AUDTRY",   "AUDUSD",   "AUDUSD!",  "AUDUSD.",  "AUDZAR",   "Autodesk", "AVAGO",    "AVOLON",   "BAIDU",    "BancoBPM", "BASF", "BAYER",    "BBBeyond", "BBVA", "BerkshireB",   "BestBuy",  "Billiton", "BITCOIN",  "BITCOIN-D",    "BITCOIN-M",    "BITCOIN-W",    "BlackBerry",   "BMO",  "BMPS", "BMPSIENA", "BMW",  "BNPEU",    "BOA",  "BOEING",   "BP",   "BrentOil", "BRLJPY",   "BRLPLN",   "BTCUSD",   "Burberry", "BUZZI",    "CADBRL",   "CADCHF",   "CADCHF.",  "CADCNH",   "CADDKK",   "CADHKD",   "CADHRK",   "CADHUF",   "CADILS",   "CADINR",   "CADJPY",   "CADJPY.",  "CADMXN",   "CADNOK",   "CADPLN",   "CADRON",   "CADRUB",   "CADSEK",   "CADSGD",   "CADTRY",   "CADZAR",   "CAP",  "CARREFOUR",    "CATERPILLAR",  "CEMEX",    "CEZ",  "CHFJPY",   "CHFJPY.",  "CHFPLN",   "CHFPLN.",  "ChildrensPl",  "China300ETF",  "China50",  "ChinaMob", "CISCO",    "CitiGroup",    "CNHJPY",   "COCACOLA", "Cocoa",    "Cocoa!",   "Cocoa!",   "Coffee",   "Coffee!",  "Coffee!",  "Cognex",   "COMMERZBANK",  "Copper",   "CoreCivic",    "Corn", "Corn!",    "Corn!",    "Costco",   "Cotton",   "Cotton!",  "Ctrip.com",    "CZKPLN",   "DAIMLER",  "DanskeBank",   "DaveBuster",   "Deere",    "Denmark20",    "DeutschBank",  "DeutscheTel",  "DeutscheTel",  "Diamond",  "DIGICEL",  "DISNEY",   "DKKJPY",   "DKKPLN",   "DNB",  "doBank",   "Dollarindex",  "easyJet",  "EBAY", "EDF",  "EEE",  "ELECTRICA",    "Ellaktor", "ELPE", "EMPRESAS", "ENAGAS",   "ENEL", "ENI",  "EOAN", "Ericsson", "ERSTE",    "ETE",  "EURAUD",   "EURAUD!",  "EURAUD.",  "EURBRL",   "EURCAD",   "EURCAD!",  "EURCAD.",  "EURCHF",   "EURCHF!",  "EURCHF.",  "EURCNH",   "EURCZK",   "EURCZK.",  "EURDKK",   "EURDKK.",  "EURGBP",   "EURGBP!",  "EURGBP.",  "EURHKD",   "EURHRK",   "EURHUF",   "EURHUF.",  "EURILS",   "EURINR",   "EURJPY",   "EURJPY!",  "EURJPY.",  "EURMXN",   "EURNOK",   "EURNOK.",  "EURNZD",   "EURNZD.",  "EUROPCAR", "EUROPCAR", "Europe50", "EURPLN",   "EURPLN.",  "EURPNC",   "EURRON",   "EURRON.",  "EURRUB",   "EURSEK",   "EURSEK.",  "EURSGD",   "EURTRY",   "EURTRY.",  "EURUSD",   "EURUSD!",  "EURUSD.",  "EURZAR",   "Expedia",  "ExxonMobil",   "Facebook", "FAURECIA", "FCA",  "FERRARI",  "FIAT", "FirstData",    "FITBIT",   "FOMENTO",  "France40", "FSOLAR",   "GAMESA",   "GameStop", "Gap",  "GAZPROM",  "GBPAUD",   "GBPAUD!",  "GBPAUD.",  "GBPCAD",   "GBPCAD!",  "GBPCAD.",  "GBPCHF",   "GBPCHF!",  "GBPCHF.",  "GBPCNH",   "GBPCZK",   "GBPDKK",   "GBPHKD",   "GBPHRK",   "GBPHUF",   "GBPILS",   "GBPJPY",   "GBPJPY!",  "GBPJPY.",  "GBPMXN",   "GBPNOK",   "GBPNZD",   "GBPNZD.",  "GBPPLN",   "GBPRON",   "GBPRON.",  "GBPRUB",   "GBPSEK",   "GBPSGD",   "GBPSGD.",  "GBPTRY",   "GBPTRY.",  "GBPUSD",   "GBPUSD!",  "GBPUSD.",  "GBPZAR",   "GE",   "GEMALTO",  "GENERALI", "GER10YBond",   "germany30",    "GILEAD",   "Gilt10Y",  "GLENCORE", "GM",   "GoDaddy",  "GolarLNG", "GoldmnSachs",  "GOOGLE",   "GoPro",    "Greece20", "GRIFOLS",  "Grivalia", "Groupon",  "GRUMA",    "Handelsbank",  "Harley",   "HEINEKEN", "HEINEKEN", "Hermes",   "HewlettEnt",   "HILTON",   "HKDJPY",   "HKDPLN",   "HongKong45",   "HP",   "HRKJPY",   "HSBC", "HTO",  "HUBSPOT",  "HUFJPY",   "HUFPLN",   "IBERDROLA",    "IBM",  "Ikang",    "ILIAD",    "ILSBRL",   "ILSCNH",   "ILSCZK",   "ILSDKK",   "ILSHKD",   "ILSHUF",   "ILSINR",   "ILSJPY",   "ILSMXN",   "ILSNOK",   "ILSPLN",   "ILSPNC",   "ILSRON",   "ILSRUB",   "ILSSEK",   "ILSSGD",   "ILSTRY",   "ILSZAR",   "India50",  "INDITEX",  "INDRA",    "INFINEON", "INTEL",    "INTESA",   "Intuit",   "Italy40",  "JABIL",    "Japan225", "JAZZTEL",  "JCPenney", "JCPenney", "JD.com",   "JIMMYCHOO",    "JPMorgan", "JPN10yBond",   "JPYINR",   "Jumbo",    "K+S",  "K+S",  "KGHM", "KING", "KirbyCorp",    "KOMERCNI", "KRAFT",    "LEVTST",   "Line", "LineCorp", "LINKEDIN", "LionsGate",    "Lloyds",   "LockheedM",    "LUFTHANSA",    "LukoilUSD",    "Lululemon",    "LVMH", "Macys",    "MAGNIT",   "MANU", "MARRIOTT", "MARVELL",  "Mastercard",   "Match",    "McDonalds",    "MEGAFON",  "METRO",    "MGM",  "MICHELIN", "MICRON",   "MICROSOFT",    "MOL",  "MOMO", "MONDELEZ", "Moneta",   "MONSANTO", "MorganStan",   "Moscow50", "MotorOil", "MsciMexico",   "MSCITaiwan",   "MTELEKOM", "MTN",  "MXNJPY",   "MXNPLN",   "Mytilineos",   "Mytilineos",   "NaturalGas",   "NESTLE",   "NETFLIX",  "NewOriental",  "NIKE", "Nintendo", "NintendoJP",   "NOBLE",    "NOKIA",    "NOKJPY",   "NOKPLN",   "Norway25", "NovoNord", "Novozymes",    "NUANCE",   "NWR",  "NZDCAD",   "NZDCAD.",  "NZDCHF",   "NZDCHF.",  "NZDJPY",   "NZDJPY.",  "NZDUSD",   "NZDUSD!",  "NZDUSD.",  "Oil",  "OPAP", "ORACLE",   "OrangeFR", "OTP",  "Palladium",    "PartyCity",    "PayPal",   "PEKAO",    "PepsiCo",  "PetroChina",   "PetrolBras",   "PEUGEOT",  "PEUGEOT",  "PFIZER",   "PGE",  "PHILIPS",  "PIRELLI",  "PKNORLEN", "PKOBP",    "Platinum", "Play", "PLNCNH",   "PLNHRK",   "PLNINR",   "PLNJPY",   "PNCCAD",   "PNCJPY",   "PNCPLN",   "PNCUSD",   "Poland20", "POPOLARE", "POPULARESP",   "POSTEITALIA",  "POTASH",   "PPC",  "PRICELINE",    "PSBC", "PZU",  "Qualcomm", "QUNAR",    "RBS",  "REE",  "RegalBeloit",  "Renault",  "REPSOL",   "Rice", "RioTinto", "ROCKET",   "ROLLSROYCE",   "ROMGAZ",   "RONJPY",   "RONPLN",   "ROSNEFT",  "RUBJPY",   "RUBPLN",   "RWE",  "SABADELL", "SABMiller",    "SACYR",    "SafeBulkers",  "SAfrica40",    "SaintGobain",  "SALESFORCE",   "SAMSUNG",  "SANDISK",  "SANOFI",   "SANTANDER",    "SAP",  "Sasol",    "SBERBANK", "Scorpio",  "SEKJPY",   "SEKPLN",   "Severstal",    "SGDJPY",   "SGDPLN",   "ShakeShack",   "SHELL",    "SHOPIFY",  "SIEMENS",  "SINA", "Snap", "SOCIETE",  "SOLARCITY",    "SONY", "SouFun",   "soybeans", "Soybeans!",    "Soybeans!",    "Soybeans!",    "Spain35",  "Splunk",   "Square",   "STARBUCKS",    "Statoil",  "Sugar",    "Sweden30", "Swiss20",  "Sydney200",    "SYMANTEC", "Synaptics",    "Target",   "TDBank",   "TECK", "TECK.",    "TECK.",    "TELECOMITAL",  "TELEFONESP",   "TELEFONICA",   "Telenor",  "TeliaSonera",  "TerraForm",    "TESCO",    "TESLA",    "TEVA", "Tiffany",  "TitanCement",  "TOTAL",    "TOYOTA",   "TPSA", "TRIPADVISOR",  "TRYJPY",   "TRYPLN",   "Twilio",   "TWITTER",  "UBS",  "UK100",    "Unicredit",    "UNISTEEL", "US10YNote",    "US30YBond",    "USA2000",  "USA30",    "USA500",   "USDBRL",   "USDCAD",   "USDCAD!",  "USDCAD.",  "USDCHF",   "USDCHF!",  "USDCHF.",  "USDCNH",   "USDCZK",   "USDCZK.",  "USDDKK",   "USDDKK.",  "USDHKD",   "USDHRK",   "USDHUF",   "USDHUF.",  "USDILS",   "USDINR",   "USDJPY",   "USDJPY!",  "USDJPY.",  "USDMXN",   "USDNOK",   "USDNOK.",  "USDPLN",   "USDPLN!",  "USDPLN.",  "USDRON",   "USDRON.",  "USDRUB",   "USDSEK",   "USDSEK.",  "USDSGD",   "USDSGD.",  "USDTRY",   "USDTRY.",  "USDZAR",   "USFoods",  "USTECH100",    "VA",   "VALE", "VestasWind",   "VIG",  "VINCI",    "Vipshop",  "VISA", "VIVENDI",  "vixx", "VODAFONE", "VolksWagen",   "Volvo",    "WALMART",  "WEIBO",    "WellsFargo",   "Wheat",    "Wheat!",   "Wheat!",   "WIZZ", "WOWO", "WPP",  "XAGUSD",   "XAGUSD.",  "XAUUSD",   "XAUUSD.",  "Xylem",    "YAHOO",    "YamanaGold",   "YANDEX",   "Yara", "Yelp", "YYInc",    "ZARJPY",   "ZARPLN",   "Zinc", "ZTO",  "ZYNGA",
                                };

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init(){

    if (        Point == 0.00001 ) Poin = 0.0001;
    else { if ( Point == 0.001   ) Poin = 0.01;
           else                    Poin = Point;
    }
    return( 0 );
    }
//+------------------------------------------------------------------+
//| start function                                    |
//+------------------------------------------------------------------+
int start(){

    int count = ArraySize( Currencies );

    for ( int ii = 0; ii < count; ii++ ){

          dSymbol = Currencies[ii];   
          handle  = FileOpen( "Hist_" + dSymbol + "_" + Period() + ".csv", FILE_BIN | FILE_WRITE );

          if ( handle < 1 ){
               Print( "Err ", GetLastError() );
               return( 0 );
          }
          WriteHeader();

          for ( int i = 0; i < maxBars - 1; i++ ){
                WriteDataRow( i );
          }
          FileClose( handle );
     }
     Alert( "Done. "
          +  maxBars + " bars generated "
          +  TimeMonth( TimeLocal() )
          +  TimeDay(   TimeLocal() )
          +  TimeYear(  TimeLocal() )
          + "_"
          +  TimeHour(  TimeLocal() )
          +  TimeMinute(TimeLocal() )
             );

     return( 0 );
     }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void WriteData( string txt ){

     FileWriteString( handle, txt, StringLen( txt ) );

     return;
     }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void WriteHeader(){

     WriteData( "Symbol," );
     WriteData( "Date," );
     WriteData( "DayOfWeek," );
     WriteData( "DayOfYear," );
     WriteData( "Open," );
     WriteData( "High," );
     WriteData( "Low," );
     WriteData( "Close," );
     WriteData( "RSI5,RSI11,MOM3_c,CCI11_c," );
     WriteData( "\n" );

     return;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void WriteDataRow( int i ){

     double  dSymTime, dSymOpen, dSymHigh, dSymLow, dSymClose, dSymVolume;
     int     dDayofWk, dDayofYr, iDigits;

     dSymTime = ( iTime( dSymbol, Period(), i ) );
     dDayofWk = (  TimeDayOfWeek( dSymTime ) );
     dDayofYr =    TimeDayOfYear( dSymTime );

     dSymOpen = ( iOpen( dSymbol, Period(), i ) );

  // if (  TimeToStr( dSymTime, TIME_DATE ) != "1970." ){
     if (  dSymOpen >  0 ){

           WriteData( dSymbol + "," );
           WriteData( TimeToStr( dSymTime, TIME_DATE | TIME_MINUTES ) + "," );

           iDigits    = MarketInfo(  Symbol(),MODE_DIGITS );
           dSymOpen   = ( iOpen(    dSymbol,  Period(), i ) );
           dSymHigh   = ( iHigh(    dSymbol,  Period(), i ) );
           dSymLow    = ( iLow(     dSymbol,  Period(), i ) );
           dSymClose  = ( iClose(   dSymbol,  Period(), i ) );
           dSymVolume = ( iVolume(  dSymbol,  Period(), i ) );

       //  int    BarsInBox = 8;

       //  double PeriodHighest = High[iHighest( dSymbol, Period(), MODE_HIGH, BarsInBox + 1, i )];
       //  double PeriodLowest  = Low[ iLowest(  dSymbol, Period(), MODE_LOW,  BarsInBox + 1, i )];
       //  double PeriodRNG     = ( PeriodHighest - PeriodLowest ) / Poin;

           double RSI5_c   =  iRSI(      NULL, 0,  5, PRICE_CLOSE, i   );
           double RSI5_p3  =  iRSI(      NULL, 0,  5, PRICE_CLOSE, i+3 );
           double MOM3_c   =  iMomentum( NULL, 0, 21, PRICE_CLOSE, i   );
           double MOM3_p3  =  iMomentum( NULL, 0, 21, PRICE_CLOSE, i+3 );
           double CCI11_c  =  iCCI(      NULL, 0,  5, PRICE_CLOSE, i   );
           double CCI11_p3 =  iCCI(      NULL, 0,  5, PRICE_CLOSE, i+3 );

           WriteData( dDayofWk + "," + dDayofYr + "," );

           WriteData( DoubleToStr( dSymOpen,  iDigits ) + "," );
           WriteData( DoubleToStr( dSymHigh,  iDigits ) + "," );
           WriteData( DoubleToStr( dSymLow,   iDigits ) + "," );

       //  WriteData( DoubleToStr( dSymClose, iDigits ) + "," + PeriodHighest + "," + PeriodLowest + "," + PeriodRNG );
           WriteData( DoubleToStr( dSymClose, iDigits ) + ","
                    + DoubleToStr( RSI5_c,    2 )       + ","
                    + DoubleToStr( RSI5_p3,   2 )       + ","
                    + DoubleToStr( MOM3_c,    2 )       + ","
                    + DoubleToStr( MOM3_p3,   2 )       + ","
                    + DoubleToStr( CCI11_c,   2 )       + ","
                    + DoubleToStr( CCI11_p3,  2 )       + ","
                      );
           WriteData( "\n" );
     }
     return;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
string GetPeriodName() {

   switch( Period() ){

       case PERIOD_D1:  return( "Day" );
       case PERIOD_H4:  return( "4_Hour" );
       case PERIOD_H1:  return( "Hour" );
       case PERIOD_M1:  return( "Minute" );
       case PERIOD_M15: return( "15_Minute" );
       case PERIOD_M30: return( "30_Minute" );
       case PERIOD_M5:  return( "5_Minute" );
       case PERIOD_MN1: return( "Month" );
       case PERIOD_W1:  return( "Week" );
       }
   }
-----------------------
       WriteData( DoubleToStr( dSymClose, iDigits ) + ","
                + DoubleToStr( RSI5_c,    2 )       + ","
                + DoubleToStr( RSI5_p3,   2 )       + ","
                + DoubleToStr( MOM3_c,    2 )       + ","
                + DoubleToStr( MOM3_p3,   2 )       + ","
                + DoubleToStr( CCI11_c,   2 )       + ","
                + DoubleToStr( CCI11_p3,  2 )       + ","
                  );
       iDigits    = MarketInfo(  Symbol(),MODE_DIGITS );
       dSymOpen   = ( iOpen(    dSymbol,  Period(), i ) );
       dSymHigh   = ( iHigh(    dSymbol,  Period(), i ) );
       dSymLow    = ( iLow(     dSymbol,  Period(), i ) );
       dSymClose  = ( iClose(   dSymbol,  Period(), i ) );
       dSymVolume = ( iVolume(  dSymbol,  Period(), i ) );
       double RSI5_c   =  iRSI(      NULL, 0,  5, PRICE_CLOSE, i   );
       double RSI5_p3  =  iRSI(      NULL, 0,  5, PRICE_CLOSE, i+3 );
       double MOM3_c   =  iMomentum( NULL, 0, 21, PRICE_CLOSE, i   );
       double MOM3_p3  =  iMomentum( NULL, 0, 21, PRICE_CLOSE, i+3 );
       double CCI11_c  =  iCCI(      NULL, 0,  5, PRICE_CLOSE, i   );
       double CCI11_p3 =  iCCI(      NULL, 0,  5, PRICE_CLOSE, i+3 );
// #property copyright "Copyright © 2012, fxprotrader" #property link      "http://www.fxpro-trader.com"
// #property show_inputs

    // a number of bars to export per Symbol
   //  int    maxBars = 6418;
extern int    maxBars =  200;
       int    handle;
       string dSymbol;
       double Poin;

 // test first on several pairs
//     string Currencies[] = { "EURUSD", "AUDUSD", "GBPUSD", "EURJPY", "GBPJPY", "USDCAD" };
       string Currencies[] = { "#Corn",
                               "#France40",
                               "#Germany30",
                               "#NaturalGas",
                               "#Oil",
                               "#UK100",
                               "#USA30",
                               "#USA500",
                               "#USTECH100",
                               "#Wheat",
                               "#XAGUSD",
                               "#XAUUSD",
                               "58.com",
                               "ABENGOA",
                               "ABNAmro",  "ADIDAS",   "ADIDAS",   "AGRICOLE", "AIB",  "AIRBUS",   "Albemarle",    "ALCATEL",  "ALCOA",    "ALIBABA",  "ALLIANZ",  "ALPHA",    "AlticeUSA",    "Aluminium",    "AMADEUS",  "AMAZON",   "AMD",  "AMEX", "AMOVIL",   "Amsterdam25",  "Anglo",    "APACHE",   "APPLE",    "APPLE.",   "ARCELOR",  "Arconic",  "ASTRAZENECA",  "ATnT", "AUDBRL",   "AUDCAD",   "AUDCAD!",  "AUDCAD.",  "AUDCHF",   "AUDCHF!",  "AUDCHF.",  "AUDCNH",   "AUDCZK",   "AUDDKK",   "AUDHKD",   "AUDHRK",   "AUDHUF",   "AUDILS",   "AUDINR",   "AUDJPY",   "AUDJPY!",  "AUDJPY.",  "AUDMXN",   "AUDNOK",   "AUDNZD",   "AUDNZD!",  "AUDNZD.",  "AUDPLN",   "AUDPNC",   "AUDRON",   "AUDRUB",   "AUDSEK",   "AUDSGD",   "AUDTRY",   "AUDUSD",   "AUDUSD!",  "AUDUSD.",  "AUDZAR",   "Autodesk", "AVAGO",    "AVOLON",   "BAIDU",    "BancoBPM", "BASF", "BAYER",    "BBBeyond", "BBVA", "BerkshireB",   "BestBuy",  "Billiton", "BITCOIN",  "BITCOIN-D",    "BITCOIN-M",    "BITCOIN-W",    "BlackBerry",   "BMO",  "BMPS", "BMPSIENA", "BMW",  "BNPEU",    "BOA",  "BOEING",   "BP",   "BrentOil", "BRLJPY",   "BRLPLN",   "BTCUSD",   "Burberry", "BUZZI",    "CADBRL",   "CADCHF",   "CADCHF.",  "CADCNH",   "CADDKK",   "CADHKD",   "CADHRK",   "CADHUF",   "CADILS",   "CADINR",   "CADJPY",   "CADJPY.",  "CADMXN",   "CADNOK",   "CADPLN",   "CADRON",   "CADRUB",   "CADSEK",   "CADSGD",   "CADTRY",   "CADZAR",   "CAP",  "CARREFOUR",    "CATERPILLAR",  "CEMEX",    "CEZ",  "CHFJPY",   "CHFJPY.",  "CHFPLN",   "CHFPLN.",  "ChildrensPl",  "China300ETF",  "China50",  "ChinaMob", "CISCO",    "CitiGroup",    "CNHJPY",   "COCACOLA", "Cocoa",    "Cocoa!",   "Cocoa!",   "Coffee",   "Coffee!",  "Coffee!",  "Cognex",   "COMMERZBANK",  "Copper",   "CoreCivic",    "Corn", "Corn!",    "Corn!",    "Costco",   "Cotton",   "Cotton!",  "Ctrip.com",    "CZKPLN",   "DAIMLER",  "DanskeBank",   "DaveBuster",   "Deere",    "Denmark20",    "DeutschBank",  "DeutscheTel",  "DeutscheTel",  "Diamond",  "DIGICEL",  "DISNEY",   "DKKJPY",   "DKKPLN",   "DNB",  "doBank",   "Dollarindex",  "easyJet",  "EBAY", "EDF",  "EEE",  "ELECTRICA",    "Ellaktor", "ELPE", "EMPRESAS", "ENAGAS",   "ENEL", "ENI",  "EOAN", "Ericsson", "ERSTE",    "ETE",  "EURAUD",   "EURAUD!",  "EURAUD.",  "EURBRL",   "EURCAD",   "EURCAD!",  "EURCAD.",  "EURCHF",   "EURCHF!",  "EURCHF.",  "EURCNH",   "EURCZK",   "EURCZK.",  "EURDKK",   "EURDKK.",  "EURGBP",   "EURGBP!",  "EURGBP.",  "EURHKD",   "EURHRK",   "EURHUF",   "EURHUF.",  "EURILS",   "EURINR",   "EURJPY",   "EURJPY!",  "EURJPY.",  "EURMXN",   "EURNOK",   "EURNOK.",  "EURNZD",   "EURNZD.",  "EUROPCAR", "EUROPCAR", "Europe50", "EURPLN",   "EURPLN.",  "EURPNC",   "EURRON",   "EURRON.",  "EURRUB",   "EURSEK",   "EURSEK.",  "EURSGD",   "EURTRY",   "EURTRY.",  "EURUSD",   "EURUSD!",  "EURUSD.",  "EURZAR",   "Expedia",  "ExxonMobil",   "Facebook", "FAURECIA", "FCA",  "FERRARI",  "FIAT", "FirstData",    "FITBIT",   "FOMENTO",  "France40", "FSOLAR",   "GAMESA",   "GameStop", "Gap",  "GAZPROM",  "GBPAUD",   "GBPAUD!",  "GBPAUD.",  "GBPCAD",   "GBPCAD!",  "GBPCAD.",  "GBPCHF",   "GBPCHF!",  "GBPCHF.",  "GBPCNH",   "GBPCZK",   "GBPDKK",   "GBPHKD",   "GBPHRK",   "GBPHUF",   "GBPILS",   "GBPJPY",   "GBPJPY!",  "GBPJPY.",  "GBPMXN",   "GBPNOK",   "GBPNZD",   "GBPNZD.",  "GBPPLN",   "GBPRON",   "GBPRON.",  "GBPRUB",   "GBPSEK",   "GBPSGD",   "GBPSGD.",  "GBPTRY",   "GBPTRY.",  "GBPUSD",   "GBPUSD!",  "GBPUSD.",  "GBPZAR",   "GE",   "GEMALTO",  "GENERALI", "GER10YBond",   "germany30",    "GILEAD",   "Gilt10Y",  "GLENCORE", "GM",   "GoDaddy",  "GolarLNG", "GoldmnSachs",  "GOOGLE",   "GoPro",    "Greece20", "GRIFOLS",  "Grivalia", "Groupon",  "GRUMA",    "Handelsbank",  "Harley",   "HEINEKEN", "HEINEKEN", "Hermes",   "HewlettEnt",   "HILTON",   "HKDJPY",   "HKDPLN",   "HongKong45",   "HP",   "HRKJPY",   "HSBC", "HTO",  "HUBSPOT",  "HUFJPY",   "HUFPLN",   "IBERDROLA",    "IBM",  "Ikang",    "ILIAD",    "ILSBRL",   "ILSCNH",   "ILSCZK",   "ILSDKK",   "ILSHKD",   "ILSHUF",   "ILSINR",   "ILSJPY",   "ILSMXN",   "ILSNOK",   "ILSPLN",   "ILSPNC",   "ILSRON",   "ILSRUB",   "ILSSEK",   "ILSSGD",   "ILSTRY",   "ILSZAR",   "India50",  "INDITEX",  "INDRA",    "INFINEON", "INTEL",    "INTESA",   "Intuit",   "Italy40",  "JABIL",    "Japan225", "JAZZTEL",  "JCPenney", "JCPenney", "JD.com",   "JIMMYCHOO",    "JPMorgan", "JPN10yBond",   "JPYINR",   "Jumbo",    "K+S",  "K+S",  "KGHM", "KING", "KirbyCorp",    "KOMERCNI", "KRAFT",    "LEVTST",   "Line", "LineCorp", "LINKEDIN", "LionsGate",    "Lloyds",   "LockheedM",    "LUFTHANSA",    "LukoilUSD",    "Lululemon",    "LVMH", "Macys",    "MAGNIT",   "MANU", "MARRIOTT", "MARVELL",  "Mastercard",   "Match",    "McDonalds",    "MEGAFON",  "METRO",    "MGM",  "MICHELIN", "MICRON",   "MICROSOFT",    "MOL",  "MOMO", "MONDELEZ", "Moneta",   "MONSANTO", "MorganStan",   "Moscow50", "MotorOil", "MsciMexico",   "MSCITaiwan",   "MTELEKOM", "MTN",  "MXNJPY",   "MXNPLN",   "Mytilineos",   "Mytilineos",   "NaturalGas",   "NESTLE",   "NETFLIX",  "NewOriental",  "NIKE", "Nintendo", "NintendoJP",   "NOBLE",    "NOKIA",    "NOKJPY",   "NOKPLN",   "Norway25", "NovoNord", "Novozymes",    "NUANCE",   "NWR",  "NZDCAD",   "NZDCAD.",  "NZDCHF",   "NZDCHF.",  "NZDJPY",   "NZDJPY.",  "NZDUSD",   "NZDUSD!",  "NZDUSD.",  "Oil",  "OPAP", "ORACLE",   "OrangeFR", "OTP",  "Palladium",    "PartyCity",    "PayPal",   "PEKAO",    "PepsiCo",  "PetroChina",   "PetrolBras",   "PEUGEOT",  "PEUGEOT",  "PFIZER",   "PGE",  "PHILIPS",  "PIRELLI",  "PKNORLEN", "PKOBP",    "Platinum", "Play", "PLNCNH",   "PLNHRK",   "PLNINR",   "PLNJPY",   "PNCCAD",   "PNCJPY",   "PNCPLN",   "PNCUSD",   "Poland20", "POPOLARE", "POPULARESP",   "POSTEITALIA",  "POTASH",   "PPC",  "PRICELINE",    "PSBC", "PZU",  "Qualcomm", "QUNAR",    "RBS",  "REE",  "RegalBeloit",  "Renault",  "REPSOL",   "Rice", "RioTinto", "ROCKET",   "ROLLSROYCE",   "ROMGAZ",   "RONJPY",   "RONPLN",   "ROSNEFT",  "RUBJPY",   "RUBPLN",   "RWE",  "SABADELL", "SABMiller",    "SACYR",    "SafeBulkers",  "SAfrica40",    "SaintGobain",  "SALESFORCE",   "SAMSUNG",  "SANDISK",  "SANOFI",   "SANTANDER",    "SAP",  "Sasol",    "SBERBANK", "Scorpio",  "SEKJPY",   "SEKPLN",   "Severstal",    "SGDJPY",   "SGDPLN",   "ShakeShack",   "SHELL",    "SHOPIFY",  "SIEMENS",  "SINA", "Snap", "SOCIETE",  "SOLARCITY",    "SONY", "SouFun",   "soybeans", "Soybeans!",    "Soybeans!",    "Soybeans!",    "Spain35",  "Splunk",   "Square",   "STARBUCKS",    "Statoil",  "Sugar",    "Sweden30", "Swiss20",  "Sydney200",    "SYMANTEC", "Synaptics",    "Target",   "TDBank",   "TECK", "TECK.",    "TECK.",    "TELECOMITAL",  "TELEFONESP",   "TELEFONICA",   "Telenor",  "TeliaSonera",  "TerraForm",    "TESCO",    "TESLA",    "TEVA", "Tiffany",  "TitanCement",  "TOTAL",    "TOYOTA",   "TPSA", "TRIPADVISOR",  "TRYJPY",   "TRYPLN",   "Twilio",   "TWITTER",  "UBS",  "UK100",    "Unicredit",    "UNISTEEL", "US10YNote",    "US30YBond",    "USA2000",  "USA30",    "USA500",   "USDBRL",   "USDCAD",   "USDCAD!",  "USDCAD.",  "USDCHF",   "USDCHF!",  "USDCHF.",  "USDCNH",   "USDCZK",   "USDCZK.",  "USDDKK",   "USDDKK.",  "USDHKD",   "USDHRK",   "USDHUF",   "USDHUF.",  "USDILS",   "USDINR",   "USDJPY",   "USDJPY!",  "USDJPY.",  "USDMXN",   "USDNOK",   "USDNOK.",  "USDPLN",   "USDPLN!",  "USDPLN.",  "USDRON",   "USDRON.",  "USDRUB",   "USDSEK",   "USDSEK.",  "USDSGD",   "USDSGD.",  "USDTRY",   "USDTRY.",  "USDZAR",   "USFoods",  "USTECH100",    "VA",   "VALE", "VestasWind",   "VIG",  "VINCI",    "Vipshop",  "VISA", "VIVENDI",  "vixx", "VODAFONE", "VolksWagen",   "Volvo",    "WALMART",  "WEIBO",    "WellsFargo",   "Wheat",    "Wheat!",   "Wheat!",   "WIZZ", "WOWO", "WPP",  "XAGUSD",   "XAGUSD.",  "XAUUSD",   "XAUUSD.",  "Xylem",    "YAHOO",    "YamanaGold",   "YANDEX",   "Yara", "Yelp", "YYInc",    "ZARJPY",   "ZARPLN",   "Zinc", "ZTO",  "ZYNGA",
                                };

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init(){

    if (        Point == 0.00001 ) Poin = 0.0001;
    else { if ( Point == 0.001   ) Poin = 0.01;
           else                    Poin = Point;
    }
    return( 0 );
    }
//+------------------------------------------------------------------+
//| start function                                    |
//+------------------------------------------------------------------+
int start(){

    int count = ArraySize( Currencies );

    for ( int ii = 0; ii < count; ii++ ){

          dSymbol = Currencies[ii];   
          handle  = FileOpen( "Hist_" + dSymbol + "_" + Period() + ".csv", FILE_BIN | FILE_WRITE );

          if ( handle < 1 ){
               Print( "Err ", GetLastError() );
               return( 0 );
          }
          WriteHeader();

          for ( int i = 0; i < maxBars - 1; i++ ){
                WriteDataRow( i );
          }
          FileClose( handle );
     }
     Alert( "Done. "
          +  maxBars + " bars generated "
          +  TimeMonth( TimeLocal() )
          +  TimeDay(   TimeLocal() )
          +  TimeYear(  TimeLocal() )
          + "_"
          +  TimeHour(  TimeLocal() )
          +  TimeMinute(TimeLocal() )
             );

     return( 0 );
     }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void WriteData( string txt ){

     FileWriteString( handle, txt, StringLen( txt ) );

     return;
     }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void WriteHeader(){

     WriteData( "Symbol," );
     WriteData( "Date," );
     WriteData( "DayOfWeek," );
     WriteData( "DayOfYear," );
     WriteData( "Open," );
     WriteData( "High," );
     WriteData( "Low," );
     WriteData( "Close," );
     WriteData( "RSI5,RSI11,MOM3_c,CCI11_c," );
     WriteData( "\n" );

     return;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void WriteDataRow( int i ){

     double  dSymTime, dSymOpen, dSymHigh, dSymLow, dSymClose, dSymVolume;
     int     dDayofWk, dDayofYr, iDigits;

     dSymTime = ( iTime( dSymbol, Period(), i ) );
     dDayofWk = (  TimeDayOfWeek( dSymTime ) );
     dDayofYr =    TimeDayOfYear( dSymTime );

     dSymOpen = ( iOpen( dSymbol, Period(), i ) );

  // if (  TimeToStr( dSymTime, TIME_DATE ) != "1970." ){
     if (  dSymOpen >  0 ){

           WriteData( dSymbol + "," );
           WriteData( TimeToStr( dSymTime, TIME_DATE | TIME_MINUTES ) + "," );

           iDigits    = MarketInfo(  Symbol(),MODE_DIGITS );
           dSymOpen   = ( iOpen(    dSymbol,  Period(), i ) );
           dSymHigh   = ( iHigh(    dSymbol,  Period(), i ) );
           dSymLow    = ( iLow(     dSymbol,  Period(), i ) );
           dSymClose  = ( iClose(   dSymbol,  Period(), i ) );
           dSymVolume = ( iVolume(  dSymbol,  Period(), i ) );

       //  int    BarsInBox = 8;

       //  double PeriodHighest = High[iHighest( dSymbol, Period(), MODE_HIGH, BarsInBox + 1, i )];
       //  double PeriodLowest  = Low[ iLowest(  dSymbol, Period(), MODE_LOW,  BarsInBox + 1, i )];
       //  double PeriodRNG     = ( PeriodHighest - PeriodLowest ) / Poin;

           double RSI5_c   =  iRSI(      NULL, 0,  5, PRICE_CLOSE, i   );
           double RSI5_p3  =  iRSI(      NULL, 0,  5, PRICE_CLOSE, i+3 );
           double MOM3_c   =  iMomentum( NULL, 0, 21, PRICE_CLOSE, i   );
           double MOM3_p3  =  iMomentum( NULL, 0, 21, PRICE_CLOSE, i+3 );
           double CCI11_c  =  iCCI(      NULL, 0,  5, PRICE_CLOSE, i   );
           double CCI11_p3 =  iCCI(      NULL, 0,  5, PRICE_CLOSE, i+3 );

           WriteData( dDayofWk + "," + dDayofYr + "," );

           WriteData( DoubleToStr( dSymOpen,  iDigits ) + "," );
           WriteData( DoubleToStr( dSymHigh,  iDigits ) + "," );
           WriteData( DoubleToStr( dSymLow,   iDigits ) + "," );

       //  WriteData( DoubleToStr( dSymClose, iDigits ) + "," + PeriodHighest + "," + PeriodLowest + "," + PeriodRNG );
           WriteData( DoubleToStr( dSymClose, iDigits ) + ","
                    + DoubleToStr( RSI5_c,    2 )       + ","
                    + DoubleToStr( RSI5_p3,   2 )       + ","
                    + DoubleToStr( MOM3_c,    2 )       + ","
                    + DoubleToStr( MOM3_p3,   2 )       + ","
                    + DoubleToStr( CCI11_c,   2 )       + ","
                    + DoubleToStr( CCI11_p3,  2 )       + ","
                      );
           WriteData( "\n" );
     }
     return;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
string GetPeriodName() {

   switch( Period() ){

       case PERIOD_D1:  return( "Day" );
       case PERIOD_H4:  return( "4_Hour" );
       case PERIOD_H1:  return( "Hour" );
       case PERIOD_M1:  return( "Minute" );
       case PERIOD_M15: return( "15_Minute" );
       case PERIOD_M30: return( "30_Minute" );
       case PERIOD_M5:  return( "5_Minute" );
       case PERIOD_MN1: return( "Month" );
       case PERIOD_W1:  return( "Week" );
       }
   }
-----------------------
       WriteData( DoubleToStr( dSymClose, iDigits ) + ","
                + DoubleToStr( RSI5_c,    2 )       + ","
                + DoubleToStr( RSI5_p3,   2 )       + ","
                + DoubleToStr( MOM3_c,    2 )       + ","
                + DoubleToStr( MOM3_p3,   2 )       + ","
                + DoubleToStr( CCI11_c,   2 )       + ","
                + DoubleToStr( CCI11_p3,  2 )       + ","
                  );
       iDigits    = MarketInfo(  Symbol(),MODE_DIGITS );
       dSymOpen   = ( iOpen(    dSymbol,  Period(), i ) );
       dSymHigh   = ( iHigh(    dSymbol,  Period(), i ) );
       dSymLow    = ( iLow(     dSymbol,  Period(), i ) );
       dSymClose  = ( iClose(   dSymbol,  Period(), i ) );
       dSymVolume = ( iVolume(  dSymbol,  Period(), i ) );
       double RSI5_c   =  iRSI(      NULL, 0,  5, PRICE_CLOSE, i   );
       double RSI5_p3  =  iRSI(      NULL, 0,  5, PRICE_CLOSE, i+3 );
       double MOM3_c   =  iMomentum( NULL, 0, 21, PRICE_CLOSE, i   );
       double MOM3_p3  =  iMomentum( NULL, 0, 21, PRICE_CLOSE, i+3 );
       double CCI11_c  =  iCCI(      NULL, 0,  5, PRICE_CLOSE, i   );
       double CCI11_p3 =  iCCI(      NULL, 0,  5, PRICE_CLOSE, i+3 );
// #property copyright "Copyright © 2012, fxprotrader" #property link      "http://www.fxpro-trader.com"
// #property show_inputs

    // a number of bars to export per Symbol
   //  int    maxBars = 6418;
extern int    maxBars =  200;
       int    handle;
       string dSymbol;
       double Poin;

 // test first on several pairs
//     string Currencies[] = { "EURUSD", "AUDUSD", "GBPUSD", "EURJPY", "GBPJPY", "USDCAD" };
       string Currencies[] = { "#Corn",
                               "#France40",
                               "#Germany30",
                               "#NaturalGas",
                               "#Oil",
                               "#UK100",
                               "#USA30",
                               "#USA500",
                               "#USTECH100",
                               "#Wheat",
                               "#XAGUSD",
                               "#XAUUSD",
                               "58.com",
                               "ABENGOA",
                               "ABNAmro",  "ADIDAS",   "ADIDAS",   "AGRICOLE", "AIB",  "AIRBUS",   "Albemarle",    "ALCATEL",  "ALCOA",    "ALIBABA",  "ALLIANZ",  "ALPHA",    "AlticeUSA",    "Aluminium",    "AMADEUS",  "AMAZON",   "AMD",  "AMEX", "AMOVIL",   "Amsterdam25",  "Anglo",    "APACHE",   "APPLE",    "APPLE.",   "ARCELOR",  "Arconic",  "ASTRAZENECA",  "ATnT", "AUDBRL",   "AUDCAD",   "AUDCAD!",  "AUDCAD.",  "AUDCHF",   "AUDCHF!",  "AUDCHF.",  "AUDCNH",   "AUDCZK",   "AUDDKK",   "AUDHKD",   "AUDHRK",   "AUDHUF",   "AUDILS",   "AUDINR",   "AUDJPY",   "AUDJPY!",  "AUDJPY.",  "AUDMXN",   "AUDNOK",   "AUDNZD",   "AUDNZD!",  "AUDNZD.",  "AUDPLN",   "AUDPNC",   "AUDRON",   "AUDRUB",   "AUDSEK",   "AUDSGD",   "AUDTRY",   "AUDUSD",   "AUDUSD!",  "AUDUSD.",  "AUDZAR",   "Autodesk", "AVAGO",    "AVOLON",   "BAIDU",    "BancoBPM", "BASF", "BAYER",    "BBBeyond", "BBVA", "BerkshireB",   "BestBuy",  "Billiton", "BITCOIN",  "BITCOIN-D",    "BITCOIN-M",    "BITCOIN-W",    "BlackBerry",   "BMO",  "BMPS", "BMPSIENA", "BMW",  "BNPEU",    "BOA",  "BOEING",   "BP",   "BrentOil", "BRLJPY",   "BRLPLN",   "BTCUSD",   "Burberry", "BUZZI",    "CADBRL",   "CADCHF",   "CADCHF.",  "CADCNH",   "CADDKK",   "CADHKD",   "CADHRK",   "CADHUF",   "CADILS",   "CADINR",   "CADJPY",   "CADJPY.",  "CADMXN",   "CADNOK",   "CADPLN",   "CADRON",   "CADRUB",   "CADSEK",   "CADSGD",   "CADTRY",   "CADZAR",   "CAP",  "CARREFOUR",    "CATERPILLAR",  "CEMEX",    "CEZ",  "CHFJPY",   "CHFJPY.",  "CHFPLN",   "CHFPLN.",  "ChildrensPl",  "China300ETF",  "China50",  "ChinaMob", "CISCO",    "CitiGroup",    "CNHJPY",   "COCACOLA", "Cocoa",    "Cocoa!",   "Cocoa!",   "Coffee",   "Coffee!",  "Coffee!",  "Cognex",   "COMMERZBANK",  "Copper",   "CoreCivic",    "Corn", "Corn!",    "Corn!",    "Costco",   "Cotton",   "Cotton!",  "Ctrip.com",    "CZKPLN",   "DAIMLER",  "DanskeBank",   "DaveBuster",   "Deere",    "Denmark20",    "DeutschBank",  "DeutscheTel",  "DeutscheTel",  "Diamond",  "DIGICEL",  "DISNEY",   "DKKJPY",   "DKKPLN",   "DNB",  "doBank",   "Dollarindex",  "easyJet",  "EBAY", "EDF",  "EEE",  "ELECTRICA",    "Ellaktor", "ELPE", "EMPRESAS", "ENAGAS",   "ENEL", "ENI",  "EOAN", "Ericsson", "ERSTE",    "ETE",  "EURAUD",   "EURAUD!",  "EURAUD.",  "EURBRL",   "EURCAD",   "EURCAD!",  "EURCAD.",  "EURCHF",   "EURCHF!",  "EURCHF.",  "EURCNH",   "EURCZK",   "EURCZK.",  "EURDKK",   "EURDKK.",  "EURGBP",   "EURGBP!",  "EURGBP.",  "EURHKD",   "EURHRK",   "EURHUF",   "EURHUF.",  "EURILS",   "EURINR",   "EURJPY",   "EURJPY!",  "EURJPY.",  "EURMXN",   "EURNOK",   "EURNOK.",  "EURNZD",   "EURNZD.",  "EUROPCAR", "EUROPCAR", "Europe50", "EURPLN",   "EURPLN.",  "EURPNC",   "EURRON",   "EURRON.",  "EURRUB",   "EURSEK",   "EURSEK.",  "EURSGD",   "EURTRY",   "EURTRY.",  "EURUSD",   "EURUSD!",  "EURUSD.",  "EURZAR",   "Expedia",  "ExxonMobil",   "Facebook", "FAURECIA", "FCA",  "FERRARI",  "FIAT", "FirstData",    "FITBIT",   "FOMENTO",  "France40", "FSOLAR",   "GAMESA",   "GameStop", "Gap",  "GAZPROM",  "GBPAUD",   "GBPAUD!",  "GBPAUD.",  "GBPCAD",   "GBPCAD!",  "GBPCAD.",  "GBPCHF",   "GBPCHF!",  "GBPCHF.",  "GBPCNH",   "GBPCZK",   "GBPDKK",   "GBPHKD",   "GBPHRK",   "GBPHUF",   "GBPILS",   "GBPJPY",   "GBPJPY!",  "GBPJPY.",  "GBPMXN",   "GBPNOK",   "GBPNZD",   "GBPNZD.",  "GBPPLN",   "GBPRON",   "GBPRON.",  "GBPRUB",   "GBPSEK",   "GBPSGD",   "GBPSGD.",  "GBPTRY",   "GBPTRY.",  "GBPUSD",   "GBPUSD!",  "GBPUSD.",  "GBPZAR",   "GE",   "GEMALTO",  "GENERALI", "GER10YBond",   "germany30",    "GILEAD",   "Gilt10Y",  "GLENCORE", "GM",   "GoDaddy",  "GolarLNG", "GoldmnSachs",  "GOOGLE",   "GoPro",    "Greece20", "GRIFOLS",  "Grivalia", "Groupon",  "GRUMA",    "Handelsbank",  "Harley",   "HEINEKEN", "HEINEKEN", "Hermes",   "HewlettEnt",   "HILTON",   "HKDJPY",   "HKDPLN",   "HongKong45",   "HP",   "HRKJPY",   "HSBC", "HTO",  "HUBSPOT",  "HUFJPY",   "HUFPLN",   "IBERDROLA",    "IBM",  "Ikang",    "ILIAD",    "ILSBRL",   "ILSCNH",   "ILSCZK",   "ILSDKK",   "ILSHKD",   "ILSHUF",   "ILSINR",   "ILSJPY",   "ILSMXN",   "ILSNOK",   "ILSPLN",   "ILSPNC",   "ILSRON",   "ILSRUB",   "ILSSEK",   "ILSSGD",   "ILSTRY",   "ILSZAR",   "India50",  "INDITEX",  "INDRA",    "INFINEON", "INTEL",    "INTESA",   "Intuit",   "Italy40",  "JABIL",    "Japan225", "JAZZTEL",  "JCPenney", "JCPenney", "JD.com",   "JIMMYCHOO",    "JPMorgan", "JPN10yBond",   "JPYINR",   "Jumbo",    "K+S",  "K+S",  "KGHM", "KING", "KirbyCorp",    "KOMERCNI", "KRAFT",    "LEVTST",   "Line", "LineCorp", "LINKEDIN", "LionsGate",    "Lloyds",   "LockheedM",    "LUFTHANSA",    "LukoilUSD",    "Lululemon",    "LVMH", "Macys",    "MAGNIT",   "MANU", "MARRIOTT", "MARVELL",  "Mastercard",   "Match",    "McDonalds",    "MEGAFON",  "METRO",    "MGM",  "MICHELIN", "MICRON",   "MICROSOFT",    "MOL",  "MOMO", "MONDELEZ", "Moneta",   "MONSANTO", "MorganStan",   "Moscow50", "MotorOil", "MsciMexico",   "MSCITaiwan",   "MTELEKOM", "MTN",  "MXNJPY",   "MXNPLN",   "Mytilineos",   "Mytilineos",   "NaturalGas",   "NESTLE",   "NETFLIX",  "NewOriental",  "NIKE", "Nintendo", "NintendoJP",   "NOBLE",    "NOKIA",    "NOKJPY",   "NOKPLN",   "Norway25", "NovoNord", "Novozymes",    "NUANCE",   "NWR",  "NZDCAD",   "NZDCAD.",  "NZDCHF",   "NZDCHF.",  "NZDJPY",   "NZDJPY.",  "NZDUSD",   "NZDUSD!",  "NZDUSD.",  "Oil",  "OPAP", "ORACLE",   "OrangeFR", "OTP",  "Palladium",    "PartyCity",    "PayPal",   "PEKAO",    "PepsiCo",  "PetroChina",   "PetrolBras",   "PEUGEOT",  "PEUGEOT",  "PFIZER",   "PGE",  "PHILIPS",  "PIRELLI",  "PKNORLEN", "PKOBP",    "Platinum", "Play", "PLNCNH",   "PLNHRK",   "PLNINR",   "PLNJPY",   "PNCCAD",   "PNCJPY",   "PNCPLN",   "PNCUSD",   "Poland20", "POPOLARE", "POPULARESP",   "POSTEITALIA",  "POTASH",   "PPC",  "PRICELINE",    "PSBC", "PZU",  "Qualcomm", "QUNAR",    "RBS",  "REE",  "RegalBeloit",  "Renault",  "REPSOL",   "Rice", "RioTinto", "ROCKET",   "ROLLSROYCE",   "ROMGAZ",   "RONJPY",   "RONPLN",   "ROSNEFT",  "RUBJPY",   "RUBPLN",   "RWE",  "SABADELL", "SABMiller",    "SACYR",    "SafeBulkers",  "SAfrica40",    "SaintGobain",  "SALESFORCE",   "SAMSUNG",  "SANDISK",  "SANOFI",   "SANTANDER",    "SAP",  "Sasol",    "SBERBANK", "Scorpio",  "SEKJPY",   "SEKPLN",   "Severstal",    "SGDJPY",   "SGDPLN",   "ShakeShack",   "SHELL",    "SHOPIFY",  "SIEMENS",  "SINA", "Snap", "SOCIETE",  "SOLARCITY",    "SONY", "SouFun",   "soybeans", "Soybeans!",    "Soybeans!",    "Soybeans!",    "Spain35",  "Splunk",   "Square",   "STARBUCKS",    "Statoil",  "Sugar",    "Sweden30", "Swiss20",  "Sydney200",    "SYMANTEC", "Synaptics",    "Target",   "TDBank",   "TECK", "TECK.",    "TECK.",    "TELECOMITAL",  "TELEFONESP",   "TELEFONICA",   "Telenor",  "TeliaSonera",  "TerraForm",    "TESCO",    "TESLA",    "TEVA", "Tiffany",  "TitanCement",  "TOTAL",    "TOYOTA",   "TPSA", "TRIPADVISOR",  "TRYJPY",   "TRYPLN",   "Twilio",   "TWITTER",  "UBS",  "UK100",    "Unicredit",    "UNISTEEL", "US10YNote",    "US30YBond",    "USA2000",  "USA30",    "USA500",   "USDBRL",   "USDCAD",   "USDCAD!",  "USDCAD.",  "USDCHF",   "USDCHF!",  "USDCHF.",  "USDCNH",   "USDCZK",   "USDCZK.",  "USDDKK",   "USDDKK.",  "USDHKD",   "USDHRK",   "USDHUF",   "USDHUF.",  "USDILS",   "USDINR",   "USDJPY",   "USDJPY!",  "USDJPY.",  "USDMXN",   "USDNOK",   "USDNOK.",  "USDPLN",   "USDPLN!",  "USDPLN.",  "USDRON",   "USDRON.",  "USDRUB",   "USDSEK",   "USDSEK.",  "USDSGD",   "USDSGD.",  "USDTRY",   "USDTRY.",  "USDZAR",   "USFoods",  "USTECH100",    "VA",   "VALE", "VestasWind",   "VIG",  "VINCI",    "Vipshop",  "VISA", "VIVENDI",  "vixx", "VODAFONE", "VolksWagen",   "Volvo",    "WALMART",  "WEIBO",    "WellsFargo",   "Wheat",    "Wheat!",   "Wheat!",   "WIZZ", "WOWO", "WPP",  "XAGUSD",   "XAGUSD.",  "XAUUSD",   "XAUUSD.",  "Xylem",    "YAHOO",    "YamanaGold",   "YANDEX",   "Yara", "Yelp", "YYInc",    "ZARJPY",   "ZARPLN",   "Zinc", "ZTO",  "ZYNGA",
                                };

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init(){

    if (        Point == 0.00001 ) Poin = 0.0001;
    else { if ( Point == 0.001   ) Poin = 0.01;
           else                    Poin = Point;
    }
    return( 0 );
    }
//+------------------------------------------------------------------+
//| start function                                    |
//+------------------------------------------------------------------+
int start(){

    int count = ArraySize( Currencies );

    for ( int ii = 0; ii < count; ii++ ){

          dSymbol = Currencies[ii];   
          handle  = FileOpen( "Hist_" + dSymbol + "_" + Period() + ".csv", FILE_BIN | FILE_WRITE );

          if ( handle < 1 ){
               Print( "Err ", GetLastError() );
               return( 0 );
          }
          WriteHeader();

          for ( int i = 0; i < maxBars - 1; i++ ){
                WriteDataRow( i );
          }
          FileClose( handle );
     }
     Alert( "Done. "
          +  maxBars + " bars generated "
          +  TimeMonth( TimeLocal() )
          +  TimeDay(   TimeLocal() )
          +  TimeYear(  TimeLocal() )
          + "_"
          +  TimeHour(  TimeLocal() )
          +  TimeMinute(TimeLocal() )
             );

     return( 0 );
     }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void WriteData( string txt ){

     FileWriteString( handle, txt, StringLen( txt ) );

     return;
     }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void WriteHeader(){

     WriteData( "Symbol," );
     WriteData( "Date," );
     WriteData( "DayOfWeek," );
     WriteData( "DayOfYear," );
     WriteData( "Open," );
     WriteData( "High," );
     WriteData( "Low," );
     WriteData( "Close," );
     WriteData( "RSI5,RSI11,MOM3_c,CCI11_c," );
     WriteData( "\n" );

     return;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void WriteDataRow( int i ){

     double  dSymTime, dSymOpen, dSymHigh, dSymLow, dSymClose, dSymVolume;
     int     dDayofWk, dDayofYr, iDigits;

     dSymTime = ( iTime( dSymbol, Period(), i ) );
     dDayofWk = (  TimeDayOfWeek( dSymTime ) );
     dDayofYr =    TimeDayOfYear( dSymTime );

     dSymOpen = ( iOpen( dSymbol, Period(), i ) );

  // if (  TimeToStr( dSymTime, TIME_DATE ) != "1970." ){
     if (  dSymOpen >  0 ){

           WriteData( dSymbol + "," );
           WriteData( TimeToStr( dSymTime, TIME_DATE | TIME_MINUTES ) + "," );

           iDigits    = MarketInfo(  Symbol(),MODE_DIGITS );
           dSymOpen   = ( iOpen(    dSymbol,  Period(), i ) );
           dSymHigh   = ( iHigh(    dSymbol,  Period(), i ) );
           dSymLow    = ( iLow(     dSymbol,  Period(), i ) );
           dSymClose  = ( iClose(   dSymbol,  Period(), i ) );
           dSymVolume = ( iVolume(  dSymbol,  Period(), i ) );

       //  int    BarsInBox = 8;

       //  double PeriodHighest = High[iHighest( dSymbol, Period(), MODE_HIGH, BarsInBox + 1, i )];
       //  double PeriodLowest  = Low[ iLowest(  dSymbol, Period(), MODE_LOW,  BarsInBox + 1, i )];
       //  double PeriodRNG     = ( PeriodHighest - PeriodLowest ) / Poin;

           double RSI5_c   =  iRSI(      NULL, 0,  5, PRICE_CLOSE, i   );
           double RSI5_p3  =  iRSI(      NULL, 0,  5, PRICE_CLOSE, i+3 );
           double MOM3_c   =  iMomentum( NULL, 0, 21, PRICE_CLOSE, i   );
           double MOM3_p3  =  iMomentum( NULL, 0, 21, PRICE_CLOSE, i+3 );
           double CCI11_c  =  iCCI(      NULL, 0,  5, PRICE_CLOSE, i   );
           double CCI11_p3 =  iCCI(      NULL, 0,  5, PRICE_CLOSE, i+3 );

           WriteData( dDayofWk + "," + dDayofYr + "," );

           WriteData( DoubleToStr( dSymOpen,  iDigits ) + "," );
           WriteData( DoubleToStr( dSymHigh,  iDigits ) + "," );
           WriteData( DoubleToStr( dSymLow,   iDigits ) + "," );

       //  WriteData( DoubleToStr( dSymClose, iDigits ) + "," + PeriodHighest + "," + PeriodLowest + "," + PeriodRNG );
           WriteData( DoubleToStr( dSymClose, iDigits ) + ","
                    + DoubleToStr( RSI5_c,    2 )       + ","
                    + DoubleToStr( RSI5_p3,   2 )       + ","
                    + DoubleToStr( MOM3_c,    2 )       + ","
                    + DoubleToStr( MOM3_p3,   2 )       + ","
                    + DoubleToStr( CCI11_c,   2 )       + ","
                    + DoubleToStr( CCI11_p3,  2 )       + ","
                      );
           WriteData( "\n" );
     }
     return;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
string GetPeriodName() {

   switch( Period() ){

       case PERIOD_D1:  return( "Day" );
       case PERIOD_H4:  return( "4_Hour" );
       case PERIOD_H1:  return( "Hour" );
       case PERIOD_M1:  return( "Minute" );
       case PERIOD_M15: return( "15_Minute" );
       case PERIOD_M30: return( "30_Minute" );
       case PERIOD_M5:  return( "5_Minute" );
       case PERIOD_MN1: return( "Month" );
       case PERIOD_W1:  return( "Week" );
       }
   }

Java Money - currency conversion rate on specific date

copy iconCopydownload iconDownload
ConversionQueryBuilder.of().setTermCurrency("EUR").
        set(LocalDate.class, LocalDate.of(2018, 1, 1)).build()
MonetaryConversions.getConversion(conversionQuery)
default CurrencyConversion getConversion(ConversionQuery conversionQuery) {
    return getExchangeRateProvider(conversionQuery).getCurrencyConversion(
            Objects.requireNonNull(conversionQuery.getCurrency(), "Terminating Currency is required.")
    );
}
MonetaryConversions.getExchangeRateProvider().getCurrencyConversion(conversionQuery)
-----------------------
ConversionQueryBuilder.of().setTermCurrency("EUR").
        set(LocalDate.class, LocalDate.of(2018, 1, 1)).build()
MonetaryConversions.getConversion(conversionQuery)
default CurrencyConversion getConversion(ConversionQuery conversionQuery) {
    return getExchangeRateProvider(conversionQuery).getCurrencyConversion(
            Objects.requireNonNull(conversionQuery.getCurrency(), "Terminating Currency is required.")
    );
}
MonetaryConversions.getExchangeRateProvider().getCurrencyConversion(conversionQuery)
-----------------------
ConversionQueryBuilder.of().setTermCurrency("EUR").
        set(LocalDate.class, LocalDate.of(2018, 1, 1)).build()
MonetaryConversions.getConversion(conversionQuery)
default CurrencyConversion getConversion(ConversionQuery conversionQuery) {
    return getExchangeRateProvider(conversionQuery).getCurrencyConversion(
            Objects.requireNonNull(conversionQuery.getCurrency(), "Terminating Currency is required.")
    );
}
MonetaryConversions.getExchangeRateProvider().getCurrencyConversion(conversionQuery)

Putting a "game" inside a game

copy iconCopydownload iconDownload
import random


players = ['human', 'computer']
random.shuffle(players)
# Assign the shuffled player names to these two variables.
player1, player2 = players

a = random.randint(1, 6)
b = random.randint(1, 6)

# Then print the dice of the players.
print(f'{player1} rolled {a} and {player2} rolled {b}')

user_input = input('Enter "y" to roll again: ')

# Just check if the input starts with 'y'.
if user_input.lower().startswith('y'):
    # Change either variable a or b depending on the first player.
    if player1 == 'human':
        a = random.randint(1, 6)
    else:
        b = random.randint(1, 6)

print(f'{player1} rolled {a} and {player2} rolled {b}')

Community Discussions

Trending Discussions on moneta
  • JOOQ Code Generation via JPADatabase problem with custom composite user type
  • How to use cumulative sum function for grouped data with missing observations
  • Validate currency code matches one of the allowed values
  • VBA force closes Excel 365 but works fine in Excel 2019
  • KARATE: print statement doesn't write to console with log4j2
  • MonetaryException: No MonetaryAmountsSingletonSpi loaded
  • I can not log in to the site through curl
  • Convert MonetaryAmount to long of minor units (Javamoney)
  • Moneta 1.3 ExchangeRateProvider.getExchangeRate(base, term) returns null
  • Overwriting dependency/plugin Management in multiple Levels of POMs
Trending Discussions on moneta

QUESTION

JOOQ Code Generation via JPADatabase problem with custom composite user type

Asked 2021-Jun-15 at 13:38

I am trying to use JOOQ code generation from JPA Entity. I have already created a dedicated maven module where the code will be generated which has dependency on a module containing all entities as well code generation plugin with of jooq.

To add more clarify on project structure, here are the modules:(The names are made up but the structure reflects the current project i am working on)

net-example
  |- net-example-data (contains both entities and spring data repositories)
  |- net-example-jooq (where jooq plugin below is configured and should generate the code )
  |- net-example-business (business layer)
  |- net-example-api (api layer)

So in the end i want is, when i build net-example-jooq it should be able to produce the jooq classes from entities found in net-example-data.

pom.xml of net-example-jooq

<build>
        .....
        <plugins>
            <plugin>
                <groupId>org.jooq</groupId>
                <artifactId>jooq-codegen-maven</artifactId>
                <version>${jooq.version}</version>
                <!-- The plugin should hook into the generate goal -->
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>

                    </execution>
                </executions>
                <!-- Specify the plugin configuration.
                     The configuration format is the same as for the standalone code generator -->
                <configuration>
                    <!-- Generator parameters -->
                    <generator>
                        <database>
                            <name>org.jooq.meta.extensions.jpa.JPADatabase</name>
                            <properties>
                                <property>
                                    <key>packages</key>
                                    <value>net.example</value>
                                </property>
                                <property>
                                    <key>useAttributeConverters</key>
                                    <value>true</value>
                                </property>
                                <property>
                                    <key>unqualifiedSchema</key>
                                    <value>none</value>
                                </property>
                                <property>
                                    <key>hibernate.physical_naming_strategy</key>
                                    <value>org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy</value>
                                </property>
                            </properties>
                            <customTypes>
                                <customType>
                                    <name>money-type</name>
                                    <type>org.javamoney.moneta.Money</type>
                                </customType>
                                <customType>
                                    <name>currency-unit-type</name>
                                    <type>javax.money.CurrencyUnit</type>
                                </customType>
                                <customType>
                                    <name>zone-id-type</name>
                                </customType>
                            </customTypes>
                        </database>
                        <target>
                            <packageName>net.example.generated</packageName>
                            <directory>src/main/java</directory>
                        </target>
                    </generator>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>com.h2database</groupId>
                        <artifactId>h2</artifactId>
                        <version>1.4.193</version>
                    </dependency>
                    <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-data-jpa</artifactId>
                        <version>2.3.5.RELEASE</version>
                    </dependency>
                    <dependency>
                        <groupId>net.example</groupId>
                        <artifactId>example-data</artifactId>
                        <version>${project.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
...

And here is one of entities containing the custom type.

@Entity
public class Example {

   @Id
   private UUID id;
   
   @Column(name = "NAME")
   private String name;


   @Columns(columns = {
            @Column(name = "CURRENCY"),
            @Column(name = "AMOUNT")
    })
    private Money moneyAmount; // org.javamoney.moneta.Money 

   ....

}

Custom types are defined with the package.info

@TypeDef(name = "money-type", typeClass = PersistentMoneyAmountAndCurrency.class, defaultForType = Money.class)
@TypeDef(name = "currency-unit-type", typeClass = PersistentCurrencyUnit.class, defaultForType = CurrencyUnit.class)
@TypeDef(name = "zone-id-type", typeClass = PersistentZoneIdAsString.class, defaultForType = ZoneId.class)
package net.example.data;

When i run mvn compile the project from the root directory (includes data module, jooq module and the other) i get the following error on the build of jooq module.

...
[ERROR] Failed to execute goal org.jooq:jooq-codegen-maven:3.14.8:generate (default) on project enmacc-server-jooq: Error running jOOQ code generation tool: Error while exporting schema: Could not determine type for column moneyAmount of type org.hibernate.type.SerializableType: java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 1 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.jooq:jooq-codegen-maven:3.14.8:generate (default) on project enmacc-server-jooq: Error running jOOQ code generation tool
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error running jOOQ code generation tool
    at org.jooq.codegen.maven.Plugin.execute (Plugin.java:210)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.jooq.exception.DataAccessException: Error while exporting schema
    at org.jooq.meta.extensions.AbstractInterpretingDatabase.connection (AbstractInterpretingDatabase.java:103)
    at org.jooq.meta.extensions.AbstractInterpretingDatabase.create0 (AbstractInterpretingDatabase.java:77)
    at org.jooq.meta.AbstractDatabase.create (AbstractDatabase.java:296)
    at org.jooq.meta.AbstractDatabase.create (AbstractDatabase.java:285)
    at org.jooq.meta.AbstractDatabase.setConnection (AbstractDatabase.java:275)
    at org.jooq.codegen.GenerationTool.run0 (GenerationTool.java:532)
    at org.jooq.codegen.GenerationTool.run (GenerationTool.java:233)
    at org.jooq.codegen.GenerationTool.generate (GenerationTool.java:228)
    at org.jooq.codegen.maven.Plugin.execute (Plugin.java:207)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.hibernate.MappingException: Could not determine type for column minimum_price_fluctuation_amount of type org.hibernate.type.SerializableType: java.lang.ArrayIndexOutOfBoundsException
    at org.hibernate.mapping.Column.getSqlTypeCode (Column.java:213)
    at org.hibernate.mapping.Column.getSqlType (Column.java:238)
    at org.hibernate.tool.schema.internal.StandardTableExporter.getSqlCreateStrings (StandardTableExporter.java:96)
    at org.hibernate.tool.schema.internal.StandardTableExporter.getSqlCreateStrings (StandardTableExporter.java:30)
    at org.hibernate.tool.schema.internal.SchemaCreatorImpl.createFromMetadata (SchemaCreatorImpl.java:315)
    at org.hibernate.tool.schema.internal.SchemaCreatorImpl.performCreation (SchemaCreatorImpl.java:166)
    at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation (SchemaCreatorImpl.java:135)
    at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation (SchemaCreatorImpl.java:121)
    at org.hibernate.tool.hbm2ddl.SchemaExport.doExecution (SchemaExport.java:296)
    at org.hibernate.tool.hbm2ddl.SchemaExport.execute (SchemaExport.java:249)
    at org.hibernate.tool.hbm2ddl.SchemaExport.execute (SchemaExport.java:228)
    at org.hibernate.tool.hbm2ddl.SchemaExport.create (SchemaExport.java:220)
    at org.jooq.meta.extensions.jpa.JPADatabase.export (JPADatabase.java:156)
    at org.jooq.meta.extensions.AbstractInterpretingDatabase.connection (AbstractInterpretingDatabase.java:100)
    at org.jooq.meta.extensions.AbstractInterpretingDatabase.create0 (AbstractInterpretingDatabase.java:77)
    at org.jooq.meta.AbstractDatabase.create (AbstractDatabase.java:296)
    at org.jooq.meta.AbstractDatabase.create (AbstractDatabase.java:285)
    at org.jooq.meta.AbstractDatabase.setConnection (AbstractDatabase.java:275)
    at org.jooq.codegen.GenerationTool.run0 (GenerationTool.java:532)
    at org.jooq.codegen.GenerationTool.run (GenerationTool.java:233)
    at org.jooq.codegen.GenerationTool.generate (GenerationTool.java:228)
    at org.jooq.codegen.maven.Plugin.execute (Plugin.java:207)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 1
    at org.hibernate.mapping.Column.getSqlTypeCode (Column.java:200)
    at org.hibernate.mapping.Column.getSqlType (Column.java:238)
    at org.hibernate.tool.schema.internal.StandardTableExporter.getSqlCreateStrings (StandardTableExporter.java:96)
    at org.hibernate.tool.schema.internal.StandardTableExporter.getSqlCreateStrings (StandardTableExporter.java:30)
    at org.hibernate.tool.schema.internal.SchemaCreatorImpl.createFromMetadata (SchemaCreatorImpl.java:315)
    at org.hibernate.tool.schema.internal.SchemaCreatorImpl.performCreation (SchemaCreatorImpl.java:166)
    at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation (SchemaCreatorImpl.java:135)
    at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation (SchemaCreatorImpl.java:121)
    at org.hibernate.tool.hbm2ddl.SchemaExport.doExecution (SchemaExport.java:296)
    at org.hibernate.tool.hbm2ddl.SchemaExport.execute (SchemaExport.java:249)
    at org.hibernate.tool.hbm2ddl.SchemaExport.execute (SchemaExport.java:228)
    at org.hibernate.tool.hbm2ddl.SchemaExport.create (SchemaExport.java:220)
    at org.jooq.meta.extensions.jpa.JPADatabase.export (JPADatabase.java:156)
    at org.jooq.meta.extensions.AbstractInterpretingDatabase.connection (AbstractInterpretingDatabase.java:100)
    at org.jooq.meta.extensions.AbstractInterpretingDatabase.create0 (AbstractInterpretingDatabase.java:77)
    at org.jooq.meta.AbstractDatabase.create (AbstractDatabase.java:296)
    at org.jooq.meta.AbstractDatabase.create (AbstractDatabase.java:285)
    at org.jooq.meta.AbstractDatabase.setConnection (AbstractDatabase.java:275)
    at org.jooq.codegen.GenerationTool.run0 (GenerationTool.java:532)
    at org.jooq.codegen.GenerationTool.run (GenerationTool.java:233)
    at org.jooq.codegen.GenerationTool.generate (GenerationTool.java:228)
    at org.jooq.codegen.maven.Plugin.execute (Plugin.java:207)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)


For a simple custom type if i use JPA attribute converters then it would work fine. I am aware that there is no direct support for matching multiple column to a single attribute via JPA Attribute converters (if i am not wrong)

Could anyone direct me here how to handle composite types for JOOQ code generation with JPADatabase? Thanks.

UPDATE:

The problem regarding the code generation was about the projection structure and where the classes were missing on the classpath. However regarding handling of composite types please refer to the accepted answer.

ANSWER

Answered 2021-Jun-02 at 07:53

Regarding the error

I'm assuming you have missing dependencies on your code generation class path. Once you update your question, I'll update my answer.

Regarding jOOQ code generation support for @TypeDef etc.

jOOQ won't support your generated composite types in generated code out of the box, you'll still have to add forced type configurations for that, possibly embeddable type configurations:

Note that the JPADatabase offers a quick win by integrating with simple JPA defined schemas very quickly. It has its caveats. For best results, I recommend going DDL first (and generate both jOOQ code and JPA model from that), because it will be much easier to put your schema change management under version control, e.g. via Flyway or Liquibase.

Source https://stackoverflow.com/questions/67784647

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install moneta

Install Moneta via Rubygems. or add it to your Gemfile.
You can use Moneta to build your own key/value server which is shared between multiple processes. If you run the following code in two different processes, they will share the same data which will also be persistet in the database shared.db. If you want to go further, you might want to take a look at Moneta::Server and Moneta::Adapters::Client which are used by Moneta::Shared and provide the networking communication. But be aware that they are experimental and subjected to change. They provide an acceptable performance (for being ruby only), but don't have a stable protocol yet. You might wonder why I didn't use DRb to implement server and client - in fact my first versions used it, but with much worse performance and it was real fun to implement the networking directly :) There is still much room for improvement and experiments, try EventMachine, try Kgio, ...

Support

In case you are wondering, Moneta uses Semantic Versioning since v1.0.0.

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Explore Related Topics

Share this Page

share link
Reuse Pre-built Kits with moneta
Compare Database Libraries with Highest Support
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.