• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Contract类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.ib.client.Contract的典型用法代码示例。如果您正苦于以下问题:Java Contract类的具体用法?Java Contract怎么用?Java Contract使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Contract类属于com.ib.client包,在下文中一共展示了Contract类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: buildContract

import com.ib.client.Contract; //导入依赖的package包/类
public Contract buildContract(FuturesTicker ticker) {
    Contract contract = new Contract();
    contract.m_currency = ticker.getCurrency();
    contract.m_exchange = ticker.getExchange().getExchangeName();
    contract.m_secType = IbUtils.getSecurityType(ticker.getInstrumentType());
    contract.m_symbol = IbUtils.translateToIbFuturesSymbol( ticker.getSymbol() );
    contract.m_expiry = IbUtils.getExpiryString(ticker.getExpiryMonth(), ticker.getExpiryYear());
    
    ILocalSymbolBuilder localSymbolBuilder = LocalSymbolBuilderFactory.getLocalSymbolBuilder(ticker.getExchange());
    
    contract.m_localSymbol = localSymbolBuilder.buildLocalSymbol(ticker.getSymbol(), ticker.getExpiryMonth(), ticker.getExpiryYear());
    
    BigDecimal multiplier = IbUtils.getIbMultiplier(ticker);
    if (multiplier != null) {
        contract.m_multiplier = multiplier.toString();
    }

    return contract;

}
 
开发者ID:rterp,项目名称:SumZeroTrading,代码行数:21,代码来源:FuturesContractBuilder.java


示例2: testBuildContract_NoMultiplier

import com.ib.client.Contract; //导入依赖的package包/类
@Test
public void testBuildContract_NoMultiplier() {
    FuturesTicker ticker = new FuturesTicker();
    ticker.setCurrency("USD");
    ticker.setExchange(Exchange.GLOBEX);
    ticker.setSymbol("HG");
    ticker.setExpiryMonth(6);
    ticker.setExpiryYear(2015);

    Contract expected = new Contract();
    expected.m_currency = "USD";
    expected.m_exchange = Exchange.GLOBEX.getExchangeName();
    expected.m_secType = "FUT";
    expected.m_symbol = "HG";
    expected.m_expiry = "201506";
    expected.m_localSymbol = "HGM5";
    
    assertEquals(expected, builder.buildContract(ticker) );
}
 
开发者ID:rterp,项目名称:SumZeroTrading,代码行数:20,代码来源:FuturesContractBuilderTest.java


示例3: testBuildContract_WithMultiplier

import com.ib.client.Contract; //导入依赖的package包/类
@Test
public void testBuildContract_WithMultiplier() {
    FuturesTicker ticker = new FuturesTicker();
    ticker.setCurrency("USD");
    ticker.setExchange(Exchange.ECBOT);
    ticker.setSymbol("ZW");
    ticker.setExpiryMonth(6);
    ticker.setExpiryYear(2015);
    ticker.setContractMultiplier(new BigDecimal(50));

    Contract expected = new Contract();
    expected.m_currency = "USD";
    expected.m_exchange = Exchange.ECBOT.getExchangeName();
    expected.m_secType = "FUT";
    expected.m_symbol = "ZW";
    expected.m_expiry = "201506";
    expected.m_multiplier = "5000";
    expected.m_localSymbol = "ZW   JUN 15";
    
    assertEquals(expected, builder.buildContract(ticker) );
}
 
开发者ID:rterp,项目名称:SumZeroTrading,代码行数:22,代码来源:FuturesContractBuilderTest.java


示例4: NewContract

import com.ib.client.Contract; //导入依赖的package包/类
public NewContract( Contract c) {
	m_conid = c.m_conId;
	m_symbol = c.m_symbol;
	m_secType = c.m_secType == null ? SecType.None : SecType.valueOf( c.m_secType);
	m_expiry = c.m_expiry == null || c.m_expiry.equals( "0") ? "" : c.m_expiry;
	m_strike = c.m_strike;
	m_right = Right.get( c.m_right);
	m_multiplier = c.m_multiplier;
	m_exchange = c.m_exchange;
	m_primaryExch = c.m_primaryExch;
	m_currency = c.m_currency;
	m_localSymbol = c.m_localSymbol;
	m_tradingClass = c.m_tradingClass;
	m_secIdType = SecIdType.get( c.m_secIdType);
	m_secId = c.m_secId;
	m_underComp = c.m_underComp != null ? new DeltaNeutralContract( c.m_underComp.m_conId, c.m_underComp.m_delta, c.m_underComp.m_price) : null;

	m_comboLegs.clear();
	if (c.m_comboLegs != null) {
		for (ComboLeg leg : c.m_comboLegs) {
			m_comboLegs.add( new NewComboLeg( leg) );
		}
	}
}
 
