Ejemplo n.º 1
0
        public static void Upload(string _dbName)
        {
            var serverSideAs = new List<UplodableObject>
                               	{
                               		new UplodableObject((int) ETestKind.A) {new UValue<int>("IVAL", 1)},
                               		new UplodableObject((int) ETestKind.A) {new UValue<int>("IVAL", 2)},
                               	};
            var serverSideBs = new List<UplodableObject>
                               	{
                               		new UplodableObject((int) ETestKind.B) {new UValue<string>("SVAL", "B1")},
                               		new UplodableObject((int) ETestKind.B) {new UValue<string>("SVAL", "B2")},
                               	};

            var parents = new List<UplodableObject>
                          	{
                          		new UplodableObject((int) ETestKind.PARENT) {new UValue<string>("NAME", "P1")},
                          		new UplodableObject((int) ETestKind.PARENT) {new UValue<string>("NAME", "P2")},
                          	};

            var childs = new List<UplodableObject>
                                 	{
                                        new UplodableObject((int) ETestKind.CHILD) {new UValue<double>("CVAL", 3.3)},
                                        new UplodableObject((int) ETestKind.CHILD) {new UValue<double>("CVAL", 4.4)},
                                        new UplodableObject((int) ETestKind.CHILD) {new UValue<double>("CVAL", 5.0)}
                                 	};

            var serverSideRefs = new List<UplodableObject>
                                 	{
                                 		new UplodableObject((int) ETestKind.REF) {new UValue<Guid>("RVAL", serverSideAs[0].Uid), new UValue<Guid>("CHILD_REF", childs[1].Uid)},
                                 		new UplodableObject((int) ETestKind.REF) {new UValue<Guid>("RVAL", serverSideAs[1].Uid), new UValue<Guid>("CHILD_REF", childs[2].Uid)},
                                 	};

            using (var st = new SQLiteStorage(_dbName))
            {
                using (st.CreateTransaction())
                {
                    foreach (var currency in serverSideAs)
                    {
                        st.InsertMain(currency);
                    }
                    foreach (var pair in serverSideBs)
                    {
                        st.InsertMain(pair);
                    }

                    st.InsertMain(childs[0], parents[0].Uid, "LIST".GetHashCode());
                    st.InsertMain(childs[1], parents[0].Uid, "LIST".GetHashCode());
                    st.InsertMain(childs[2], parents[1].Uid, "LIST".GetHashCode());

                    foreach (var index in serverSideRefs)
                    {
                        st.InsertMain(index);
                    }
                    foreach (var prt in parents)
                    {
                        st.InsertMain(prt);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static void Upload(string _dbName)
        {
            var serverSideAs = new List <UplodableObject>
            {
                new UplodableObject((int)ETestKind.A)
                {
                    new UValue <int>("IVAL", 1)
                },
                new UplodableObject((int)ETestKind.A)
                {
                    new UValue <int>("IVAL", 2)
                },
            };
            var serverSideBs = new List <UplodableObject>
            {
                new UplodableObject((int)ETestKind.B)
                {
                    new UValue <string>("SVAL", "B1")
                },
                new UplodableObject((int)ETestKind.B)
                {
                    new UValue <string>("SVAL", "B2")
                },
            };

            var parents = new List <UplodableObject>
            {
                new UplodableObject((int)ETestKind.PARENT)
                {
                    new UValue <string>("NAME", "P1")
                },
                new UplodableObject((int)ETestKind.PARENT)
                {
                    new UValue <string>("NAME", "P2")
                },
            };

            var childs = new List <UplodableObject>
            {
                new UplodableObject((int)ETestKind.CHILD)
                {
                    new UValue <double>("CVAL", 3.3)
                },
                new UplodableObject((int)ETestKind.CHILD)
                {
                    new UValue <double>("CVAL", 4.4)
                },
                new UplodableObject((int)ETestKind.CHILD)
                {
                    new UValue <double>("CVAL", 5.0)
                }
            };

            var serverSideRefs = new List <UplodableObject>
            {
                new UplodableObject((int)ETestKind.REF)
                {
                    new UValue <Guid>("RVAL", serverSideAs[0].Uid), new UValue <Guid>("CHILD_REF", childs[1].Uid)
                },
                new UplodableObject((int)ETestKind.REF)
                {
                    new UValue <Guid>("RVAL", serverSideAs[1].Uid), new UValue <Guid>("CHILD_REF", childs[2].Uid)
                },
            };

            using (var st = new SQLiteStorage(_dbName))
            {
                using (st.CreateTransaction())
                {
                    foreach (var currency in serverSideAs)
                    {
                        st.InsertMain(currency);
                    }
                    foreach (var pair in serverSideBs)
                    {
                        st.InsertMain(pair);
                    }

                    st.InsertMain(childs[0], parents[0].Uid, "LIST".GetHashCode());
                    st.InsertMain(childs[1], parents[0].Uid, "LIST".GetHashCode());
                    st.InsertMain(childs[2], parents[1].Uid, "LIST".GetHashCode());

                    foreach (var index in serverSideRefs)
                    {
                        st.InsertMain(index);
                    }
                    foreach (var prt in parents)
                    {
                        st.InsertMain(prt);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public static void Upload(string _dbName)
        {
            const string NAME = "NAME";

            var currencies = new List<UplodableObject>
                             	{
                             		new UplodableObject((int) EAlphaKind.CURRENCY) {new UValue<string>(NAME, "United States Dollar"), new UValue<string>("CODE", "USD")},
                                    new UplodableObject((int) EAlphaKind.CURRENCY) {new UValue<string>(NAME, "Great Britain Pound"), new UValue<string>("CODE", "GBP")},
                                    new UplodableObject((int) EAlphaKind.CURRENCY) {new UValue<string>(NAME, "Hong Kong Dollar"), new UValue<string>("CODE", "HKD")},
                             	};
            var pairs = new List<UplodableObject>
                            {
                             		new UplodableObject((int) EAlphaKind.CURRENCY_PAIR) {new UValue<Guid>("LEFT_CURRENCY", currencies[0].Uid), new UValue<Guid>("RIGHT_CURRENCY", currencies[1].Uid)},
                                    new UplodableObject((int) EAlphaKind.CURRENCY_PAIR) {new UValue<Guid>("LEFT_CURRENCY", currencies[0].Uid), new UValue<Guid>("RIGHT_CURRENCY", currencies[2].Uid)},
                                    new UplodableObject((int) EAlphaKind.CURRENCY_PAIR) {new UValue<Guid>("LEFT_CURRENCY", currencies[1].Uid), new UValue<Guid>("RIGHT_CURRENCY", currencies[2].Uid)},
                            };

            var indexes = new List<UplodableObject>
                            {
                             	new UplodableObject((int) EAlphaKind.INDEX) {new UValue<string>(NAME, "S&P 500 Index"), new UValue<Guid>("CURRENCY", currencies[0].Uid)},
                                new UplodableObject((int) EAlphaKind.INDEX) {new UValue<string>(NAME, "NASDAQ 100 Index"), new UValue<Guid>("CURRENCY", currencies[1].Uid)},
                                new UplodableObject((int) EAlphaKind.INDEX) {new UValue<string>(NAME, "Hang Seng Index"), new UValue<Guid>("CURRENCY", currencies[2].Uid)},
                            };

            var bonds = new List<UplodableObject>
                            {
                             	new UplodableObject((int) EAlphaKind.BOND) {new UValue<string>(NAME, "Sweden Govt Bond 10Y Benchmark Yield"), new UValue<Guid>("CURRENCY", currencies[0].Uid)},
                             	new UplodableObject((int) EAlphaKind.BOND) {new UValue<string>(NAME, "Aus 10yr Treasury Bond"), new UValue<Guid>("CURRENCY", currencies[0].Uid)},
                             	new UplodableObject((int) EAlphaKind.BOND) {new UValue<string>(NAME, "US Long Bond"), new UValue<Guid>("CURRENCY", currencies[0].Uid)},
                            };
            var derivatives = new List<UplodableObject>();

            using (var st = new SQLiteStorage(_dbName))
            {
                using (st.CreateTransaction())
                {
                    foreach (var currency in currencies)
                    {
                        st.InsertMain(currency);
                    }
                    foreach (var pair in pairs)
                    {
                        st.InsertMain(pair);
                        derivatives.Add(new UplodableObject((int)EAlphaKind.FORWARD) { new UValue<Guid>("ASSET", pair.Uid) });
                    }
                    foreach (var index in indexes)
                    {
                        st.InsertMain(index);
                        derivatives.Add(new UplodableObject((int)EAlphaKind.FUTURES) { new UValue<Guid>("ASSET", index.Uid) });
                    }
                    foreach (var bond in bonds)
                    {
                        st.InsertMain(bond);
                        derivatives.Add(new UplodableObject((int)EAlphaKind.FUTURES) { new UValue<Guid>("ASSET", bond.Uid) });
                    }

                    foreach (var derivative in derivatives)
                    {
                        st.InsertMain(derivative);
                    }

                    for (var i = 0; i < 3; ++i)
                    {
                        var prt = new UplodableObject((int)EAlphaKind.PORTFOLIO)
                            {
                                new UValue<string>(NAME, "Portfolio" + i),
                                new UValue<Guid>("BASE_CURRENCY", currencies[i].Uid),
                                new UValue<decimal>("NOTIONAL_AMOUNT", i*1000000)
                            };
                        st.InsertMain(prt);
                        for (var index = i; index < derivatives.Count; index += 3)
                        {
                            var pi = new UplodableObject((int)EAlphaKind.PORTFOLIO_INSTRUMENT)
                            {
                                new UValue<Guid>("DERIVATIVE", derivatives[index].Uid),
                            };
                            st.InsertMain(pi, prt.Uid, "INSTRUMENTS".GetHashCode());
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public static void Upload(string _dbName)
        {
            const string NAME = "NAME";

            var currencies = new List <UplodableObject>
            {
                new UplodableObject((int)EAlphaKind.CURRENCY)
                {
                    new UValue <string>(NAME, "United States Dollar"), new UValue <string>("CODE", "USD")
                },
                new UplodableObject((int)EAlphaKind.CURRENCY)
                {
                    new UValue <string>(NAME, "Great Britain Pound"), new UValue <string>("CODE", "GBP")
                },
                new UplodableObject((int)EAlphaKind.CURRENCY)
                {
                    new UValue <string>(NAME, "Hong Kong Dollar"), new UValue <string>("CODE", "HKD")
                },
            };
            var pairs = new List <UplodableObject>
            {
                new UplodableObject((int)EAlphaKind.CURRENCY_PAIR)
                {
                    new UValue <Guid>("LEFT_CURRENCY", currencies[0].Uid), new UValue <Guid>("RIGHT_CURRENCY", currencies[1].Uid)
                },
                new UplodableObject((int)EAlphaKind.CURRENCY_PAIR)
                {
                    new UValue <Guid>("LEFT_CURRENCY", currencies[0].Uid), new UValue <Guid>("RIGHT_CURRENCY", currencies[2].Uid)
                },
                new UplodableObject((int)EAlphaKind.CURRENCY_PAIR)
                {
                    new UValue <Guid>("LEFT_CURRENCY", currencies[1].Uid), new UValue <Guid>("RIGHT_CURRENCY", currencies[2].Uid)
                },
            };

            var indexes = new List <UplodableObject>
            {
                new UplodableObject((int)EAlphaKind.INDEX)
                {
                    new UValue <string>(NAME, "S&P 500 Index"), new UValue <Guid>("CURRENCY", currencies[0].Uid)
                },
                new UplodableObject((int)EAlphaKind.INDEX)
                {
                    new UValue <string>(NAME, "NASDAQ 100 Index"), new UValue <Guid>("CURRENCY", currencies[1].Uid)
                },
                new UplodableObject((int)EAlphaKind.INDEX)
                {
                    new UValue <string>(NAME, "Hang Seng Index"), new UValue <Guid>("CURRENCY", currencies[2].Uid)
                },
            };

            var bonds = new List <UplodableObject>
            {
                new UplodableObject((int)EAlphaKind.BOND)
                {
                    new UValue <string>(NAME, "Sweden Govt Bond 10Y Benchmark Yield"), new UValue <Guid>("CURRENCY", currencies[0].Uid)
                },
                new UplodableObject((int)EAlphaKind.BOND)
                {
                    new UValue <string>(NAME, "Aus 10yr Treasury Bond"), new UValue <Guid>("CURRENCY", currencies[0].Uid)
                },
                new UplodableObject((int)EAlphaKind.BOND)
                {
                    new UValue <string>(NAME, "US Long Bond"), new UValue <Guid>("CURRENCY", currencies[0].Uid)
                },
            };
            var derivatives = new List <UplodableObject>();

            using (var st = new SQLiteStorage(_dbName))
            {
                using (st.CreateTransaction())
                {
                    foreach (var currency in currencies)
                    {
                        st.InsertMain(currency);
                    }
                    foreach (var pair in pairs)
                    {
                        st.InsertMain(pair);
                        derivatives.Add(new UplodableObject((int)EAlphaKind.FORWARD)
                        {
                            new UValue <Guid>("ASSET", pair.Uid)
                        });
                    }
                    foreach (var index in indexes)
                    {
                        st.InsertMain(index);
                        derivatives.Add(new UplodableObject((int)EAlphaKind.FUTURES)
                        {
                            new UValue <Guid>("ASSET", index.Uid)
                        });
                    }
                    foreach (var bond in bonds)
                    {
                        st.InsertMain(bond);
                        derivatives.Add(new UplodableObject((int)EAlphaKind.FUTURES)
                        {
                            new UValue <Guid>("ASSET", bond.Uid)
                        });
                    }

                    foreach (var derivative in derivatives)
                    {
                        st.InsertMain(derivative);
                    }

                    for (var i = 0; i < 3; ++i)
                    {
                        var prt = new UplodableObject((int)EAlphaKind.PORTFOLIO)
                        {
                            new UValue <string>(NAME, "Portfolio" + i),
                            new UValue <Guid>("BASE_CURRENCY", currencies[i].Uid),
                            new UValue <decimal>("NOTIONAL_AMOUNT", i * 1000000)
                        };
                        st.InsertMain(prt);
                        for (var index = i; index < derivatives.Count; index += 3)
                        {
                            var pi = new UplodableObject((int)EAlphaKind.PORTFOLIO_INSTRUMENT)
                            {
                                new UValue <Guid>("DERIVATIVE", derivatives[index].Uid),
                            };
                            st.InsertMain(pi, prt.Uid, "INSTRUMENTS".GetHashCode());
                        }
                    }
                }
            }
        }