Esempio n. 1
1
        public static bool gopost(string url, string user, string password,  string data, TradeLink.API.DebugDelegate deb, out string result)
        {
            debs = deb;
            Curl.GlobalInit((int)CURLinitFlag.CURL_GLOBAL_ALL);

            Easy easy = new Easy();
            rresult = new StringBuilder();
            hasresult = false;

            Easy.WriteFunction wf = new Easy.WriteFunction(OnWritePostData);
            easy.SetOpt(CURLoption.CURLOPT_WRITEFUNCTION, wf);
            Easy.DebugFunction df = new Easy.DebugFunction(OnDebug);
            easy.SetOpt(CURLoption.CURLOPT_DEBUGFUNCTION, df);

            // simple post - with a string
            easy.SetOpt(CURLoption.CURLOPT_POSTFIELDS,
                data);
            Slist sl = new Slist();
            sl.Append("Content-Type:application/xml");
            sl.Append("Accept: application/xml");
            easy.SetOpt(CURLoption.CURLOPT_HTTPHEADER, sl);
            easy.SetOpt(CURLoption.CURLOPT_SSL_VERIFYPEER, false);
            easy.SetOpt(CURLoption.CURLOPT_USERAGENT,
                "Mozilla 4.0 (compatible; MSIE 6.0; Win32");
            easy.SetOpt(CURLoption.CURLOPT_FOLLOWLOCATION, true);
            easy.SetOpt(CURLoption.CURLOPT_USERPWD, user + ":" + password);
            CURLhttpAuth authflag = CURLhttpAuth.CURLAUTH_BASIC;
            easy.SetOpt(CURLoption.CURLOPT_HTTPAUTH, authflag);
            easy.SetOpt(CURLoption.CURLOPT_URL,url);
            
            easy.SetOpt(CURLoption.CURLOPT_POST, true);
            if (debs!=null)
                easy.SetOpt(CURLoption.CURLOPT_VERBOSE, true);
            


            CURLcode err = easy.Perform();
            int waits = 0;
            int maxwaits = 200;
            while (!hasresult && (waits++<maxwaits))
                System.Threading.Thread.Sleep(10);

            int rcodei = 0;
            CURLcode rcode = easy.GetInfo(CURLINFO.CURLINFO_RESPONSE_CODE, ref rcodei);


            if (!hasresult && (deb != null))
                deb(easy.StrError(err));

            easy.Cleanup();



            Curl.GlobalCleanup();
            result = rresult.ToString();



            return hasresult;
        }
Esempio n. 2
0
        public static bool ConfirmSubmitCapitalRequest(TradeLink.AppKit.Results rs, bool skip, TradeLink.API.DebugDelegate deb)

        {
            d = deb;
            if (skip)
            {
                return false;
            }

            CapitalRequestConfim crc = new CapitalRequestConfim();
            bool ok = false;
            if (crc.InvokeRequired)
                crc.Invoke(new capcondel(ConfirmSubmitCapitalRequest), new object[] { rs, skip, deb });
            else
            {
                DialogResult dr = crc.ShowDialog();
                if (!crc.AskAgain)
                {
                    // disable tracking

                }
                ok = dr == DialogResult.Yes;
            }
            if (!ok) return false;
            return CapitalRequest.Submit(crc.Email, rs, deb);
        }
Esempio n. 3
0
        public Boolean selectTradeLink(string expectedVin)
        {
            Boolean isSuccessful = false;

            try
            {
                //Click(By.XPath("//div[10]//div[@class='tm-grid-icon-label']"));
                Actions action = new Actions(Driver.GetDriver());

                IWebElement shortCutMenulink = Driver.GetDriver().FindElement(By.XPath("//div[@class='tm-icon actions-cell ng-star-inserted']/i[@class='toyota-icon more-vert']"));
                action.MoveToElement(shortCutMenulink).Click().Build().Perform();
                Driver.GetDriver().Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(30);
                if (TradeLink.Displayed)
                {
                    Console.WriteLine("Trade Link is found");
                    TradeLink.Click();
                    Driver.GetDriver().Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30);
                    Console.WriteLine("Trade Popup Title======" + TradePopupTitle.Text);
                    if ((TradePopupTitle.Text.Trim() == "Trade vehicles") && (TradeWindowVin.Text.Contains(expectedVin)))
                    {
                        isSuccessful = true;
                        Console.WriteLine("Trade Link was found and clicked fine.");
                    }
                }
            }
            catch (StaleElementReferenceException ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
            return(isSuccessful);
        }
