1717using QuickFix . FIX42 ;
1818using QuickFix . Fields ;
1919using QuantConnect . Orders ;
20+ using System . Globalization ;
2021using QuantConnect . Securities ;
2122using QuantConnect . Securities . Equity ;
2223using QuantConnect . Brokerages . Fix . Connection ;
@@ -26,6 +27,7 @@ namespace QuantConnect.Brokerages.Wolverine
2627{
2728 public class WolverineOrderRoutingSessionHandler : MessageCracker , IFixOrdersController
2829 {
30+ private readonly SymbolPropertiesDatabase _symbolPropertiesDatabase = SymbolPropertiesDatabase . FromDataFolder ( ) ;
2931 private readonly Dictionary < string , string > _exchangeMapping = new ( ) {
3032 { Exchange . AMEX . Name , "AMEX" } ,
3133 { Exchange . ARCA . Name , "ARCA" } ,
@@ -74,7 +76,7 @@ public bool PlaceOrder(Order order)
7476 {
7577 var side = new Side ( order . Direction == OrderDirection . Buy ? Side . BUY : Side . SELL ) ;
7678
77- var ticker = _symbolMapper . GetBrokerageSymbol ( order . Symbol ) ;
79+ var ticker = _symbolMapper . GetBrokerageSymbol ( order . Symbol . HasUnderlying ? order . Symbol . Underlying : order . Symbol ) ;
7880 var securityType = new QuickFix . Fields . SecurityType ( _symbolMapper . GetBrokerageSecurityType ( order . Symbol . SecurityType ) ) ;
7981
8082 var wexOrder = new NewOrderSingle
@@ -92,10 +94,22 @@ public bool PlaceOrder(Order order)
9294 ExDestination = new ExDestination ( GetOrderExchange ( order ) )
9395 } ;
9496
95- if ( order . Symbol . SecurityType == SecurityType . Option )
97+ if ( order . Symbol . SecurityType . IsOption ( ) )
9698 {
97- wexOrder . MaturityMonthYear = Utility . GetMaturityMonthYear ( order . Symbol ) ;
9899 wexOrder . StrikePrice = new StrikePrice ( decimal . Round ( order . Price , Utility . LIMIT_DECIMAL_PLACE ) ) ;
100+
101+ var expirationDate = order . Symbol . ID . Date ;
102+ wexOrder . SetField ( new MaturityMonthYear ( expirationDate . ToString ( "yyyyMM" , CultureInfo . InvariantCulture ) ) ) ;
103+ wexOrder . SetField ( new MaturityDay ( expirationDate . Day . ToString ( CultureInfo . InvariantCulture ) ) ) ;
104+ wexOrder . SetField ( new ContractMultiplier ( GetSymbolProperties ( order . Symbol ) . ContractMultiplier ) ) ;
105+ wexOrder . SetField ( new PutOrCall ( order . Symbol . ID . OptionRight == OptionRight . Call ? PutOrCall . CALL : PutOrCall . PUT ) ) ;
106+ }
107+ else if ( order . Symbol . SecurityType == SecurityType . Future )
108+ {
109+ var expirationDate = order . Symbol . ID . Date ;
110+ wexOrder . SetField ( new MaturityMonthYear ( expirationDate . ToString ( "yyyyMM" , CultureInfo . InvariantCulture ) ) ) ;
111+ wexOrder . SetField ( new MaturityDay ( expirationDate . Day . ToString ( CultureInfo . InvariantCulture ) ) ) ;
112+ wexOrder . SetField ( new ContractMultiplier ( GetSymbolProperties ( order . Symbol ) . ContractMultiplier ) ) ;
99113 }
100114
101115 switch ( order . Type )
@@ -162,5 +176,10 @@ private string GetOrderExchange(Order order)
162176 }
163177 return wolverineExchange + exchangePostFix ;
164178 }
179+
180+ private SymbolProperties GetSymbolProperties ( Symbol symbol )
181+ {
182+ return _symbolPropertiesDatabase . GetSymbolProperties ( symbol . ID . Market , symbol , symbol . SecurityType , Currencies . USD ) ;
183+ }
165184 }
166185}
0 commit comments