开发者ID:rterp,项目名称:SumZeroTrading,代码行数:25,代码来源:NewContract.java


示例5: subscribeLevel1

import com.ib.client.Contract; //导入依赖的package包/类
@Override
public synchronized void subscribeLevel1(Ticker ticker, Level1QuoteListener listener) {
    super.subscribeLevel1(ticker, listener);
    Integer quoteId = tickerMap.get(ticker);
    if (quoteId == null) {
        quoteId = ++nextQuoteId;
        tickerMap.put(ticker, quoteId);
        idToTickerMap.put(quoteId, ticker);
        Contract contract = ContractBuilderFactory.getContractBuilder(ticker).buildContract(ticker);
        List<TagValue> list = new ArrayList<>();
        list.add(new TagValue("XYZ","XYZ"));
        ibConnection.reqMktData(nextQuoteId, contract, "", false, list);
    }

    if (closeQuoteMap.get(ticker) != null) {
        listener.quoteRecieved(closeQuoteMap.get(ticker));
    }

    if (openQuoteMap.get(ticker) != null) {
        listener.quoteRecieved(openQuoteMap.get(ticker));
    }

}
 
开发者ID:rterp,项目名称:SumZeroTrading,代码行数:24,代码来源:IBQuoteEngine.java


示例6: testSubscribeLevel1_alreadySubscribed

import com.ib.client.Contract; //导入依赖的package包/类
@Test
    @Ignore
    public void testSubscribeLevel1_alreadySubscribed() {
        final EClientSocket mockSocketInterface = mockery.mock(EClientSocket.class);
        final IBConnectionInterface mockConnectionInterface = mockery.mock(IBConnectionInterface.class);
        final Level1QuoteListener mockQuoteListener = mockery.mock(Level1QuoteListener.class);
        final Ticker ticker = new StockTicker("LUT");
        final int requestId = 1;
        final Contract contract = ContractBuilderFactory.getContractBuilder(ticker).buildContract(ticker);

 

//        IBQuoteEngine quoteEngine = new IBQuoteEngine(mockSocketInterface, mockConnectionInterface);
//        quoteEngine.tickerMap.put(ticker, requestId);
//        quoteEngine.subscribeLevel1(ticker, mockQuoteListener);
//        mockery.assertIsSatisfied();
        fail();
    }
 
开发者ID:rterp,项目名称:SumZeroTrading,代码行数:19,代码来源:IBQuoteEngineTest.java


示例7: testUnsubscribeLevel1_NoRequestIdFound

import com.ib.client.Contract; //导入依赖的package包/类
@Test
    @Ignore
    public void testUnsubscribeLevel1_NoRequestIdFound() {
        final EClientSocket mockSocketInterface = mockery.mock(EClientSocket.class);
        final IBConnectionInterface mockConnectionInterface = mockery.mock(IBConnectionInterface.class);
        final Level1QuoteListener mockQuoteListener = mockery.mock(Level1QuoteListener.class);
        final Ticker ticker = new StockTicker("LUT");
        final int requestId = 1;
        final Contract contract = ContractBuilderFactory.getContractBuilder(ticker).buildContract(ticker);

//        IBQuoteEngine quoteEngine = new IBQuoteEngine(mockSocketInterface, mockConnectionInterface);
//        quoteEngine.unsubscribeLevel1(ticker, mockQuoteListener);
//
//        assertNull( quoteEngine.tickerMap.get(ticker) );
//        assertNull( quoteEngine.idToTickerMap.get( requestId ) );
//
//        mockery.assertIsSatisfied();
        fail();
    }
 
开发者ID:rterp,项目名称:SumZeroTrading,代码行数:20,代码来源:IBQuoteEngineTest.java


示例8: NewContract

import com.ib.client.Contract; //导入依赖的package包/类
public NewContract( Contract c) {
	m_conid = c.m_conId;
	m_symbol = c.m_symbol;
	m_secType = c.m_secType == null ? SecType.None : SecType.valueOf( c.m_secType);
	m_expiry = c.m_expiry == null || c.m_expiry.equals( "0") ? "" : c.m_expiry;
	m_strike = c.m_strike;
	m_right = Right.get( c.m_right);
	m_multiplier = c.m_multiplier;
	m_exchange = c.m_exchange;
	m_currency = c.m_currency;
	m_localSymbol = c.m_localSymbol;
	m_tradingClass = c.m_tradingClass;
	m_primaryExch = c.m_primaryExch;
	m_secIdType = SecIdType.get( c.m_secIdType);
	m_secId = c.m_secId;
	m_underComp = c.m_underComp != null ? new DeltaNeutralContract( c.m_underComp.m_conId, c.m_underComp.m_delta, c.m_underComp.m_price) : null;

	m_comboLegs.clear();
	if (c.m_comboLegs != null) {
		for (ComboLeg leg : c.m_comboLegs) {
			m_comboLegs.add( new NewComboLeg( leg) );
		}
	}
}
 