Esempio n. 4
0
     public static void Send(string gmailuser, string password, string to, string subject, string message, TradeLink.API.DebugDelegate deb)
     {
         d = deb;
         try
         {
             MailMessage mail = new MailMessage();
             System.Net.NetworkCredential cred = new System.Net.NetworkCredential
 (gmailuser, password);
             mail.To.Add(to);
             mail.Subject = subject;
             mail.From = new MailAddress(gmailuser);
             mail.IsBodyHtml = true;
             mail.Body = message;
             SmtpClient smtp = new SmtpClient("smtp.gmail.com");
             smtp.UseDefaultCredentials = false;
             smtp.EnableSsl = true;
             smtp.Credentials = cred;
             smtp.Port = 587;
             smtp.SendCompleted += new SendCompletedEventHandler(s_SendCompleted);
             smtp.Send(mail);
         }
         catch (Exception ex)
         {
             debug("Error sending email from: " + gmailuser + " to: " + to + " subject: " + subject + " err: " + ex.Message + ex.StackTrace);
         }
     }
Esempio n. 5
0
 public CapitalRequest(string email, TradeLink.AppKit.Results rs)
     : this(email, rs.ToString())
 {
     SubmittedResults = rs;
     usingresults = true;
     result_symbols = rs.Symbols;
     result = System.Text.RegularExpressions.Regex.Replace(result, "Symbols:.*\n", string.Empty);
     Source = CapitalRequestSource.TradeLink;
 }
Esempio n. 6
0
 public AuthInfoPrompt(TradeLink.AppKit.AuthInfo authinfo)
 {
     ai = authinfo;
     InitializeComponent();
     _un.Text = ai.Username;
     _pw.Text = ai.Password;
     Invalidate(true);
     
 }
Esempio n. 7
0
 void raw_GotTick(TradeLink.API.Tick t)
 {
     if (!syms.Contains(t.symbol))
         syms.Add(t.symbol);
     tickcount++;
     bool viol = t.datetime<lasttime;
     GOODTIME &= !viol;
     lasttime = t.datetime;
 }
Esempio n. 8
0
        public GauntletEngine(TradeLink.API.Response r, TickFileFilter tff)
        {
            _r = r;
            _r.SendOrder += new OrderDelegate(_r_SendOrder);
            _r.SendCancel += new UIntDelegate(_r_SendCancel);
            _tff = tff;
            _h = new HistSim(_tff);
            _h.GotTick += new TickDelegate(_h_GotTick);
            _h.SimBroker.GotOrderCancel += new OrderCancelDelegate(SimBroker_GotOrderCancel);
            _h.SimBroker.GotOrder += new OrderDelegate(_r.GotOrder);
            _h.SimBroker.GotFill += new FillDelegate(_r.GotFill);

        }
Esempio n. 9
0
        public GauntletEngine(TradeLink.API.Response r, HistSim h)
        {
            responseengine = r;
            bindresponse(ref responseengine);

            myhistsim = h;
            bindsim(ref myhistsim);
            
            SimBroker = new Broker();
            SimBroker.GotOrderCancel += new OrderCancelDelegate(SimBroker_GotOrderCancel);
            SimBroker.GotOrder += new OrderDelegate(responseengine.GotOrder);
            SimBroker.GotFill += new FillDelegate(responseengine.GotFill);
        }
