Keeping the balance

I have two lists, one for stocks bought and one for stocks sold. I now want to keep track whether the strategy is making or loosing money.public void startPeriodicDownload(){
        int delay = 5000;   // delay for 5 sec.
        int period = 1000*10;  // repeat every min.
        Timer timer = new Timer();
        timer.scheduleAtFixedRate(new TimerTask() {
            public void run() {
                RetrieveAndSaveFile("http://www.efg.eurosport.com/efg/shares.jsp");
                ReadFile("/temp.txt");
                extractData();
                for(int x=0; x<team.length-1;x++){
                    if(x==0){
                        team[x].addPrice(Double.parseDouble(teamPrice.getItem(x+1)));
                    }else{
                        team[x].addPrice(Double.parseDouble(teamPrice.getItem(x*2+1)));
                    UpdateBuyList(x);
                    UpdateSellList(x);
                NumberFormat formatter = new DecimalFormat("0.00");
                String s = formatter.format(investments);
                lblInvestments.setText("$"+s);
                s = formatter.format(balance);
                lblBalance.setText("$"+s);
                s = formatter.format(total);
                lblTotal.setText("$"+s);
                downloadCounter++;
                System.out.println("Time " +downloadCounter+ ":" + new Timestamp(System.currentTimeMillis()));
        }, delay, period);
    private void UpdateBuyList(int teamNumber){
        if((team[teamNumber].Buy())&&!( buyModel.contains(team[teamNumber].getTeamName() ) ) ){
            buyModel.add(0, team[teamNumber].getTeamName());
            double lotCost=10*team[teamNumber].getCurrentPrice();
            if(balance>lotCost){
                balance-=lotCost;
                investments+=lotCost;
                total=balance+investments;
                txtInvestments.append(team[teamNumber].getTeamName() + " bought @$" +lotCost+"\n");
    private void UpdateSellList(int teamNumber){
        int index = buyModel.indexOf(team[teamNumber].getTeamName());
        if(index!=-1){
            if(team[teamNumber].Sell()){
                int pos = sellList.getModel().getSize();
                sellModel.add(pos,buyModel.getElementAt(index));
                buyModel.remove(index);
                double lotCost=10*team[teamNumber].getCurrentPrice();
                balance+=lotCost;
                investments-=lotCost;
                total=balance+investments;
                txtInvestments.append(team[teamNumber].getTeamName() + " sold @$" +lotCost+"\n");
    private double total = 0;
    private double balance = 20000;
    private double investments = 0;Unfortunately when I run the program the updates arn't showing because I have a list showing the bought prices and the sold prices and can see that there should be a difference in the total but it does not show up and simply keeps the balance at 20000?????

Like I mentioned I have a list that shows all the transactionstxtInvestments.append(team[teamNumber].getTeamName() + " sold @$" +lotCost+"\n");&txtInvestments.append(team[teamNumber].getTeamName() + " bought @$" +lotCost+"\n");This shows that the value being added or subtract from iwther investments or balance is changing. Somehow though the value i not changing the total. I have a variable(lotCost) that does change and is being printed. The total, balance and investments also get printed to the screenNumberFormat formatter = new DecimalFormat("0.00");
                String s = formatter.format(investments);
                lblInvestments.setText("$"+s);
                s = formatter.format(balance);
                lblBalance.setText("$"+s);
                s = formatter.format(total);
                lblTotal.setText("$"+s);
                downloadCounter++;
                System.out.println("Time " +downloadCounter+ ":" + new Timestamp(System.currentTimeMillis()));This shows that changes are occuring in all the proper places. I thnk you may be right in the fact that my maths is a bit skwang and this is what I kindly request you to help me with.
if(balance>lotCost){
                balance-=lotCost;
                investments+=lotCost;
                total=balance+investments;
                txtInvestments.append(team[teamNumber].getTeamName() + " bought @$" +lotCost+"\n");
if(team[teamNumber].Sell()){
                int pos = sellList.getModel().getSize();
                sellModel.add(pos,buyModel.getElementAt(index));
                buyModel.remove(index);
                double lotCost=10*team[teamNumber].getCurrentPrice();
                balance+=lotCost;
                investments-=lotCost;
                total=balance+investments;
                txtInvestments.append(team[teamNumber].getTeamName() + " sold @$" +lotCost+"\n");
            }I think the problem is in the italized part but I can't seem to pin point the little monster.:
Buy:
balance-=lotCost;
investments+=lotCost;
total=balance+investments;
Sell:
balance+=lotCost;
investments-=lotCost;
total=balance+investments;

Similar Messages

  • HT201209 If I have redeemed my my gift and the balance is updated in the App Store and I still can not down load apps...what could the issue be?  I keep getting this error message "Your Purchase Could Not Be Completed". Then it refers me to apple support.

    If I have redeemed my my gift and the balance is updated in the App Store and I still can not down load apps...what could the issue be?  I keep getting this error message "Your Purchase Could Not Be Completed". Then it refers me to apple support.

    If you haven't already contacted iTunes Support then you can do so via this link and ask them why the message is appearing (we are fellow users here on these forums, we won't know why) : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption

  • Redeemed an itunes card, when i go to purchase a song it keeps asking me for my credit card.  Do I need to have a credit card on my account before it will let me use the balance in my account?

    I have just redeemed an iTunes card and I show a balance beside my name in iTunes store.  When I click on the song it keeps asking me for my credit card instead of using the balance in my account. 

    Hi Joycekk,
    If you have a question about the billing process on the iTunes Store, you may find the following article helpful:
    iTunes Store: How iTunes Store purchases are billed
    http://support.apple.com/kb/HT5582
    Regards,
    - Brenden

  • I created my Apple ID in Ireland, but would now like to switch to a German Apple ID, keeping the same email address. How do I delete my old Irish Apple ID, so I can create a new German one with the same email?

    I created my Apple ID in Ireland, but would now like to switch to a German Apple ID, keeping the same email address. How do I delete my old Irish Apple ID, so I can create a new German one with the same email?

    Welcome to the Apple Community.
    Click on your account name in the top right corner of the iTunes store in the iTunes application on your computer, enter your password and click the "view account" button. Navigate to the Apple ID summary where you have the option to "change country or region".
    In order to change your location, you will need a credit card registered to an address in the location you are trying to change to.
    You cannot change your location if you have credit on your account, if you are unable to spend your credit and leave a balance of zero, contact Apple, which you can do through iTunes Store Support.

  • Purchased Itunes card..Have balance on my itunes account but trying to use the balance for an APP game...how do i transfer the funds ?

    I had a itunes card purchased for me...I redeemed it on my iphone in the Itunes APP...shows it was redeemed succesfully.Want to use the balance for an APP game i have....SImpsons Tapped out...hoe do i transfer it to it . it keeps using my credit card for purchasing premium items...how do i fix this to the itunes balance...thanks

    So then put any sim card in and restore it.  this isn't rocket science

  • How do I tell iTunes to use the balance in a gift card to purchase music instead of charging my credit card?

    I'm trying to use the balance from a gift card to buy music for my iTouch, but the system keeps trying to charge my credit card.   How do I use my balance???

    http://support.apple.com/kb/HT1364
    http://support.apple.com/kb/HT1203
    http://docs.info.apple.com/article.html?path=iTunesWin/9.0/en/27554.html
    This is the best guide:
    http://www.ilounge.com/index.php/articles/comments/moving-your-itunes-library-to -a-new-hard-drive

  • How can I keep the links between pages in a PDF file after the file has been saved?

    My accounting department has just starting using Adobe Acrobat XI Standard to make our account reconciliations.  I like that we can create links between one page and the next, so that we can show our supervisor where the account balances tie to the supporting documentation.  But I have noticed the links disappear after my supervisor reviews and signs the PDF file.  Is there a way we can keep the links after it is signed?  Please note that we are not using EchoSign, just the “place signature” function in Acrobat.

    When a document is signed, the signer has the option of locking the document. The links won't be active if the document is locked, so to avoid this, instruct the signer not to lock when signing.

  • HT5035 i have a gift card , trying to find out the balance i have the card number but don't have a pin number

    i am trying to find out the balance of a itunes gift card but it is asking for a pin number but there doesn't appear to have one on the card.
    i entered the number on the back of the card but it keeps saying to enter a pin number
    can you help?

    Hello Kelleyfromon
    Look for the area to scratch off for the pin number. If you do not see it, then check out the article below for some troubleshooting options to help you out.
    If you can't redeem your iTunes Gift Card or code
    http://support.apple.com/kb/HT6021
    Regards,
    -Norm G.  

  • Importing Canon Picture Styles into Aperture (how to keep the metadata) RAW

    I have a Canon 30D. Often I use the picture styles settings to shoot Monochromes. When I bring them up in Aperture to import they read as Monochromes (they are RAW) and as soon as I import them....Aperture strips it. This is pretty frustrating when I have a shoot of 300 images and 85 of them are black and whites. Canon software keeps the settings if I use their software, but i'm building an Aperture Library.
    Does anyone have a fix around this?

    Although I don't know for sure, it is possible that Canon Picture Styles are not in industry standard EXIF, and so they might be a Canon private format only readable by Canon software. If that is the case, there isn't much Apple can do but reach some kind of deal with Canon. Apple may or may not want to go to the trouble, because they might not want to also support the private data in other manufacturers' private raw data, like Nikon's encrypted white balance.
    It's worth noting that Adobe's software doesn't read Canon Picture Styles either; I've read posts asking about it on their forums too.
    Possibly worth noting most of all: The only advantage to shooting in monochrome is to be able to use the camera to visualize it. You can often get a better black-and-white by customizing the conversion from the original raw color data.

  • How the balance works for http/https in CSS?

    I want to understand how the balance works for http/https in the CSS.
    As per doc,
    - http/1.0=single URL per TCP connection
    - http/1.1=persistent connection.
    Q1. my understanding is http is stateless connection so needs TCP session for each URL. how the http/1.1 works with persistent. keep the same TCP session for a multiple URL request?
    Q2. https is using single URL and continue processing until terminate the https instead of open another URL in the middle of transaction. in this case, I think the client can stick into same service based on the assumption the CSS support persistent. if then, no advanced sticky(ex, srcip) required?
    Q3. looks below both are analogy. what's difference between them?
    - balance srcip(same src IP to the same service)
    - advanced-balance sticky-srcip
    Q4. what's balance decision mechanism for "balance roundrobin" to distribute evenly? ex, in case of multiple URL request coming from same client. evenly distribute URLs?
    Regards,

    Hello,
    first let me clarify 1 point.
    HTTP/HTTPS are standards that are defined in RFC.
    For HTTP/1.1 you can check the following RFC
    http://www.faqs.org/rfcs/rfc2616.html
    Therefore, the behavior of HTTP 1.1 is not defined by the CSS.
    Q1- HTTP/1.1 simply keeps 1 TCP connection to send a received mutiplie HTTP request/response.
    HTTP/1.0 will open 1 TCP connection for every HTTP request.
    Q2- HTTPS is just HTTP over SSL.
    So basically the same rule as above applies.
    HTTP/1.1 can use 1 SSL connection for many HTTP request/response while HTTP/1.0 will use 1 SSL connection for each HTTP request.
    Therefore, if you have customer using HTTP/1.0 you need some form of stickyness to guarantee that every connections will go to the same server.
    Even if only using HTTP/1.1 you may need stickyness.
    A user could disconnect and reconnect and require to be loadbalanced to the same server as before.
    Q3- There is a big different between balance srcip and sticky-srcip.
    The balance srcip simply hash the source ip address to find the destination server.
    The problem of this method is that the loadbalancing is not guarantee to be evenly distributed between the servers.
    With sticky-srcip, you use a normal balance method like round-robin, and then you create a sticky entry in a sticky table.
    Next time this user comes back we first check the sticky entry to find the destination server.
    The advantage is that it guarantess your users will be evenly distributed among the server.
    Q4- roundrobin is applied to connection - not url [by default].
    So if you have 2 users and they both open 1 connection, the CSS will send 1 connection to 2 different servers.
    So each server has 1 connection.
    If one user sens 10 URL and the other 1 sends only 1, one server will have 10 url to process while the other only one.
    That's if you are using HTTP/1.1 and use persistent mode on the CSS.
    You can break persistency and split the url.
    I run out of space and time to explain you everything.
    I suggest you go read the RFC or a book on HTTP.
    Also read the CSS configuration guide.
    There is much more you need to know if you want to take full advantage of the CSS like cookie, ssl offloading, L7 rules vs L3/4 rules, ...
    Regards,
    Gilles.

  • Can i use my Corp discount to buy a phone and pay the balance after discount thru Edge?

    Can i use my Corp discount to buy a phone and pay the balance after discount thru Edge?
    Are Corporate discounts usable against the full purchase price of the phone?
    How does Corporate discount work on More Everything Edge.

    Ok so another question are you going to pay full price up front for the phone, use Edge or do it on a subsidy? Also which model since they vary in price from $650-$950.
    Line fees on a More Everything plan are typically $40 per line.As I said being on Edge or being off contract would reduce that by $25 if you have a 10 GB data plan as you state you would. The 10 GB data portion is $100 but since your discount is 26% it will only cost $74.
    So to keep this simple until I get more info from you if you still had all 3 lines under contract, 3 smartphone lines and 10 GB with a 26% discount would be $194 a month before taxes and fees.
    Since you have 2 lines currently of contract, if you kept using your current phones or paid full price upfront for new phones you'd have 2 month2month discounts of $25 so that would drop your bill to $144 before taxes/fees
    If you bought the cheapest iPhone 6 on Edge your Edge payment would be $32.50 a month for 20 months. So for two iPhones 6es( assuming you got the cheapest one ) that would be $65. That would on top of the $144. So a total of $209

  • Am I able to keep a balance on my account for buying songs? I just bought 15 songs and I thought it would come off my credit card on file. But my card did not show a purchase. Could I still have some money left from agift card? How do I view my balance?

    Am I able to keep a balance on my account for buying songs? I just bought 15 songs and I thought it would come off my credit card on file. But my card did not show a purchase. Could I still have some money left from a gift card or a deposit
    ? How do I view my balance?

    Your balance should show to the left of account id at the top of the iTunes store page on your computer's iTunes. You can also check it by clicking on that id, or doing Store > View My Account, which should show your account balance and let you view your payment info

  • How do I get loops to keep the effect settings I hear when previewing?

    When I place loops into a new track, the effects settings go away and it is simply a dry signal. How can I move a loop from the browser into a new track and have it keep the effects settings that I hear when I preview the loop?

    If you drag a green MIDI loop onto the Arrange window space, it should create a Software instrument track with all the required plug-ins for the sound, so don't drag it to an already existing Software instrument track.
    If you drag it to an audio track it will convert it to an audio file, so obviously the instrument/fx plug-ins wont be in the channel strip.
    If that's what you mean?

  • How to keep the same cost in Sales order and return order?

    Hi experts,
    When I create a sales order with item cost 100 USD.
    Then the cost of item changed and down to 90 USD.
    When I do goods return refer to the sales order. How can I keep the same cost (VPRS) 100 USD but not 90 USD?
    I made a test the cost in sales order is 100 USD but 90 USD in return sales order.
    I want the cost in return sales order is 100 USD.
    How can I do?
    Thanks,
    Lance

    Hi,
    Let me tell u my understanding of your requirement, after the sales the cost of the item is changed to some thing low than it was in sales order or invoice, in this scenario you need to transfer the cost of the material as it is in the sale order or invoice (which you are taking as reference to create a Return Order), am i right?
    If so, you can proceed like this.
    In the copy controls of Billing to Sales orders ( F2 to RE) we have the pricing type N assigned to it ( Transfer pricing components unchanged, New Cost) here the system is reading the change of the cost again from the material master. if you don' t want it to read the material master data again we can have a change try with pricing type 'D'  (Copy Pricing elements unchanged), and try now.
    let me know the result.
    hope this will solve your problem.

  • Is it wise to keep the Nikon camera files "DSC's"  after downloading them and converting to DNG files via Adobe converter for lightroom use. In other words do the DNG files have all the raw data I would ever need in processing or should I save the camera'

    Is it wise to keep the Nikon camera files "DSC's"  after downloading them and converting to DNG files via Adobe converter for lightroom use. In other words do the DNG files have all the raw data I would ever need in processing or should I save the camera's DSC files?

    DNG files do not contain some metadata supplied by the camera, which can be used by the manufacturer's software. Thus, if you don't keep the original Raw photo, you will lose this information.
    If your 1000% sure you're never going to use the manufacturer's software, then this isn't a problem. But who can be sure what software you will be using 10 years from now?

Maybe you are looking for

  • Data source problem

    Hi, iam able to see this error while testing a datasource,on one of the RAC node ,while the remaining RAC nodes are working,can any one please tell me is there anything to be done on weblogic side. weblogic.common.ResourceException: Could not create

  • Curious: How does "Save for Web" reduce the file size?

    I do know HOW TO USE "Save for web" -- no questions there. I'm wanting to understand better what's going on under the hood. When I start with say, an 8x10 JPG at 300 dpi, I understand completely how bringing that down to 72 dpi yields a much smaller

  • Wireframe Components list smaller than Flash Builder Components list?

    Hi All, I noticed that in Flash Catalyst the WIREFRAME COMPONENTS tab only has a limited set of components (Button, Checkbox, Data List, HScrollbar, HSlider, Radio Button, Text Input, Toggle Button, VScrollbar, VSlider). Flash Builder, on the other h

  • Does OWB creates CWM2 for OLAP/BI

    The environment is: Personal Oracle9i Release 9.2.0.3.0 - Production With the Partitioning, OLAP and Oracle Data Mining options JServer Release 9.2.0.3.0 - Production JDev 9.0.3.1035 I managed to run the OLAP/BI Beans tutorials. So, I am now ready to

  • Opteron VS A64 Performance

    I am totally happy with my Athlon 64 3000+ but as a hard core enthusiast, I have been thinking of moving to a dual opteron setup. comparable clock speed opterons are extremely high but I am sure a slower running opteron can provide the same performan