本文整理汇总了C#中SmartQuant.Instrument类的典型用法代码示例。如果您正苦于以下问题:C# Instrument类的具体用法?C# Instrument怎么用?C# Instrument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Instrument类属于SmartQuant命名空间,在下文中一共展示了Instrument类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Subscribe
public override void Subscribe(Instrument instrument)
{
if (instrument.Parent != null)
{
this.strategyBySynthInstrument[instrument.Id] = this.strategyBySynthInstrument[instrument.Parent.Id];
this.strategyBySynthInstrument[instrument.Id].OnSubscribe(instrument);
return;
}
SellSideInstrumentStrategy sellSideInstrumentStrategy = (SellSideInstrumentStrategy)Activator.CreateInstance(base.GetType(), new object[]
{
this.framework,
string.Concat(new object[]
{
base.Name,
"(",
instrument,
")"
})
});
this.SetupStrategy(sellSideInstrumentStrategy);
sellSideInstrumentStrategy.Instrument = instrument;
this.strategyBySynthInstrument[instrument.Id] = sellSideInstrumentStrategy;
sellSideInstrumentStrategy.OnSubscribe(instrument);
sellSideInstrumentStrategy.dataProvider = base.DataProvider;
sellSideInstrumentStrategy.executionProvider = base.ExecutionProvider;
sellSideInstrumentStrategy.raiseEvents = true;
base.AddStrategy(sellSideInstrumentStrategy, false);
sellSideInstrumentStrategy.OnStrategyStart();
}
开发者ID:ForTrade,项目名称:CSharp,代码行数:29,代码来源:SellSideInstrumentStrategy.cs
示例2: GetData_Instrument
// 从分类好的目录中取中所有合约
private SortedDictionary<int, FileInfo> GetData_Instrument(Instrument inst)
{
SortedDictionary<int, FileInfo> resultList = new SortedDictionary<int, FileInfo>();
if (string.IsNullOrEmpty(DataPath_Instrument))
return resultList;
// 直接查找某一目录是否存在
string instrument = inst.Symbol;
int i = inst.Symbol.IndexOf('.');
if(i>=0)
{
instrument = instrument.Substring(0,i);
}
var di = new DirectoryInfo(DataPath_Instrument);
if (!di.Exists)
return resultList;
var list = di.GetDirectories(instrument, System.IO.SearchOption.AllDirectories);
foreach(var l in list)
{
UnionAndUpdate(resultList, GetFiles(l, inst.Symbol));
}
return resultList;
}
开发者ID:kandsy,项目名称:QuantBox.DataSimulator,代码行数:29,代码来源:ProtobufDataZeroReader.cs
示例3: HistoricalDataRequest
public HistoricalDataRequest(Instrument instrument, DateTime dateTime1, DateTime dateTime2, byte dataType)
{
this.Instrument = instrument;
this.DateTime1 = dateTime1;
this.DateTime2 = dateTime2;
this.DataType = dataType;
}
开发者ID:hack1t,项目名称:SmartQuant.dll,代码行数:7,代码来源:HistoricalDataRequest.cs
示例4: BarFactoryItem
protected BarFactoryItem(Instrument instrument, BarType barType, long barSize)
{
this.factory = null;
this.instrument = instrument;
this.barType = barType;
this.barSize = barSize;
}
开发者ID:ForTrade,项目名称:CSharp,代码行数:7,代码来源:BarFactoryItem.cs
示例5: OnInit
protected override void OnInit()
{
this.instrument = (Instrument) this.args[0];
this.InitDataSeriesList();
this.InitDataSeriesViewer();
this.Text = string.Format("Data [{0}]", (object) this.instrument.Symbol);
}
开发者ID:fastquant,项目名称:fastquant.dll,代码行数:7,代码来源:InstrumentData.cs
示例6: Read
public override object Read(BinaryReader reader)
{
reader.ReadByte();
int id = reader.ReadInt32();
InstrumentType type = (InstrumentType)reader.ReadByte();
string symbol = reader.ReadString();
string description = reader.ReadString();
byte currencyId = reader.ReadByte();
string exchange = reader.ReadString();
Instrument instrument = new Instrument(id, type, symbol, description, currencyId, exchange);
instrument.tickSize = reader.ReadDouble();
instrument.maturity = new DateTime(reader.ReadInt64());
instrument.factor = reader.ReadDouble();
instrument.strike = reader.ReadDouble();
instrument.putcall = (PutCall)reader.ReadByte();
instrument.margin = reader.ReadDouble();
int num = reader.ReadInt32();
for (int i = 0; i < num; i++)
{
AltId altId = new AltId();
altId.providerId = reader.ReadByte();
altId.symbol = reader.ReadString();
altId.exchange = reader.ReadString();
instrument.altId.Add(altId);
}
return instrument;
}
开发者ID:ForTrade,项目名称:CSharp,代码行数:27,代码来源:InstrumentStreamer.cs
示例7: Subscribe
public void Subscribe(IDataProvider provider, Instrument instrument)
{
if (provider.Status != ProviderStatus.Connected)
{
provider.Connect();
}
Dictionary<Instrument, int> dictionary = null;
if (!this.subscriptions.TryGetValue((int)provider.Id, out dictionary))
{
dictionary = new Dictionary<Instrument, int>();
this.subscriptions[(int)provider.Id] = dictionary;
}
int num = 0;
bool flag = false;
if (!dictionary.TryGetValue(instrument, out num))
{
flag = true;
num = 1;
}
else
{
if (num == 0)
{
flag = true;
}
num++;
}
dictionary[instrument] = num;
if (flag)
{
provider.Subscribe(instrument);
}
}
开发者ID:ForTrade,项目名称:CSharp,代码行数:33,代码来源:SubscriptionManager.cs
示例8: ImportTask
public ImportTask(Instrument instrument)
{
this.Instrument = instrument;
this.State = ImportTaskState.Pending;
this.Count = 0;
this.TotalNum = 0;
this.Message = string.Empty;
}
开发者ID:fastquant,项目名称:fastquant.dll,代码行数:8,代码来源:ImportTask.cs
示例9: textBox_Instrument_Validating
private void textBox_Instrument_Validating(object sender, CancelEventArgs e)
{
Instrument = SmartQuant.Shared.Global.Framework.InstrumentManager.Get((sender as TextBox).Text);
errorProvider1.Clear();
if (Instrument == null)
{
errorProvider1.SetError(textBox_Instrument,"合约不存在");
}
}
开发者ID:kandsy,项目名称:DemoDock,代码行数:9,代码来源:ChangePositionForm.cs
示例10: Delete
public void Delete(Instrument instrument)
{
this.instruments.Remove(instrument);
if (this.server != null && instrument.isPersistent)
{
this.server.Delete(instrument);
}
this.framework.eventServer.OnInstrumentDeleted(instrument);
}
开发者ID:ForTrade,项目名称:CSharp,代码行数:9,代码来源:InstrumentManager.cs
示例11: GetById
public Instrument GetById(int id)
{
Instrument instrument = this.instruments.GetById(id);
if (instrument == null)
{
instrument = new Instrument(id, InstrumentType.Synthetic, Guid.NewGuid().ToString(), "", 1);
this.instruments.Add(instrument);
}
return instrument;
}
开发者ID:ForTrade,项目名称:CSharp,代码行数:10,代码来源:InstrumentManager.cs
示例12: InstrumentViewItem
public InstrumentViewItem(Instrument instrument)
: base(new string[5])
{
this.Instrument = instrument;
this.SubItems[0].Text = instrument.Symbol;
this.SubItems[1].Text = instrument.Type.ToString();
this.SubItems[2].Text = instrument.Exchange;
this.SubItems[3].Text = CurrencyId.GetName(instrument.CurrencyId);
this.SubItems[4].Text = instrument.Maturity == DateTime.MinValue ? string.Empty : instrument.Maturity.ToShortDateString();
}
开发者ID:fastquant,项目名称:fastquant.dll,代码行数:10,代码来源:InstrumentViewItem.cs
示例13: Order
public Order(IExecutionProvider provider, Instrument instrument, OrderType type, OrderSide side, double qty, double price = 0.0, double stopPx = 0.0, TimeInForce timeInForce = TimeInForce.Day, string text = "")
: this()
{
this.provider = provider;
this.instrument = instrument;
this.type = type;
this.side = side;
this.qty = qty;
this.price = price;
this.stopPx = stopPx;
this.timeInForce = timeInForce;
this.text = text;
this.portfolio = null;
}
开发者ID:ForTrade,项目名称:CSharp,代码行数:14,代码来源:Order.cs
示例14: Add
public void Add(Instrument instrument, bool save = true)
{
if (this.Contains(instrument.symbol))
{
throw new ApplicationException("Instrument with the same symbol is already present in the framework : " + instrument.symbol);
}
instrument.Id = this.next_id;
this.next_id++;
this.instruments.Add(instrument);
if (save && this.server != null)
{
this.server.Save(instrument);
}
this.framework.eventServer.OnInstrumentAdded(instrument);
}
开发者ID:ForTrade,项目名称:CSharp,代码行数:15,代码来源:InstrumentManager.cs
示例15: AddInstance
public void AddInstance(Instrument instrument, InstrumentStrategy strategy)
{
strategy.instruments.Add(instrument);
strategy.instrument = instrument;
strategy.raiseEvents = true;
strategy.dataProvider = this.dataProvider;
strategy.executionProvider = this.executionProvider;
this.Add(strategy);
if (base.Instruments.GetById(instrument.id) == null)
{
base.Instruments.Add(instrument);
}
strategy.status = StrategyStatus.Running;
strategy.OnStrategyStart();
}
开发者ID:ForTrade,项目名称:CSharp,代码行数:15,代码来源:InstrumentStrategy.cs
示例16: Stop
public Stop(Strategy strategy, Position position, DateTime time)
{
this.strategy = strategy;
this.position = position;
this.instrument = position.instrument;
this.qty = position.qty;
this.side = position.Side;
this.type = StopType.Time;
this.creationTime = strategy.framework.Clock.DateTime;
this.completionTime = time;
this.stopPrice = this.GetInstrumentPrice();
if (this.completionTime > this.creationTime)
{
strategy.framework.Clock.AddReminder(new Reminder(new ReminderCallback(this.OnClock), this.completionTime, null));
}
}
开发者ID:ForTrade,项目名称:CSharp,代码行数:16,代码来源:Stop.cs
示例17: OnBar
protected override void OnBar(Instrument instrument, Bar bar)
{
// Add bar to bar series.
Bars.Add(bar);
// Add bar to group.
Log(bar, barsGroup);
// Add upper bollinger band value to group.
if (bbu.Count > 0)
Log(bbu.Last, bbuGroup);
// Add lower bollinger band value to group.
if (bbl.Count > 0)
Log(bbl.Last, bblGroup);
// Add simple moving average value bands to group.
if (sma.Count > 0)
Log(sma.Last, smaGroup);
// Calculate performance.
Portfolio.Performance.Update();
// Add equity to group.
Log(Portfolio.Value, equityGroup);
// Check strategy logic.
if (!HasPosition(instrument))
{
if (bbu.Count > 0 && bar.Close >= bbu.Last)
{
Order enterOrder = SellOrder(Instrument, Qty, "Enter");
Send(enterOrder);
}
else if (bbl.Count > 0 && bar.Close <= bbl.Last)
{
Order enterOrder = BuyOrder(Instrument, Qty, "Enter");
Send(enterOrder);
}
}
else
UpdateExitLimit();
}
开发者ID:fastquant,项目名称:fastquant.dll,代码行数:43,代码来源:Backtest.cs
示例18: Add
public void Add(Instrument instrument, BarType barType, long barSize)
{
BarFactoryItem item;
switch (barType)
{
case BarType.Time:
item = new TimeBarFactoryItem(instrument, barSize);
break;
case BarType.Tick:
item = new TickBarFactoryItem(instrument, barSize);
break;
case BarType.Volume:
item = new VolumeBarFactoryItem(instrument, barSize);
break;
default:
throw new ArgumentException(string.Format("Unknown bar type - {0}", barType));
}
this.Add(item);
}
开发者ID:ForTrade,项目名称:CSharp,代码行数:19,代码来源:BarFactory.cs
示例19: GetHistoricalTrades
public TickSeries GetHistoricalTrades(IHistoricalDataProvider provider, Instrument instrument, DateTime dateTime1, DateTime dateTime2)
{
HistoricalDataRequest request = new HistoricalDataRequest(instrument, dateTime1, dateTime2, 4);
provider.Send(request);
this.handle = new ManualResetEventSlim(false);
this.handle.Wait();
TickSeries tickSeries = new TickSeries("");
if (this.historicalData != null)
{
foreach (HistoricalData current in this.historicalData)
{
DataObject[] objects = current.Objects;
for (int i = 0; i < objects.Length; i++)
{
DataObject dataObject = objects[i];
tickSeries.Add((Trade)dataObject);
}
}
}
this.historicalData = null;
return tickSeries;
}
开发者ID:ForTrade,项目名称:CSharp,代码行数:22,代码来源:DataManager.cs
示例20: GetApi_Symbol_Exchange_TickSize
// 得到API中的合约名与交易所
private void GetApi_Symbol_Exchange_TickSize(Instrument instrument,
out string altSymbol, out string altExchange,
out string apiSymbol, out string apiExchange,
out double apiTickSize)
{
// 取合约别名
altSymbol = instrument.GetSymbol(this.id);
altExchange = instrument.GetExchange(this.id);
apiTickSize = instrument.TickSize;
// 取合约在API中的名字
apiSymbol = altSymbol;
apiExchange = altExchange;
InstrumentField _Instrument;
if (_dictInstruments.TryGetValue(altSymbol, out _Instrument))
{
apiSymbol = _Instrument.InstrumentID;
apiExchange = _Instrument.ExchangeID;
apiTickSize = _Instrument.PriceTick;
}
}
开发者ID:ForTrade,项目名称:QuantBox.APIProvider,代码行数:23,代码来源:SingleProvider.Other.cs
注:本文中的SmartQuant.Instrument类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论