Esempio n. 10
0
        public GauntletEngine(TradeLink.API.Response r, TickFileFilter tff)
        {
            _r = r;
            _r.SendOrderEvent += new OrderSourceDelegate(_r_SendOrder);
            _r.SendCancelEvent += new LongSourceDelegate(_r_SendCancel);
            _tff = tff;
            _h = new MultiSimImpl(_tff);
            _h.GotTick += new TickDelegate(_h_GotTick);
            SimBroker.GotOrderCancel += new OrderCancelDelegate(SimBroker_GotOrderCancel);
            SimBroker.GotOrder += new OrderDelegate(_r.GotOrder);
            SimBroker.GotFill += new FillDelegate(_r.GotFill);

        }
Esempio n. 11
0
 public static string string2urlparams(string content, TradeLink.API.DebugDelegate ds)
 {
     try
     {
         return System.Web.HttpUtility.UrlEncode(content);
     }
     catch (BadImageFormatException ex)
     {
         if (ds != null)
             ds("Error, install .net 4 from microsoft to correct. Err: " + ex.Message + ex.StackTrace);
     }
     return string.Empty;
 }
Esempio n. 12
0
 public override void GotFill(TradeLink.API.Trade fill)
 {
     // keep track of position
     D(fill.symbol + " fill: " + fill.ToString());
     _pt.Adjust(fill);
     // ensure fill comes from this response
     int idx = _entrysignal.getindex(fill.symbol);
     if (idx < 0) return;
     // reset signals if we're flat (allows re-entry)
     if (_pt[fill.symbol].isFlat)
     {
         _entrysignal[fill.symbol] = false;
         _exitsignal[fill.symbol] = false;
     }
 }
        public Boolean AccessTradePopup()
        {
            Boolean isTradePopoupAppear = false;

            try
            {
                Console.WriteLine("Found Vehicle in Status=====> " + GetVechileInventoryStatus());
                if ((GetVechileInventoryStatus().Contains("AVAILABLE")) || (GetVechileInventoryStatus().Contains("ALLOCATED")) || (GetVechileInventoryStatus().Contains("IN TRANSIT")))
                {
                    Driver.GetDriver().Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(60);
                    if (QuickActionsLnk.Displayed == true)
                    {
                        Console.WriteLine("Quick Actions link is present.");

                        QuickActionsLnk.Click();
                        Driver.GetDriver().Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30);
                        if (TradeLink.Displayed)
                        {
                            Console.WriteLine("Trade link is present.");
                            TradeLink.Click();
                            Driver.GetDriver().Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30);
                            Wait.Until(x => (TradeDialog.Displayed != true));
                            Driver.GetDriver().Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(60);
                            Console.WriteLine("Trade Popup Title======" + TradePopupTitle.Text);
                            if (TradePopupTitle.Text.Trim() == "Trade vehicles")
                            {
                                isTradePopoupAppear = true;
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("Unable to see Quick Actions Link from Vehicle Detail Page.");
                    }
                }
                else
                {
                    Console.WriteLine("Status of Vehicle was not tradeable. Olease check the vin before you execute." + GetVechileInventoryStatus());
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Unable to access Trade Popup to make trade." + e.StackTrace);
            }
            return(isTradePopoupAppear);
        }
Esempio n. 14
0
 public override void GotTick(TradeLink.API.Tick tick)
 {
     // ignore quotes
     if (!tick.isTrade) return;
     // get current position
     Position p = pt[tick.symbol];
     // if we're flat, enter
     if (p.isFlat)
     {
         D("entering long");
         O(new BuyMarket(tick.symbol, 1));
     }
     // otherwise if we're up 10/th of a point, flat us
     else if (Calc.OpenPT(tick.trade, p) > .1m)
     {
         D("hit profit target");
         O(new MarketOrderFlat(p));
     }
 }
Esempio n. 15
0
        public void GotTick(TradeLink.API.Tick tick)
        {

            // if we don't have 10 trades yet, add it
            if (_dt.Rows.Count < ROWS)
            {
                _dt.Rows.Add(tick.time, tick.symbol,tick.trade, tick.size, tick.ex);
                refresh();
                return;
            }

            // otherwise, go through list and check to see if it's bigger
            for (int i = 0; i < _dt.Rows.Count; i++)
                if ((int)_dt.Rows[i]["TradeSize"] < tick.size)
                {
                    _dt.Rows[i].ItemArray = new object[] { tick.time, tick.symbol,tick.trade, tick.size, tick.ex };
                    refresh();
                    return;
                }
        }
Esempio n. 16
0
        public override void GotTick(TradeLink.API.Tick tick)
        {
            // ensure we track this symbol
            _entrysignal.addindex(tick.symbol,false);
            // track tick
            _kt.newTick(tick);
            // get current position
            Position p = _pt[tick.symbol];

            // if we're flat and no signal, enter
            if (p.isFlat && !_entrysignal[tick.symbol])
            {
                _entrysignal[tick.symbol] = true;
                D(tick.symbol+": entering long");
                O(new MarketOrder(tick.symbol, EntrySize));
            }
            else if (!p.isFlat && !_exitsignal[tick.symbol])
            {
                // get most recent tick data
                Tick k = _kt[tick.symbol];
                // estimate our exit price
                decimal exitprice = UseQuotes 
                    ? (k.hasAsk && p.isLong ? k.ask 
                    : (k.hasBid && p.isShort ? k.bid : 0))
                    : (k.isTrade ? k.trade : 0);
                // assuming we could estimate an exit, see if our exit would hit our target
                if ((exitprice != 0) && (Calc.OpenPT(exitprice, p) > ProfitTarget))
                {
                    _exitsignal[tick.symbol] = true;
                    D("hit profit target");
                    O(new MarketOrderFlat(p));
                }
                
                
            }
        }
Esempio n. 17
0
 public SellStop(string sym, int size, decimal stop, long orderid, TradeLink.API.OrderInstructionType oit) : base(sym, false, Math.Abs(size), 0, stop, "", 0, 0, orderid) { ValidInstruct = oit; }
Esempio n. 18
0
        public static string GetNetworkAddress(TradeLink.API.DebugDelegate deb)
        {
            debs = deb;
            try
            {
                List<string> macs = new List<string>();
                foreach (System.Net.NetworkInformation.NetworkInterface ni in System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces())
                {

                    if (ni.OperationalStatus != System.Net.NetworkInformation.OperationalStatus.Up)
                    {
                        debugs("ignoring non-up network interface: " + ni.Name + " / " + ni.Description + " type: " + ni.NetworkInterfaceType.ToString() + " " + ni.Id);
                        continue;
                    }
                    // skip virtual types
                    if ((ni.NetworkInterfaceType == System.Net.NetworkInformation.NetworkInterfaceType.Slip)
                        || (ni.NetworkInterfaceType == System.Net.NetworkInformation.NetworkInterfaceType.Ppp)
                        || (ni.NetworkInterfaceType == System.Net.NetworkInformation.NetworkInterfaceType.Loopback)
                        || (ni.NetworkInterfaceType == System.Net.NetworkInformation.NetworkInterfaceType.Tunnel)
                        || (ni.NetworkInterfaceType == System.Net.NetworkInformation.NetworkInterfaceType.Unknown))
                    {
                        debugs("ignoring virtual network interface: " + ni.Name + " / " + ni.Description + " type: " + ni.NetworkInterfaceType.ToString() + " " + ni.Id);
                        continue;
                    }

                    string id = ni.Id;
                    if (string.IsNullOrEmpty(id))
                        continue;
                    id = id.Replace("-", string.Empty);
                    id = id.Replace("{", string.Empty);
                    id = id.Replace("}", string.Empty);
                    macs.Add(id);
                    debugs("found network interface: " + ni.Name + " / " + ni.Description + " type: " + ni.NetworkInterfaceType.ToString() + " " + ni.Id);

                }
                // sort for determinism
                var tmp = macs.ToArray();
                Array.Sort(tmp);
                if (tmp.Length == 0)
                    return string.Empty;
                debugs("using first sorted network address: " + tmp[0]);
                // return first
                return tmp[0];

            }
            catch
            {
            }

            return string.Empty;
        }
Esempio n. 19
0
 public SellMarket(string sym, int size, long id, TradeLink.API.OrderInstructionType oit) : base(sym, false, System.Math.Abs(size), 0, 0, string.Empty, 0, 0, id) { ValidInstruct = oit; }
Esempio n. 20
0
        public static bool gomultipartpost(string url, string user, string password, string fname, string fpath, int ticketid,int maxwaitsec, bool showprogress, TradeLink.API.DebugDelegate deb, out string result)
        {
            debs = deb;
            Curl.GlobalInit((int)CURLinitFlag.CURL_GLOBAL_ALL);

            Easy easy = new Easy();
            rresult = new StringBuilder();
            hasresult = false;

            MultiPartForm mf = new MultiPartForm();


            // <input name="frmFileOrigPath">
            mf.AddSection(CURLformoption.CURLFORM_COPYNAME, "document[name]",
                CURLformoption.CURLFORM_COPYCONTENTS, fname,
                CURLformoption.CURLFORM_END);



            // <input type="File" name="f1">
            mf.AddSection(CURLformoption.CURLFORM_COPYNAME, "document[file]",
                CURLformoption.CURLFORM_FILE, fpath,
                CURLformoption.CURLFORM_CONTENTTYPE, "application/octet-stream",
                CURLformoption.CURLFORM_END);

            // <input name="frmFileDate">
            if (ticketid != 0)
                mf.AddSection(CURLformoption.CURLFORM_COPYNAME, "document[ticket_id]",
                    CURLformoption.CURLFORM_COPYCONTENTS, ticketid.ToString(),
                    CURLformoption.CURLFORM_END);

            if (showprogress)
            {
                Easy.ProgressFunction pf = new Easy.ProgressFunction(OnProgress);
                easy.SetOpt(CURLoption.CURLOPT_PROGRESSFUNCTION, pf);
            }


            Easy.WriteFunction wf = new Easy.WriteFunction(OnWritePostData);
            easy.SetOpt(CURLoption.CURLOPT_WRITEFUNCTION, wf);
            easy.SetOpt(CURLoption.CURLOPT_HTTPPOST, mf);
            Easy.DebugFunction df = new Easy.DebugFunction(OnDebug);
            easy.SetOpt(CURLoption.CURLOPT_DEBUGFUNCTION, df);

            // simple post - with a string
            //easy.SetOpt(CURLoption.CURLOPT_POSTFIELDS,data);
            Slist sl = new Slist();
            //sl.Append("Content-Type:multipart/form-data");
            sl.Append("Accept: application/xml");
            easy.SetOpt(CURLoption.CURLOPT_HTTPHEADER, sl);
            easy.SetOpt(CURLoption.CURLOPT_SSL_VERIFYPEER, false);
            easy.SetOpt(CURLoption.CURLOPT_USERAGENT,
                "Mozilla 4.0 (compatible; MSIE 6.0; Win32");
            easy.SetOpt(CURLoption.CURLOPT_FOLLOWLOCATION, true);
            easy.SetOpt(CURLoption.CURLOPT_USERPWD, user + ":" + password);
            CURLhttpAuth authflag = CURLhttpAuth.CURLAUTH_BASIC;
            easy.SetOpt(CURLoption.CURLOPT_HTTPAUTH, authflag);
            easy.SetOpt(CURLoption.CURLOPT_URL, url);

            //easy.SetOpt(CURLoption.CURLOPT_POST, true);
            if (debs != null)
                easy.SetOpt(CURLoption.CURLOPT_VERBOSE, true);



            CURLcode err = easy.Perform();
            int waits = 0;
            int maxwaits = 100*maxwaitsec;
            while (!hasresult && (waits++ < maxwaits))
                System.Threading.Thread.Sleep(10);

            int rcodei = 0;
            CURLcode rcode = easy.GetInfo(CURLINFO.CURLINFO_RESPONSE_CODE, ref rcodei);


            if (!hasresult && (deb != null))
                deb(easy.StrError(err));

            easy.Cleanup();
            mf.Free();


            Curl.GlobalCleanup();
            result = rresult.ToString();



            return hasresult && (rcodei==201);
        }
Esempio n. 21
0
 public Playback(TradeLink.API.HistSim simulator)
 {
     h = simulator;
     WorkerSupportsCancellation = true;
     WorkerReportsProgress = true;
 }
Esempio n. 22
0
 public void Subscribe(TradeLink.API.Basket mb)
 {
     TLSend(MessageTypes.REGISTERSTOCK, Text + "+" + mb.ToString());
 }
Esempio n. 23
0
 public override void GotPosition(TradeLink.API.Position p)
 {
     // keep track of position
     D(p.Symbol + " pos: " + p.ToString());
     _pt.Adjust(p);
 }
Esempio n. 24
0
 static void HistSource_gotTick(TradeLink.API.Tick t)
 {
     _tw.newTick((TickImpl)t);
 }
Esempio n. 25
0
 void h_GotTick(TradeLink.API.Tick t)
 {
     tickcount++;
     bt.newTick(t);
 }
Esempio n. 26
0
 void SimBroker_GotFill(TradeLink.API.Trade t)
 {
     fillcount++;
 }
Esempio n. 27
0
 void execute_GotTick(TradeLink.API.Tick t)
 {
     SimBroker.Execute(t);
     tickcount++;
     // generate fills periodically
     if (fillcount >= desiredfills) return;
     if (tickcount % 50 == 0)
     {
         bool side = fillcount % 2 == 0;
         SimBroker.SendOrderStatus(new MarketOrder(t.symbol, side, 100));
     }
 }
Esempio n. 28
0
        public GauntletEngine(TradeLink.API.Response r, TickFileFilter inittff)
        {
            responseengine = r;
            responseengine.SendOrderEvent += new OrderSourceDelegate(_r_SendOrder);
            responseengine.SendCancelEvent += new LongSourceDelegate(_r_SendCancel);
            responseengine.SendDebugEvent += new DebugDelegate(_r_SendDebugEvent);
            tff = inittff;
            myhistsim = new MultiSimImpl(tff);
            myhistsim.GotTick += new TickDelegate(_h_GotTick);
            SimBroker.GotOrderCancel += new OrderCancelDelegate(SimBroker_GotOrderCancel);
            SimBroker.GotOrder += new OrderDelegate(responseengine.GotOrder);
            SimBroker.GotFill += new FillDelegate(responseengine.GotFill);

        }
Esempio n. 29
0
 public void Subscribe(TradeLink.API.Basket mb)
 {
     // save last basket
     _b = mb;
     TLSend(MessageTypes.REGISTERSTOCK, Name + "+" + mb.ToString());
 }
Esempio n. 30
0
 public void GotDebug(TradeLink.API.Debug deb)
 {
     debugControl1.GotDebug(deb);
 }
        // GotTick is called everytime a new quote or trade occurs
        public override void GotTick(TradeLink.API.Tick tick)
        {

            // tmp workaround for "how to show debug messages from response constructor"
            if (debug_message_from_constructor.Length > 0)
            {
                D(debug_message_from_constructor);
                debug_message_from_constructor = "";
            }

            // keep track of time from tick
            time = tick.time;

            // safe tick to files
            //_ta.newTick(tick);

            // ignore quotes
            if (!tick.isTrade) return;

            // ignore ticks with timestamp prior to 9:30:00am
            if (tick.time < 93000) return;

            // ensure we track this symbol, all the other trackers will be indexed inside track_symbols_NewTxt()
            track_symbols.addindex(tick.symbol, false);

            // track tick
            track_ticks.newTick(tick);
            track_barlists.newTick(tick); // dimon: give any ticks (trades) to this symbol and tracker will create barlists automatically

            // if we don't have enough bars, wait for more ticks
            if (!track_barlists[tick.symbol].Has(_slow_ma_bar)) return;

        }
Esempio n. 32
0
 public void GotDebug(TradeLink.API.Debug deb)
 {
     _msg.AppendLine(deb.Msg);
     debugControl1.GotDebug(deb);
 }