Package intrade.entities

Examples of intrade.entities.Contract


      } else if (nd_name.equals("expiryPrice")) {
        contract_expiryPrice = nd.getTextContent();
      }
    }

    Contract con = new Contract(contract_id, eventid, contract_name, contract_symbol, contract_totalVolume,
        contract_ccy, contract_inRunning, contract_state, contract_tickSize, contract_tickValue, contract_type, start,
        end);

    if (contract_expiryDate != null) {
      con.setExpiryDate(Long.parseLong(contract_expiryDate));
    }

    if (contract_expiryPrice != null) {
      con.setExpiryPrice(Double.parseDouble(contract_expiryPrice));
    }

    return con;
  }
View Full Code Here


  private long storeContracts(Node contract, String eventid, Long start, Long end) {

    long now = (new Date()).getTime();

    Contract con = parseContract(contract, eventid, start, end);

    PersistenceManager pm = PMF.get().getPersistenceManager();
    Contract stored_contract = null;

    try {
      stored_contract = pm.getObjectById(Contract.class, Contract.generateKeyFromID(con.getId()));
    } catch (Exception e) {
      stored_contract = null;
View Full Code Here

      // lastFetchedCSV

    }

    PersistenceManager pm = PMF.get().getPersistenceManager();
    Contract stored_con = pm.getObjectById(Contract.class, Contract.generateKeyFromID(contractid));
    if (setArchive) {
      stored_con.setArchived(true);
    } else {
      stored_con.setArchived(false);
    }
    Long now = (new Date()).getTime();
    if (fetchedCSV) {
      stored_con.setLaststoredCSV(now);
    }
    if (setArchive) {
      print("Processed and archived contract:" + stored_con.toString());
    } else {
      print("Processed (but not archived) contract:" + stored_con.toString());
    }
    pm.close();

    return true;
  }
View Full Code Here

    return true;
  }

  private Blob storeCSVfile(String id) {

    Contract c = null;

    PersistenceManager pm = PMF.get().getPersistenceManager();

    c = pm.getObjectById(Contract.class, Contract.generateKeyFromID(id));
    c.debug_setResponse(r);
    if (c.fetchCSV()) {
      print("Fetched CSV for contract " + id);
    }
    pm.close();

    return (c != null) ? c.getFileCSV() : null;

  }
View Full Code Here

    // stop here...
    if (contractsCP.contains("There is no data for download."))
      return true;

    PersistenceManager pm = PMF.get().getPersistenceManager();
    Contract c = pm.getObjectById(Contract.class, Contract.generateKeyFromID(contractid));
    Integer limit = c.getLastLineInsertedCSV();
    pm.close();

    if (limit == null)
      limit = 0;

    String[] entries = contractsCP.split("\n");

    if (entries.length > 2)
      print("Adding " + (entries.length - 1) + "entries, starting from " + limit + ", for contract " + contractid);

    ArrayList<ContractClosingPriceCSV> prices = new ArrayList<ContractClosingPriceCSV>();
    for (int i = limit; i < entries.length; i++) {
      if (entries[i].startsWith("Date"))
        continue;

      ContractClosingPriceCSV cp = parseContractClosingPriceCSV(entries[i], contractid);
      prices.add(cp);

      // Every 50 added prices, persist, update contract, and flush...

      if (i % 50 == 0) {
        pm = PMF.get().getPersistenceManager();
        pm.makePersistentAll(prices);
        Contract con = pm.getObjectById(Contract.class, Contract.generateKeyFromID(contractid));
        con.setLastLineInsertedCSV(i);
        pm.close();
        prices = new ArrayList<ContractClosingPriceCSV>();

      }

    }

    pm = PMF.get().getPersistenceManager();
    pm.makePersistentAll(prices);
    Contract con = pm.getObjectById(Contract.class, Contract.generateKeyFromID(contractid));
    con.setLastLineInsertedCSV(entries.length - 1);
    pm.close();

    return true;
  }
View Full Code Here

      return true;

    }

    PersistenceManager pm = PMF.get().getPersistenceManager();
    Contract stored_con = pm.getObjectById(Contract.class, Contract.generateKeyFromID(contractid));

    Long now = (new Date()).getTime();
    if (fetchedTrades) {
      stored_con.setLastretrievedTrades(now);
    }

    pm.close();

    return true;
View Full Code Here

    return true;
  }

  private Blob storeTradesfile(String id) {

    Contract c = null;

    PersistenceManager pm = PMF.get().getPersistenceManager();

    c = pm.getObjectById(Contract.class, Contract.generateKeyFromID(id));
    c.debug_setResponse(r);
    if (c.fetchTrades()) {
      print("Fetched Trades for contract " + id);
    }
    pm.close();

    return (c != null) ? c.getFileTrades() : null;

  }
View Full Code Here

    }

    PersistenceManager pm = PMF.get().getPersistenceManager();
    pm.makePersistentAll(prices);
    Contract con = pm.getObjectById(Contract.class, Contract.generateKeyFromID(contractid));
    con.setLastUTCInsertedTrades(lastUTC);
    pm.close();

    return true;
  }
View Full Code Here

      } else if (nd_name.equals("expiryPrice")) {
        contract_expiryPrice = nd.getTextContent();
      }
    }

    Contract con = new Contract(contract_id, eventid, contract_name, contract_symbol, contract_totalVolume,
        contract_ccy, contract_inRunning, contract_state, contract_tickSize, contract_tickValue, contract_type, start,
        end);

    if (contract_expiryDate != null) {
      con.setExpiryDate(Long.parseLong(contract_expiryDate));
    }

    if (contract_expiryPrice != null) {
      con.setExpiryPrice(Double.parseDouble(contract_expiryPrice));
    }

    return con;
  }
View Full Code Here

  private long storeContracts(Node contract, String eventid, Long start, Long end) {

    long now = (new Date()).getTime();

    Contract con = parseContract(contract, eventid, start, end);

    PersistenceManager pm = PMF.get().getPersistenceManager();
    Contract stored_contract = null;

    try {
      stored_contract = pm.getObjectById(Contract.class, Contract.generateKeyFromID(con.getId()));
    } catch (Exception e) {
      stored_contract = null;
View Full Code Here

TOP

Related Classes of intrade.entities.Contract

Copyright © 2018 www.massapicom. 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.