开发者ID:singh-manish,项目名称:trading-indexFutureAndOptions,代码行数:25,代码来源:NewContract.java


示例9: getComboContractFromLegs

import com.ib.client.Contract; //导入依赖的package包/类
private Contract getComboContractFromLegs() {
	if (m_legRows.size() < 2) {
		return null;
	}

	LegRow leg = m_legRows.get( 0);

	Contract comboContract = new Contract();
	comboContract.secType( SecType.BAG);
	comboContract.currency( leg.m_contract.currency() );
	comboContract.exchange( "SMART");
	comboContract.symbol( "USD");

	for (LegRow row : m_legRows) {
		comboContract.comboLegs().add( row.m_leg);
	}

	return comboContract;
}
 
开发者ID:qerio,项目名称:goib,代码行数:20,代码来源:ComboPanel.java


示例10: onRecUnderDetails

import com.ib.client.Contract; //导入依赖的package包/类
protected void onRecUnderDetails(ArrayList<ContractDetails> list) {
	if (list.size() != 1) {
		ApiDemo.INSTANCE.show( "Error: " + list.size() + " underlying contracts returned");
		return;
	}
	
	// request option chains
	Contract optContract = new Contract();
	optContract.symbol( m_underContract.symbol() );
	optContract.currency( m_underContract.currency() );
	optContract.exchange( m_optExch.getText() );
	optContract.secType( SecType.OPT);
	
	final ChainPanel symbolPanel = new ChainPanel();
	m_tabbedPanel.addTab( optContract.symbol(), symbolPanel, true, true);
	
	ApiDemo.INSTANCE.controller().reqContractDetails( optContract, symbolPanel);
}
 
开发者ID:qerio,项目名称:goib,代码行数:19,代码来源:OptionChainsPanel.java


示例11: positionMulti

import com.ib.client.Contract; //导入依赖的package包/类
@Override
public void positionMulti(String account, String modelCode, Contract contract, double pos, double avgCost) {
	Integer key = contract.conid();
	PositionRow row = m_map.get( key);
	if (row == null) {
		row = new PositionRow();
		m_map.put( key, row);
		m_list.add( row);
	}
	row.update( account, modelCode, contract, pos, avgCost);
	
	if (m_complete) {
		m_model.fireTableDataChanged();
	}
	
}
 
开发者ID:qerio,项目名称:goib,代码行数:17,代码来源:AccountPositionsMultiPanel.java


示例12: onAdd

import com.ib.client.Contract; //导入依赖的package包/类
protected void onAdd() {
	Contract dn = new Contract();
	dn.symbol( m_symbol.getText().toUpperCase() ); 
	dn.secType( m_secType.getSelectedItem() ); 
	dn.lastTradeDateOrContractMonth( m_lastTradeDateOrContractMonth.getText() ); 
	dn.exchange( m_exchange.getText().toUpperCase() ); 
	dn.currency( m_currency.getText().toUpperCase() ); 
	
	ApiDemo.INSTANCE.controller().reqContractDetails(dn, new IContractDetailsHandler() {
		@Override public void contractDetails(ArrayList<ContractDetails> list) {
			if (list.size() == 1) {
			    Contract c = list.get( 0).contract();
				m_dnContract = new DeltaNeutralContract( c.conid(), m_delta.getDouble(), m_price.getDouble() );
				m_dnText.setText( String.format( "Delta-neutral: %s Delta: %s  Price: %s", c.description(), m_delta.getText(), m_price.getText() ) );
			}
			else {
				ApiDemo.INSTANCE.show( "DN description does not define a uniqe contract");
				m_dnContract = null;
				m_dnText.setText( null);
			}
		}
	});
}
 
开发者ID:qerio,项目名称:goib,代码行数:24,代码来源:ComboPanel.java


示例13: USStockAtSmart

import com.ib.client.Contract; //导入依赖的package包/类
public static Contract USStockAtSmart() {
	Contract contract = new Contract();
	contract.symbol("IBKR");
	contract.secType("STK");
	contract.currency("USD");
	contract.exchange("SMART");
	return contract;
}
 
开发者ID:qerio,项目名称:goib,代码行数:9,代码来源:ContractSamples.java


示例14: buildContract

import com.ib.client.Contract; //导入依赖的package包/类
public Contract buildContract(CurrencyTicker ticker) {
    
    Contract contract = new Contract();
    contract.m_currency = ticker.getCurrency();
    contract.m_exchange = ticker.getExchange().getExchangeName();
    contract.m_secType = IbUtils.getSecurityType( ticker.getInstrumentType() );
    contract.m_symbol = ticker.getSymbol();

    return contract;
}
 
