Examples of OTAPI_Func


Examples of com.moneychanger.core.util.OTAPI_Func

        if (!Utility.VerifyStringVal(pubKey)) {
            System.out.println("proposePaymentPlan - OT_API_LoadUserPubkey returned null for recipient nym:" + recepientNymID);
            return false;
        }

        OTAPI_Func theRequest = new OTAPI_Func(OTAPI_Func.FT.SEND_USER_INSTRUMENT, serverID, senderNymID, recepientNymID, pubKey, plan);
        System.out.println(" theRequest :" + theRequest);

        String strResponse = theRequest.SendRequest(theRequest, "SEND_USER_INSTRUMENT");
        System.out.println(" strResponse:" + strResponse);

        if (Utility.VerifyStringVal(strResponse)) {
            status = true;
        }
View Full Code Here

Examples of com.moneychanger.core.util.OTAPI_Func

public class Market {

    public static MarketTicker getTicker(String marketID, String serverID, String nymID) {

        // ----------------------------------------------------------
        OTAPI_Func theRequest = new OTAPI_Func(OTAPI_Func.FT.GET_MARKET_LIST, serverID, nymID);
        String strResponse = OTAPI_Func.SendRequest(theRequest, "GET_MARKET_LIST");

        if (!Utility.VerifyStringVal(strResponse)) {
            System.out.println("IN getTicker: OTAPI_Func.SendRequest(() failed. (I give up.) ");
            return null;
View Full Code Here

Examples of com.moneychanger.core.util.OTAPI_Func

    public static Map loadMarketList(String serverID, String nymID) throws InterruptedException {
//DEBUGGING 3rd step of debugging.
        Map marketListMap = new HashMap();

        // ----------------------------------------------------------
        OTAPI_Func theRequest = new OTAPI_Func(OTAPI_Func.FT.GET_MARKET_LIST, serverID, nymID);
        String strResponse = OTAPI_Func.SendRequest(theRequest, "GET_MARKET_LIST");

        if (!Utility.VerifyStringVal(strResponse)) {
            System.out.println("IN loadMarketList: OTAPI_Func.SendRequest(() failed. (I give up.) ");
            return null;
View Full Code Here

Examples of com.moneychanger.core.util.OTAPI_Func

    public static boolean createOrder(String serverID, String nymID, String assetTypeID, String assetAcctID, String currencyTypeID, String currencyAcctID,
            String scale, String minIncrement, String quantity, String price, int selling) {

        // ----------------------------------------
        OTAPI_Func theRequest = new OTAPI_Func(OTAPI_Func.FT.CREATE_MARKET_OFFER, serverID, nymID, assetTypeID, assetAcctID, currencyTypeID, currencyAcctID,
                scale, minIncrement, quantity, price, selling == 1 ? true : false, new String("86400")); // 86400 seconds == 1 day. TODO: Allow the USER to select the length for the offer...
       
        String strResponse = OTAPI_Func.SendTransaction(theRequest, "CREATE_MARKET_OFFER");

        if (!Utility.VerifyStringVal(strResponse)) {
View Full Code Here

Examples of com.moneychanger.core.util.OTAPI_Func

    public static boolean cancelOrder(String serverID, String nymID, String assetAccountID, String transactionID) {

        // ----------------------------------------
        System.out.println(serverID+" .. "+nymID+" .. "+assetAccountID+" .. "+transactionID);
        OTAPI_Func theRequest = new OTAPI_Func(OTAPI_Func.FT.CANCEL_MARKET_OFFER, serverID, nymID, assetAccountID, transactionID);
        String strResponse = OTAPI_Func.SendTransaction(theRequest, "CANCEL_MARKET_OFFER");

        if (!Utility.VerifyStringVal(strResponse)) {
            System.out.println("IN cancelOrder: OTAPI_Func.SendTransaction(() failed. (I give up.) ");
            return false;
View Full Code Here

Examples of com.moneychanger.core.util.OTAPI_Func

    public static Map getNymOfferList(String serverID, String nymID) throws InterruptedException {

        Map nymOffersData = new HashMap();

        // ----------------------------------------------------------
        OTAPI_Func theRequest = new OTAPI_Func(OTAPI_Func.FT.GET_NYM_MARKET_OFFERS, serverID, nymID);
        String strResponse = OTAPI_Func.SendRequest(theRequest, "GET_NYM_MARKET_OFFERS");

        if (!Utility.VerifyStringVal(strResponse)) {
            System.out.println("IN getNymOfferList: OTAPI_Func.SendRequest(() failed. (I give up.) ");
            return null;
View Full Code Here

Examples of com.moneychanger.core.util.OTAPI_Func

                marketDetails.setNbrAsks(     !Utility.VerifyStringVal(marketData.getNumber_asks())  ? "" : marketData.getNumber_asks());
                marketDetails.setNbrBids(     !Utility.VerifyStringVal(marketData.getNumber_bids())  ? "" : marketData.getNumber_bids());
                marketDetails.setTotalAssets( !Utility.VerifyStringVal(marketData.getTotal_assets()) ? "" : marketData.getTotal_assets());

                // ----------------------------------------------------------
                OTAPI_Func theRequest = new OTAPI_Func(OTAPI_Func.FT.GET_MARKET_OFFERS, serverID, nymID, marketID, Configuration.getMarketMaxDepth());
                String strResponse = OTAPI_Func.SendRequest(theRequest, "GET_MARKET_OFFERS");

                if (!Utility.VerifyStringVal(strResponse)) {
                    System.out.println("IN getMarketDetails: OTAPI_Func.SendRequest(() failed. (I give up.) ");
                    return null;
                }
                // ----------------------------------------------------------

                if (otapiJNI.OTAPI_Basic_Message_GetDepth(strResponse) > 0) {

                    OfferListMarket offerListMarket = Helpers.getMarketOffer(serverID, marketID);

                    if (offerListMarket == null) {
                        System.out.println("getMarketDetails - offerListMarket returns null");
                        return null;
                    }
                    // ----------------------------------------------------
                    for (int j = 0; j < offerListMarket.GetAskDataCount(); j++) {
                        AskData askData = offerListMarket.GetAskData(j);
                        if (askData == null) {
                            continue;
                        }

                        String[] askRow = new String[4];

                        askRow[0] = askData.getPrice_per_scale();
                        askRow[1] = askData.getAvailable_assets();
                        askRow[3] = askData.getMinimum_increment();

                        try {
                            Long lScale = Long.valueOf(marketDetails.getGranularity());
                            Long lPrice = Long.valueOf(askRow[0]);    // this price is "per scale"
                            Long lQuantity = Long.valueOf(askRow[1]);    // Total overall quantity available
                            Long lScaleUnits = Long.valueOf(lQuantity / lScale);   // Number of scale units available in total quanity. (120 total at scale of 10, is 12 units.)
                            Long lTotalCost = Long.valueOf(lPrice * lScaleUnits); // // Total value of available units is price times scale units.
                            askRow[2] = String.valueOf(lTotalCost);    // At $5 per scale, at 12 units, is $60 total for 120 total assets. (The number 60 goes here, plus the currency symbol todo.)
//                          askRow[2] = String.valueOf(Double.parseDouble(askRow[0]) * Double.parseDouble(askRow[1]));

                        } catch (NumberFormatException nfe) {
                            nfe.printStackTrace();
                            System.out.println("getMarketDetails: Invalid number returned");
                            askRow[2] = "";
                        }

                        askGridData.put(askData.getTransaction_id(), askRow);
                    }
                    // ----------------------------------------------------
                    for (int j = 0; j < offerListMarket.GetBidDataCount(); j++) {
                        BidData bidData = offerListMarket.GetBidData(j);
                        if (bidData == null) {
                            continue;
                        }

                        String[] bidRow = new String[4];

                        bidRow[0] = bidData.getPrice_per_scale();
                        bidRow[1] = bidData.getAvailable_assets();
                        bidRow[3] = bidData.getMinimum_increment();

                        try {
                            Long lScale = Long.valueOf(marketDetails.getGranularity());
                            Long lPrice = Long.valueOf(bidRow[0]);    // this price is "per scale"
                            Long lQuantity = Long.valueOf(bidRow[1]);    // Total overall quantity available
                            Long lScaleUnits = Long.valueOf(lQuantity / lScale);   // Number of scale units available in total quanity. (120 total at scale of 10, is 12 units.)
                            Long lTotalCost = Long.valueOf(lPrice * lScaleUnits); // // Total value of available units is price times scale units.
                            bidRow[2] = String.valueOf(lTotalCost);    // At $5 per scale, at 12 units, is $60 total for 120 total assets. (The number 60 goes here, plus the currency symbol todo.)
//                          bidRow[2] = String.valueOf(Double.parseDouble(bidRow[0]) * Double.parseDouble(bidRow[1]));

                        } catch (NumberFormatException nfe) {
                            nfe.printStackTrace();
                            System.out.println("getMarketDetails: Invalid number returned");
                            bidRow[2] = "";
                        }

                        bidGridData.put(bidData.getTransaction_id(), bidRow);
                    }
                }
                // ----------------------------------------------------------
                OTAPI_Func theRequest2 = new OTAPI_Func(OTAPI_Func.FT.GET_MARKET_RECENT_TRADES, serverID, nymID, marketID);
                String strResponse2 = OTAPI_Func.SendRequest(theRequest2, "GET_MARKET_RECENT_TRADES");

                if (!Utility.VerifyStringVal(strResponse2)) {
                    System.out.println("IN getMarketDetails: OTAPI_Func.SendRequest(() failed. (I give up.) ");
                    return null;
                }
                // ----------------------------------------------------------

                if (otapiJNI.OTAPI_Basic_Message_GetDepth(strResponse2) > 0) {

                    TradeListMarket tradeListMarket = Helpers.getMarketTradeList(serverID, marketID);

                    if (tradeListMarket == null) {
                        System.out.println("getMarketDetails - tradeListMarket returns null");
                        return null;
                    }

                    for (int j = 0; j < tradeListMarket.GetTradeDataMarketCount(); j++) {
                        TradeDataMarket tradeDataMarket = tradeListMarket.GetTradeDataMarket(j);
                        if (tradeDataMarket == null) {
                            continue;
                        }

                        String[] tradeDataRow = new String[5];

                        tradeDataRow[2] = !Utility.VerifyStringVal(tradeDataMarket.getAmount_sold()) ? "" : tradeDataMarket.getAmount_sold();
                        tradeDataRow[4] = !Utility.VerifyStringVal(tradeDataMarket.getDate())        ? "" : tradeDataMarket.getDate();
                        System.out.println("tradeDataMarket.getDate():"+tradeDataMarket.getDate());
                        try {
                            tradeDataRow[4] = String.valueOf(new Date(Long.parseLong(tradeDataRow[4]) * 1000));

                        } catch (NumberFormatException nfe) {
                            nfe.printStackTrace();
                            System.out.println("Invalid number returned by timestmp:" + tradeDataRow[4]);
                            tradeDataRow[4] = "";
                        }

                        tradeDataRow[1] = !Utility.VerifyStringVal(tradeDataMarket.getPrice())          ? "" : tradeDataMarket.getPrice();
                        tradeDataRow[0] = !Utility.VerifyStringVal(tradeDataMarket.getTransaction_id()) ? "" : tradeDataMarket.getTransaction_id();

                        try {
                            Long lScale = Long.valueOf(marketDetails.getGranularity());
                            Long lPrice = Long.valueOf(tradeDataRow[1]);    // this price is "per scale"
                            Long lQuantity = Long.valueOf(tradeDataRow[2]);    // Total overall quantity available
                            Long lScaleUnits = Long.valueOf(lQuantity / lScale);   // Number of scale units available in total quanity. (120 total at scale of 10, is 12 units.)
                            Long lTotalCost = Long.valueOf(lPrice * lScaleUnits); // // Total value of available units is price times scale units.
                            tradeDataRow[3] = String.valueOf(lTotalCost);    // At $5 per scale, at 12 units, is $60 total for 120 total assets. (The number 60 goes here, plus the currency symbol todo.)
//                          tradeDataRow[3] = String.valueOf(Double.parseDouble(tradeDataRow[2]) * Double.parseDouble(tradeDataRow[1]));

                        } catch (NumberFormatException nfe) {
                            nfe.printStackTrace();
                            System.out.println("Invalid number returned by timestmp:" + tradeDataRow[3]);
                            tradeDataRow[3] = "";
                        }

                        tradeMarketData.add(tradeDataRow);
                    }
                }
                // ----------------------------------------------------------
                OTAPI_Func theRequest3 = new OTAPI_Func(OTAPI_Func.FT.GET_NYM_MARKET_OFFERS, serverID, nymID);
                String strResponse3 = OTAPI_Func.SendRequest(theRequest3, "GET_NYM_MARKET_OFFERS");

                if (!Utility.VerifyStringVal(strResponse3)) {
                    System.out.println("IN getMarketDetails: OTAPI_Func.SendRequest(() failed. (I give up.) ");
                    return null;
View Full Code Here

Examples of com.moneychanger.core.util.OTAPI_Func

            //Error;
        }

        // Then send the server message

        OTAPI_Func theRequest = new OTAPI_Func(OTAPI_Func.FT.QUERY_ASSET_TYPES, serverID, nymID, strEncodedObj);
        System.out.println(" theRequest :" + theRequest);

        String strResponse = theRequest.SendRequest(theRequest, "QUERY_ASSET_TYPES");
        System.out.println(" strResponse:" + strResponse);

        String strReplyMap = null;

        // When the server reply comes back, get the payload from it:
View Full Code Here

Examples of com.moneychanger.core.util.OTAPI_Func

            if (!Utility.VerifyStringVal(nymID)) {
                return "Popup Dialog";
            }

            OTAPI_Func theRequest = new OTAPI_Func(OTAPI_Func.FT.GET_CONTRACT, serverID, nymID, assetTypeID);
            String strResponse = OTAPI_Func.SendRequest(theRequest, "GET_CONTRACT");

            if (!Utility.VerifyStringVal(strResponse)) {
                System.out.println("IN getAssetTypeName: OTAPI_Func.SendRequest(() failed. (I give up.) ");
                return null;
View Full Code Here

Examples of com.moneychanger.core.util.OTAPI_Func

        if (!Utility.VerifyStringVal(otapiJNI.OTAPI_Basic_LoadAssetContract(assetTypeID))) {
            System.out.println("IN getAssetTypeName, OT_API_LoadAssetContract is null");

            // ----------------------------------------

            OTAPI_Func theRequest = new OTAPI_Func(OTAPI_Func.FT.GET_CONTRACT, serverID, nymID, assetTypeID);
            String strResponse = OTAPI_Func.SendRequest(theRequest, "GET_CONTRACT");

            if (!Utility.VerifyStringVal(strResponse)) {
                System.out.println("IN getAssetTypeName: OTAPI_Func.SendRequest(() failed. (I give up.) ");
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.