开发者ID:rterp,项目名称:SumZeroTrading,代码行数:11,代码来源:CurrencyContractBuilder.java


示例15: OptionForQuery

import com.ib.client.Contract; //导入依赖的package包/类
public static Contract OptionForQuery() {
	//! [optionforquery]
	Contract contract = new Contract();
	contract.symbol("FISV");
	contract.secType("OPT");
	contract.currency("USD");
	contract.exchange("SMART");
	//! [optionforquery]
	return contract;
}
 
开发者ID:qerio,项目名称:goib,代码行数:11,代码来源:ContractSamples.java


示例16: buildContract

import com.ib.client.Contract; //导入依赖的package包/类
@Override
public Contract buildContract(CFDTicker ticker) {
    Contract contract = new Contract();
    contract.m_currency = ticker.getCurrency();
    contract.m_exchange = ticker.getExchange().getExchangeName();
    contract.m_secType = IbUtils.getSecurityType(ticker.getInstrumentType());
    contract.m_symbol = ticker.getSymbol();
    if (ticker.getPrimaryExchange() != null) {
        contract.m_primaryExch = ticker.getPrimaryExchange().getExchangeName();
    }
    return contract;
}
 
开发者ID:rterp,项目名称:SumZeroTrading,代码行数:13,代码来源:CFDContractBuilder.java


示例17: BZbroadtapeNewsFeed

import com.ib.client.Contract; //导入依赖的package包/类
public static Contract BZbroadtapeNewsFeed() {
	//! [newscontractbz]
	Contract contract = new Contract();
	contract.symbol("BZ:BZ_ALL"); //BroadTape All News
	contract.secType("NEWS");
	contract.exchange("BZ"); //Benzinga Pro
	//! [newscontractbz]
	return contract;
}
 
开发者ID:qerio,项目名称:goib,代码行数:10,代码来源:ContractSamples.java


示例18: buildContract

import com.ib.client.Contract; //导入依赖的package包/类
public Contract buildContract(OptionTicker ticker) {
    Contract contract = new Contract();
    contract.m_currency = ticker.getCurrency();
    contract.m_exchange = ticker.getExchange().getExchangeName();
    contract.m_secType = IbUtils.getSecurityType(ticker.getInstrumentType());
    contract.m_symbol = ticker.getSymbol();
    
    contract.m_expiry = IbUtils.getExpiryString(ticker.getExpiryDay(), ticker.getExpiryMonth(), ticker.getExpiryYear());
    contract.m_multiplier = ticker.getContractMultiplier().toString();
    contract.m_right = IbUtils.getOptionRight(ticker.getRight());
    contract.m_strike = ticker.getStrike().doubleValue();

    return contract;

}
 
开发者ID:rterp,项目名称:SumZeroTrading,代码行数:16,代码来源:OptionContractBuilder.java


示例19: testBuildContract_primaryExchange

import com.ib.client.Contract; //导入依赖的package包/类
@Test
public void testBuildContract_primaryExchange() {
    CFDTicker ticker = getTicker();
    ticker.setPrimaryExchange(Exchange.NASDAQ);
    CFDContractBuilder builder = new CFDContractBuilder();
    Contract contract = builder.buildContract(ticker);

    assertEquals( ticker.getCurrency(), contract.m_currency );
    assertEquals( ticker.getExchange().getExchangeName(), contract.m_exchange );
    assertEquals( ticker.getSymbol(), contract.m_symbol );
    assertEquals( InstrumentType.CFD,  ticker.getInstrumentType());
    assertEquals( ticker.getPrimaryExchange().getExchangeName(), contract.m_primaryExch );
}
 
开发者ID:rterp,项目名称:SumZeroTrading,代码行数:14,代码来源:CFDContractBuilderTest.java


示例20: openOrder

import com.ib.client.Contract; //导入依赖的package包/类
@Override public void openOrder(Contract contract, Order order, OrderState orderState) {
	OrderRow full = m_map.get( order.permId() );
	
	if (full != null) {
		full.m_order = order;
		full.m_state = orderState;
		fireTableDataChanged();
	}
	else if (shouldAdd(contract, order, orderState) ) {
		full = new OrderRow( contract, order, orderState);
		add( full);
		m_map.put( order.permId(), full);
		fireTableDataChanged();
	}
}
 
开发者ID:qerio,项目名称:goib,代码行数:16,代码来源:OrdersPanel.java



注:本文中的com.ib.client.Contract类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TaskReportPBImpl类代码示例发布时间:2022-05-22
下一篇:
Java Jooby类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap